Classes | Macros | Typedefs | Enumerations | Functions
dn_common.h File Reference

Common API file. More...

#include <wchar.h>
#include <time.h>
Include dependency graph for dn_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SAFEARRAY
 A type definition for the array. More...
 
struct  SAFEARRAYBOUND
 A type definition for the bound of SAFEARRAY. More...
 
union  tagCY
 A type definition for the signed 64bit integer. More...
 
struct  VARIANT
 A type definition for the multi type variable. More...
 

Macros

#define _DN_EXP_COMMON
 
#define _DN_USE_BSTR_API   (1)
 
#define _DN_USE_VARIANT_API   (1)
 
#define _HRESULT_DEFINED
 
#define _HRESULT_TYPEDEF_(_sc)   ((HRESULT)_sc)
 A macro that defines a new HRESULT. More...
 
#define DISP_E_BADINDEX   _HRESULT_TYPEDEF_(0x8002000BL)
 Failed because the index is invalid. More...
 
#define DISP_E_BADVARTYPE   _HRESULT_TYPEDEF_(0x80020008L)
 Failed because bad variable type. More...
 
#define DISP_E_OVERFLOW   _HRESULT_TYPEDEF_(0x8002000AL)
 Failed because out of range. More...
 
#define DISP_E_TYPEMISMATCH   _HRESULT_TYPEDEF_(0x80020005L)
 Failed because the type mismatch. More...
 
#define E_ACCESSDENIED   _HRESULT_TYPEDEF_(0x80070005L)
 Failed because the resource is not ready. More...
 
#define E_ALREADY_REGISTER   _HRESULT_TYPEDEF_(0x80000906L)
 Failed because the packet is too much. More...
 
#define E_FAIL   _HRESULT_TYPEDEF_(0x80004005L)
 Failed because unspecified error occurs. More...
 
#define E_HANDLE   _HRESULT_TYPEDEF_(0x80070006L)
 Failed because the handle is invalid. More...
 
#define E_INVALIDARG   _HRESULT_TYPEDEF_(0x80070057L)
 Failed because some arguments are invalid. More...
 
#define E_MAX_CONNECT   _HRESULT_TYPEDEF_(0x8000090BL)
 Failed because the number of connection is too much. More...
 
#define E_MAX_OBJECT   _HRESULT_TYPEDEF_(0x80000905L)
 Failed because the packet is too much. More...
 
#define E_NOT_CONNECTED   _HRESULT_TYPEDEF_(0x80000902L)
 Failed because the connection is not established. More...
 
#define E_NOTIMPL   _HRESULT_TYPEDEF_(0x80004001L)
 Failed because the function is not implemented. More...
 
#define E_OUTOFMEMORY   _HRESULT_TYPEDEF_(0x8007000EL)
 Failed because there is no enough memory space. More...
 
#define E_TIMEOUT   _HRESULT_TYPEDEF_(0x80000900L)
 Failed because the communication timed out. More...
 
#define E_TOO_MUCH_DATA   _HRESULT_TYPEDEF_(0x80000909L)
 Failed because the packet is too much. More...
 
#define E_UNEXPECTED   _HRESULT_TYPEDEF_(0x8000FFFFL)
 Failed because unexpected error happens. More...
 
#define FAILED(hr)   ((HRESULT)hr < 0)
 A macro that returns TRUE/FALSE. If hr is less than zero, then returns TRUE. More...
 
#define FORMAT_DATE2BSTR   "%Y/%m/%d %H:%M:%S"
 A definition for the format string converting DATE to BSTR. More...
 
#define OSERR2HRESULT(err)   (((err) & 0x0000FFFF) | 0x80910000)
 A macro that returns HREUSLT(0x8091) which means OS error. More...
 
#define S_FALSE   ((HRESULT)1L)
 Succeeded but some processes may remain. More...
 
#define S_OK   ((HRESULT)0L)
 Succeeded. More...
 
#define SUCCEEDED(hr)   ((HRESULT)hr >= 0)
 A macro that returns TRUE/FALSE. If hr is zero or more, then returns TRUE. More...
 
#define VARIANT_FALSE   ((VARIANT_BOOL) 0)
 FALSE for VARIANT. More...
 
#define VARIANT_TRUE   ((VARIANT_BOOL)-1)
 TRUE for VARIANT. More...
 

Typedefs

typedef wchar_t * BSTR
 
typedef union tagCY CY
 
typedef time_t DATE
 
typedef int32_t HRESULT
 
typedef struct SAFEARRAY SAFEARRAY
 
typedef struct SAFEARRAYBOUND SAFEARRAYBOUND
 
typedef struct VARIANT VARIANT
 
typedef int16_t VARIANT_BOOL
 

Enumerations

enum  VARENUM {
  VT_EMPTY = 0, VT_NULL = 1, VT_I2 = 2, VT_I4 = 3,
  VT_R4 = 4, VT_R8 = 5, VT_CY = 6, VT_DATE = 7,
  VT_BSTR = 8, VT_ERROR = 10, VT_BOOL = 11, VT_VARIANT = 12,
  VT_UI1 = 17, VT_UI2 = 18, VT_UI4 = 19, VT_I8 = 20,
  VT_UI8 = 21, VT_ARRAY = 0x2000
}
 Variant type. More...
 

Functions

_DN_EXP_COMMON uint32_t ChangeVarType (VARIANT varSrc, uint16_t vt, void *pDest, uint32_t dwSize)
 Changes the variant to destination value with the indicated type. More...
 
_DN_EXP_COMMON wchar_t * ConvertMultiByte2WideChar (const char *chSrc)
 Converts string to wide string. More...
 
_DN_EXP_COMMON char * ConvertWideChar2MultiByte (const wchar_t *chSrc)
 Converts wide string to string. More...
 
_DN_EXP_COMMON HRESULT GetOptionValue (BSTR bstrSrc, BSTR bstrKey, uint16_t vt, VARIANT *pvarDest)
 Searchs the key string from source string and sets the value to the destination variant with the indicated type. More...
 
_DN_EXP_COMMON HRESULT SafeArrayAccessData (SAFEARRAY *psa, void **ppvData)
 Accesses the SAFEARRAY and gets the pointer of array data. More...
 
_DN_EXP_COMMON SAFEARRAYSafeArrayCreateVector (uint16_t vt, int32_t lLbound, uint32_t cElements)
 Allocates and returns SAFEARRAY. More...
 
_DN_EXP_COMMON HRESULT SafeArrayDestroy (SAFEARRAY *psa)
 Releases the memory of SAFEARRAY. More...
 
_DN_EXP_COMMON uint16_t SafeArrayGetDim (SAFEARRAY *psa)
 Gets and returns the dimension of SAFEARRAY. More...
 
_DN_EXP_COMMON uint32_t SafeArrayGetElemsize (SAFEARRAY *psa)
 Gets and returns the size of an element. More...
 
_DN_EXP_COMMON HRESULT SafeArrayGetLBound (SAFEARRAY *psa, uint16_t nDim, int32_t *plLbound)
 Gets the lower bound of SAFEARRAY. More...
 
_DN_EXP_COMMON HRESULT SafeArrayGetUBound (SAFEARRAY *psa, uint16_t nDim, int32_t *plUbound)
 Gets the upper bound of SAFEARRAY. More...
 
_DN_EXP_COMMON HRESULT SafeArrayGetVartype (SAFEARRAY *psa, uint16_t *pvt)
 Gets the variant type of SAFEARRAY. More...
 
_DN_EXP_COMMON HRESULT SafeArrayUnaccessData (SAFEARRAY *psa)
 Unaccesses the SAFEARRAY. More...
 
_DN_EXP_COMMON BSTR SysAllocString (const wchar_t *sz)
 Allocates and returns BSTR. More...
 
_DN_EXP_COMMON BSTR SysAllocStringLen (const wchar_t *pch, uint16_t cch)
 Allocates and returns BSTR. More...
 
_DN_EXP_COMMON void SysFreeString (BSTR bstr)
 Releases the memory of BSTR. More...
 
_DN_EXP_COMMON uint16_t SysStringLen (BSTR bstr)
 Gets and returns the number of characters of BSTR. More...
 
_DN_EXP_COMMON HRESULT VariantChangeType (VARIANT *pvargDest, VARIANT *pvarSrc, uint16_t wFlags, uint16_t vt)
 Changes the source variant to destination variant with the indicated type. More...
 
_DN_EXP_COMMON void VariantClear (VARIANT *pvarg)
 Clears the VARIANT. More...
 
_DN_EXP_COMMON HRESULT VariantCopy (VARIANT *pvargDest, const VARIANT *pvargSrc)
 Copies the source variant to destination variant. More...
 
_DN_EXP_COMMON void VariantInit (VARIANT *pvarg)
 Initializes the VARIANT. More...
 

Detailed Description

Common API file.

Defines some types, macros and functions to be compatible with Windows.

Version
1.2
Date
2014/11/06
2015/01/20 Adds VariantCopy, VariantChangeType, ChangeVarType, and GetOptionValue functions.
2016/09/15 Adds ConvertMultiByte2WideChar and ConvertWideChar2MultiByte functions.
2017/01/18 Adds VT_I8 and VT_UI8.
Author
DENSO WAVE

Software License Agreement (MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file dn_common.h.

Macro Definition Documentation

#define _DN_EXP_COMMON

Definition at line 40 of file dn_common.h.

#define _DN_USE_BSTR_API   (1)

Definition at line 48 of file dn_common.h.

#define _DN_USE_VARIANT_API   (1)

Definition at line 44 of file dn_common.h.

#define _HRESULT_DEFINED

Definition at line 59 of file dn_common.h.

#define _HRESULT_TYPEDEF_ (   _sc)    ((HRESULT)_sc)

A macro that defines a new HRESULT.

Definition at line 83 of file dn_common.h.

#define DISP_E_BADINDEX   _HRESULT_TYPEDEF_(0x8002000BL)

Failed because the index is invalid.

Definition at line 161 of file dn_common.h.

#define DISP_E_BADVARTYPE   _HRESULT_TYPEDEF_(0x80020008L)

Failed because bad variable type.

Definition at line 149 of file dn_common.h.

#define DISP_E_OVERFLOW   _HRESULT_TYPEDEF_(0x8002000AL)

Failed because out of range.

Definition at line 155 of file dn_common.h.

#define DISP_E_TYPEMISMATCH   _HRESULT_TYPEDEF_(0x80020005L)

Failed because the type mismatch.

Definition at line 143 of file dn_common.h.

#define E_ACCESSDENIED   _HRESULT_TYPEDEF_(0x80070005L)

Failed because the resource is not ready.

Definition at line 113 of file dn_common.h.

#define E_ALREADY_REGISTER   _HRESULT_TYPEDEF_(0x80000906L)

Failed because the packet is too much.

Definition at line 187 of file dn_common.h.

#define E_FAIL   _HRESULT_TYPEDEF_(0x80004005L)

Failed because unspecified error occurs.

Definition at line 107 of file dn_common.h.

#define E_HANDLE   _HRESULT_TYPEDEF_(0x80070006L)

Failed because the handle is invalid.

Definition at line 119 of file dn_common.h.

#define E_INVALIDARG   _HRESULT_TYPEDEF_(0x80070057L)

Failed because some arguments are invalid.

Definition at line 131 of file dn_common.h.

#define E_MAX_CONNECT   _HRESULT_TYPEDEF_(0x8000090BL)

Failed because the number of connection is too much.

Definition at line 199 of file dn_common.h.

#define E_MAX_OBJECT   _HRESULT_TYPEDEF_(0x80000905L)

Failed because the packet is too much.

Definition at line 181 of file dn_common.h.

#define E_NOT_CONNECTED   _HRESULT_TYPEDEF_(0x80000902L)

Failed because the connection is not established.

Definition at line 175 of file dn_common.h.

#define E_NOTIMPL   _HRESULT_TYPEDEF_(0x80004001L)

Failed because the function is not implemented.

Definition at line 101 of file dn_common.h.

#define E_OUTOFMEMORY   _HRESULT_TYPEDEF_(0x8007000EL)

Failed because there is no enough memory space.

Definition at line 125 of file dn_common.h.

#define E_TIMEOUT   _HRESULT_TYPEDEF_(0x80000900L)

Failed because the communication timed out.

Definition at line 169 of file dn_common.h.

#define E_TOO_MUCH_DATA   _HRESULT_TYPEDEF_(0x80000909L)

Failed because the packet is too much.

Definition at line 193 of file dn_common.h.

#define E_UNEXPECTED   _HRESULT_TYPEDEF_(0x8000FFFFL)

Failed because unexpected error happens.

Definition at line 137 of file dn_common.h.

#define FAILED (   hr)    ((HRESULT)hr < 0)

A macro that returns TRUE/FALSE. If hr is less than zero, then returns TRUE.

Definition at line 77 of file dn_common.h.

#define FORMAT_DATE2BSTR   "%Y/%m/%d %H:%M:%S"

A definition for the format string converting DATE to BSTR.

Note
You can change this parameter.

Definition at line 56 of file dn_common.h.

#define OSERR2HRESULT (   err)    (((err) & 0x0000FFFF) | 0x80910000)

A macro that returns HREUSLT(0x8091) which means OS error.

Definition at line 205 of file dn_common.h.

#define S_FALSE   ((HRESULT)1L)

Succeeded but some processes may remain.

Definition at line 95 of file dn_common.h.

#define S_OK   ((HRESULT)0L)

Succeeded.

Definition at line 89 of file dn_common.h.

#define SUCCEEDED (   hr)    ((HRESULT)hr >= 0)

A macro that returns TRUE/FALSE. If hr is zero or more, then returns TRUE.

Definition at line 71 of file dn_common.h.

#define VARIANT_FALSE   ((VARIANT_BOOL) 0)

FALSE for VARIANT.

Definition at line 273 of file dn_common.h.

#define VARIANT_TRUE   ((VARIANT_BOOL)-1)

TRUE for VARIANT.

Definition at line 267 of file dn_common.h.

Typedef Documentation

typedef wchar_t* BSTR

Definition at line 239 of file dn_common.h.

typedef union tagCY CY
typedef time_t DATE

Definition at line 259 of file dn_common.h.

typedef int32_t HRESULT

Definition at line 61 of file dn_common.h.

typedef struct SAFEARRAY SAFEARRAY
typedef struct VARIANT VARIANT

Definition at line 261 of file dn_common.h.

Enumeration Type Documentation

enum VARENUM

Variant type.

Enumerator
VT_EMPTY 

No argument

VT_NULL 

No argument

VT_I2 

int16_t

VT_I4 

int32_t

VT_R4 

float

VT_R8 

double

VT_CY 

CY

VT_DATE 

DATE

VT_BSTR 

BSTR

VT_ERROR 

ERROR

VT_BOOL 

VARIANT_BOOL

VT_VARIANT 

VARIANT

VT_UI1 

uint8_t

VT_UI2 

uint16_t

VT_UI4 

uint32_t

VT_I8 

int64_t

VT_UI8 

uint64_t

VT_ARRAY 

SAFEARRAY

Definition at line 213 of file dn_common.h.

Function Documentation

uint32_t ChangeVarType ( VARIANT  varSrc,
uint16_t  vt,
void *  pDest,
uint32_t  dwSize 
)

Changes the variant to destination value with the indicated type.

Parameters
[in]varSrcThe source variant.
[in]vtThe variant type.
[out]pDestThe pointer of the destination value.
[in]dwSizeThe maximum number of changed values.
wchar_t * ConvertMultiByte2WideChar ( const char *  chSrc)

Converts string to wide string.

Parameters
[in]chSrcThe source string.
char * ConvertWideChar2MultiByte ( const wchar_t *  chSrc)

Converts wide string to string.

Parameters
[in]chSrcThe source string.
HRESULT GetOptionValue ( BSTR  bstrSrc,
BSTR  bstrKey,
uint16_t  vt,
VARIANT pvarDest 
)

Searchs the key string from source string and sets the value to the destination variant with the indicated type.

Parameters
[in]bstrSrcThe source string.
[in]bstrKeyThe key string.
[in]vtThe variant type.
[out]pvarDestThe destination variant.
HRESULT SafeArrayAccessData ( SAFEARRAY psa,
void **  ppvData 
)

Accesses the SAFEARRAY and gets the pointer of array data.

Parameters
[in]psaSAFEARRAY to be accessed.
[out]ppvDataThe gotten pointer.
Note
This function must be called before accessing SAFEARRAY data.

Definition at line 336 of file dn_common.c.

SAFEARRAY * SafeArrayCreateVector ( uint16_t  vt,
int32_t  lLbound,
uint32_t  cElements 
)

Allocates and returns SAFEARRAY.

Parameters
[in]vtVariant type.
[in]lLboundThe lower bound of array. This should be 0.
[in]cElementsThe number of elements.
Note
If there is no enough memory space, then return NULL.

Definition at line 138 of file dn_common.c.

HRESULT SafeArrayDestroy ( SAFEARRAY psa)

Releases the memory of SAFEARRAY.

Parameters
[in,out]psaSAFEARRAY to be freed.

Definition at line 212 of file dn_common.c.

uint16_t SafeArrayGetDim ( SAFEARRAY psa)

Gets and returns the dimension of SAFEARRAY.

Parameters
[in]psaSAFEARRAY to be gotten.

Definition at line 248 of file dn_common.c.

uint32_t SafeArrayGetElemsize ( SAFEARRAY psa)

Gets and returns the size of an element.

Parameters
[in]psaSAFEARRAY to be gotten.

Definition at line 262 of file dn_common.c.

HRESULT SafeArrayGetLBound ( SAFEARRAY psa,
uint16_t  nDim,
int32_t plLbound 
)

Gets the lower bound of SAFEARRAY.

Parameters
[in]psaSAFEARRAY to be gotten.
[in]nDimThe target dimension.
[out]plLboundThe gotten lower bound.

Definition at line 278 of file dn_common.c.

HRESULT SafeArrayGetUBound ( SAFEARRAY psa,
uint16_t  nDim,
int32_t plUbound 
)

Gets the upper bound of SAFEARRAY.

Parameters
[in]psaSAFEARRAY to be gotten.
[in]nDimThe target dimension.
[out]plUboundThe gotten upper bound.

Definition at line 298 of file dn_common.c.

HRESULT SafeArrayGetVartype ( SAFEARRAY psa,
uint16_t pvt 
)

Gets the variant type of SAFEARRAY.

Parameters
[in]psaSAFEARRAY to be gotten.
[out]pvtThe gotten variant type.

Definition at line 318 of file dn_common.c.

HRESULT SafeArrayUnaccessData ( SAFEARRAY psa)

Unaccesses the SAFEARRAY.

Parameters
[in]psaSAFEARRAY to be unaccessed.
Note
This function must be called after accessing SAFEARRAY data.

Definition at line 353 of file dn_common.c.

BSTR SysAllocString ( const wchar_t *  sz)

Allocates and returns BSTR.

Parameters
[in]szUnicode string to be copied. This must be NULL terminated.
Note
If there is no enough memory space, then return NULL.

Definition at line 61 of file dn_common.c.

BSTR SysAllocStringLen ( const wchar_t *  pch,
uint16_t  cch 
)

Allocates and returns BSTR.

Parameters
[in]pchUnicode string to be copied. This must be NULL terminated.
[in]cchThe number of characters to be copied.
Note
If there is no enough memory space, then return NULL.

Definition at line 77 of file dn_common.c.

void SysFreeString ( BSTR  bstr)

Releases the memory of BSTR.

Parameters
[in,out]bstrUnicode string to be freed.

Definition at line 104 of file dn_common.c.

uint16 SysStringLen ( BSTR  bstr)

Gets and returns the number of characters of BSTR.

Parameters
[in]bstrUnicode string to be gotten. This must be NULL terminated.

Definition at line 118 of file dn_common.c.

HRESULT VariantChangeType ( VARIANT pvargDest,
VARIANT pvarSrc,
uint16_t  wFlags,
uint16_t  vt 
)

Changes the source variant to destination variant with the indicated type.

Parameters
[out]pvargDestThe destination variant to be changed.
[in]pvarSrcThe source variant.
[in]wFlagsFlags.
[in]vtThe variant type.
Note
This function is not sufficiently compatible with Windows.
void VariantClear ( VARIANT pvarg)

Clears the VARIANT.

Parameters
[in,out]pvargVARIANT to be cleared.
Note
This function must be called before destructing VARIANT.

Definition at line 382 of file dn_common.c.

HRESULT VariantCopy ( VARIANT pvargDest,
const VARIANT pvargSrc 
)

Copies the source variant to destination variant.

Parameters
[out]pvargDestThe destination variant to be changed.
[in]pvarSrcThe source variant.
void VariantInit ( VARIANT pvarg)

Initializes the VARIANT.

Parameters
[in,out]pvargVARIANT to be initialized.
Note
This function must be called before accessing VARIANT.

Definition at line 368 of file dn_common.c.



bcap_core
Author(s): DENSO WAVE INCORPORATED
autogenerated on Mon Jun 10 2019 13:12:20