Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Static Public Member Functions | List of all members
kome::core::ConversionTool Class Reference

the class that has some functions for convert More...

#include <ConversionTool.h>

Static Public Member Functions

static std::string getIdName (const int id, IDInfo *idInfoArray, const unsigned int arraySize)
 gets name from id number More...
 
template<typename S , typename T >
static T convert (const S key, const T dfVal, ConversionElement< S, T > *elementArray, int arraySize)
 gets converted value from key ( S -> T ) More...
 
template<typename S , typename T >
static S invert (const T key, const S dfVal, ConversionElement< S, T > *elementArray, int arraySize)
 gets converted value from key ( T -> S ) More...
 

Detailed Description

the class that has some functions for convert

Definition at line 72 of file ConversionTool.h.

Member Function Documentation

template<typename S , typename T >
static T kome::core::ConversionTool::convert ( const S  key,
const T  dfVal,
ConversionElement< S, T > *  elementArray,
int  arraySize 
)
inlinestatic

gets converted value from key ( S -> T )

Parameters
[in]keykey
[in]dfValdefault value to be returned when the specified key is not found
[in]elementArraythe array of conversion element
arraySizethe size of array
Returns
converted value

Definition at line 107 of file ConversionTool.h.

112  {
113  // check arguments
114  if( elementArray == NULL || arraySize <= 0 ) {
115  return dfVal;
116  }
117 
118  // search
119  for( int i = 0; i < arraySize; i++ ) {
120  if( key == elementArray[ i ].key ) {
121  return elementArray[ i ].value;
122  }
123  }
124 
125  return dfVal;
126  }
#define NULL
Definition: CoreMacros.h:18
static std::string kome::core::ConversionTool::getIdName ( const int  id,
IDInfo idInfoArray,
const unsigned int  arraySize 
)
static

gets name from id number

Parameters
[in]idID
[in]idInfoArraythe array of ID informations
[in]arraySizearray size
Returns
name ( If specified ID is not found, this method returns empty string. )

Definition at line 28 of file ConversionTool.cpp.

32  {
33  // string object
34  std::string name;
35 
36  // check parameters
37  if( idInfoArray == NULL || arraySize == 0 ) {
38  return name;
39  }
40 
41  // find ID
42  for( unsigned int i = 0; i < arraySize && name.empty(); i++ ) {
43  if( idInfoArray[ i ].id == id ) { // matched
44  name = std::string( NVL( idInfoArray[ i ].name, "" ) );
45  }
46  }
47 
48  return name;
49 }
#define NVL(checkVal, replaceVal)
Definition: CoreMacros.h:99
#define NULL
Definition: CoreMacros.h:18
template<typename S , typename T >
static S kome::core::ConversionTool::invert ( const T  key,
const S  dfVal,
ConversionElement< S, T > *  elementArray,
int  arraySize 
)
inlinestatic

gets converted value from key ( T -> S )

Parameters
[in]keykey
[in]dfValdefault value to be returned when the specified key is not found
[in]elementArraythe array of conversion element
[in]arraySizethe size of array
Returns
converted value

Definition at line 143 of file ConversionTool.h.

148  {
149  // check arguments
150  if( elementArray == NULL || arraySize <= 0 ) {
151  return dfVal;
152  }
153 
154  // search
155  for( int i = 0; i < arraySize; i++ ) {
156  if( key == elementArray[ i ].value ) {
157  return elementArray[ i ].key;
158  }
159  }
160 
161  return dfVal;
162  }
#define NULL
Definition: CoreMacros.h:18

The documentation for this class was generated from the following files: