30 template<
class T >
class Conv
38 static unsigned int size(
const T& val )
40 return 1 + (
sizeof( T ) - 1 ) /
sizeof( double );
45 const T* ret =
reinterpret_cast< const T*
>( *buf );
56 static void val2buf(
const T& val,
double** buf ) {
57 *
reinterpret_cast< T*
>( *buf ) = val;
65 static void str2val( T& val,
const string& s ) {
66 istringstream is( s );
74 static void val2str(
string& s,
const T& val ) {
83 if (
typeid( T ) ==
typeid(
char ))
85 if (
typeid( T ) ==
typeid(
int ) )
87 if (
typeid( T ) ==
typeid(
short ) )
89 if (
typeid( T ) ==
typeid(
long ) )
91 if (
typeid( T ) ==
typeid(
unsigned int ) )
92 return "unsigned int";
93 if (
typeid( T ) ==
typeid(
unsigned long ) )
94 return "unsigned long";
95 if (
typeid( T ) ==
typeid(
float ) )
97 if (
typeid( T ) ==
typeid(
double ) )
99 if (
typeid( T ) ==
typeid(
Id ) )
101 if (
typeid( T ) ==
typeid(
ObjId ) )
103 return typeid( T ).
name();
113 template<>
class Conv< string >
122 static unsigned int size(
const string& val )
125 return 1 + val.length() /
sizeof( double );
132 ret =
reinterpret_cast< const char*
>( *buf );
143 static void val2buf(
const string& val,
double** buf ) {
144 char* temp =
reinterpret_cast< char*
>( *buf );
145 strcpy( temp, val.c_str() );
149 static void str2val(
string& val,
const string& s ) {
153 static void val2str(
string& s,
const string& val ) {
167 template<>
class Conv< double >
173 static unsigned int size(
double val )
183 static void val2buf(
double val,
double** buf ) {
188 static void str2val(
double &val,
const string& s ) {
189 val = atof( s.c_str() );
192 static void val2str(
string& s,
double val ) {
214 static unsigned int size(
float val )
224 static void val2buf(
float val,
double** buf ) {
229 static void str2val(
float& val,
const string& s ) {
230 val = atof( s.c_str() );
249 template<>
class Conv< unsigned int >
255 static unsigned int size(
int val )
260 static const unsigned int buf2val(
double** buf ) {
261 unsigned int ret = (
unsigned int)**buf;
265 static void val2buf(
unsigned int val,
double** buf ) {
270 static void str2val(
unsigned int& val,
const string& s ) {
271 val = atoi( s.c_str() );
274 static void val2str(
string& s,
unsigned int val ) {
281 return "unsigned int";
296 static unsigned int size(
int val )
302 int ret = (int)**buf;
306 static void val2buf(
int val,
double** buf ) {
311 static void str2val(
int& val,
const string& s ) {
312 val = atoi( s.c_str() );
327 template<>
class Conv< unsigned short >
333 static unsigned int size(
unsigned short val )
338 static const unsigned short buf2val(
double** buf ) {
339 unsigned short ret = (
unsigned int)**buf;
343 static void val2buf(
unsigned short val,
double** buf ) {
348 static void str2val(
unsigned short& val,
const string& s ) {
349 val = atoi( s.c_str() );
352 static void val2str(
string& s,
unsigned short val ) {
359 return "unsigned short";
370 static unsigned int size(
short val )
376 short ret = (short)**buf;
380 static void val2buf(
short val,
double** buf ) {
385 static void str2val(
short& val,
const string& s ) {
386 val = atoi( s.c_str() );
407 static unsigned int size(
bool val )
413 bool ret = (**buf > 0.5);
417 static void val2buf(
bool val,
double** buf ) {
422 static void str2val(
bool& val,
const string& s ) {
423 if ( s ==
"0" || s ==
"false" || s ==
"False" )
460 Id ret( (
unsigned int)**buf );
497 template<
class T >
class Conv< vector< vector< T > > >
500 static unsigned int size(
const vector< vector < T > > & val)
502 unsigned int ret = 1 + val.size();
503 for (
unsigned int i = 0; i < val.size(); ++i ) {
504 if ( val[i].
size() > 0 ) {
514 static const vector< vector< T > >
buf2val(
double** buf )
516 static vector< vector< T > > ret;
519 ret.resize( numEntries );
521 for (
unsigned int i = 0; i <
numEntries; ++i ) {
522 unsigned int rowSize = **buf;
524 for (
unsigned int j = 0; j < rowSize; ++j )
530 static void val2buf(
const vector< vector< T > >& val,
double**buf )
533 *temp++ = val.size();
534 for(
unsigned int i = 0; i < val.size(); ++i ) {
535 *temp++ = val[i].size();
536 for (
unsigned int j = 0; j < val[i].size(); ++j ) {
543 static void str2val( vector< vector< T > >& val,
const string& s ) {
544 cout <<
"Specialized Conv< vector< vector< T > > >::str2val not done\n";
547 static void val2str(
string& s,
const vector< vector< T > >& val ) {
548 cout <<
"Specialized Conv< vector< vector< T > > >::val2str not done\n";
564 template<
class T >
class Conv< vector< T > >
570 static unsigned int size(
const vector< T >& val )
572 unsigned int ret = 1;
573 for (
unsigned int i = 0; i < val.size(); ++i ) {
579 static const vector< T >
buf2val(
double** buf )
581 static vector< T > ret;
583 unsigned int numEntries = (
unsigned int)**buf;
585 for (
unsigned int i = 0; i <
numEntries; ++i )
590 static void val2buf(
const vector< T >& val,
double**buf )
593 *temp++ = val.size();
594 for(
unsigned int i = 0; i < val.size(); ++i ) {
600 static void str2val( vector< T >& val,
const string& s ) {
601 cout <<
"Specialized Conv< vector< T > >::str2val not done\n";
604 static void val2str(
string& s,
const vector< T >& val ) {
605 cout <<
"Specialized Conv< vector< T > >::val2str not done\n";
static void val2buf(Id id, double **buf)
static void str2val(short &val, const string &s)
static void str2val(vector< vector< T > > &val, const string &s)
static void val2buf(const T &val, double **buf)
static unsigned int size(bool val)
static unsigned int size(const string &val)
static const unsigned short buf2val(double **buf)
static void val2str(string &s, short val)
static void str2val(vector< T > &val, const string &s)
std::string path(const std::string &separator="/") const
static void val2str(string &s, unsigned int val)
static void val2str(string &s, const vector< T > &val)
static void val2buf(unsigned short val, double **buf)
static const vector< T > buf2val(double **buf)
static void val2str(string &s, float val)
static const int buf2val(double **buf)
static void val2buf(short val, double **buf)
static const double buf2val(double **buf)
static void val2buf(const vector< T > &val, double **buf)
static const short buf2val(double **buf)
static const float buf2val(double **buf)
static void val2str(string &s, unsigned short val)
static const vector< vector< T > > buf2val(double **buf)
static void val2str(string &s, Id val)
static void val2buf(const vector< vector< T > > &val, double **buf)
static void str2val(Id &val, const string &s)
static void str2val(string &val, const string &s)
static void str2val(int &val, const string &s)
static void val2str(string &s, const vector< vector< T > > &val)
static unsigned int size(const T &val)
static void val2str(string &s, double val)
static const unsigned int UnreasonablyLargeArray
static void val2str(string &s, int val)
static void str2val(double &val, const string &s)
static void str2val(float &val, const string &s)
static void val2buf(int val, double **buf)
static const unsigned int buf2val(double **buf)
static void str2val(bool &val, const string &s)
static void str2val(T &val, const string &s)
static void str2val(unsigned short &val, const string &s)
static void val2buf(bool val, double **buf)
static void val2str(string &s, bool val)
static unsigned int size(int val)
static unsigned int size(unsigned short val)
static unsigned int size(Id val)
static unsigned int size(short val)
static const T & buf2val(double **buf)
static void val2buf(float val, double **buf)
static void val2buf(double val, double **buf)
static void val2str(string &s, const T &val)
static unsigned int size(float val)
static unsigned int size(int val)
static const bool buf2val(double **buf)
static void str2val(unsigned int &val, const string &s)
static const Id buf2val(double **buf)
static void val2buf(unsigned int val, double **buf)
static unsigned int size(const vector< vector< T > > &val)
static void val2str(string &s, const string &val)
static void val2buf(const string &val, double **buf)
static const string buf2val(double **buf)
static unsigned int size(double val)
static unsigned int size(const vector< T > &val)