proj home

Files   Classes   Functions   Hierarchy  

vectorstring Class Reference

Read and write vectors to strings. More...

#include <stringserialization.h>

List of all members.

Static Public Member Functions

template<typename T >
static boolc serialize (string &str, vector< T > const &v)
 Write a vector to a string.
template<typename T >
static boolc deserialize (vector< T > &v, stringc &str)
 Read a string into a vector.
template<typename T >
static void serializeInverse (vector< T > &v, stringc &str)


Detailed Description

Read and write vectors to strings.

Definition at line 17 of file stringserialization.h.


Member Function Documentation

template<typename T >
boolc vectorstring::deserialize ( vector< T > &  v,
stringc str 
) [inline, static]

Read a string into a vector.

Definition at line 119 of file stringserialization.h.

Referenced by serializeInverse(), stringserializationtest::test01(), and stringserializationtest::test02().

00120 {
00121   stringstream targ(str);
00122   if (targ.good()==false)
00123     return false;
00124 
00125   bool process=true;
00126   T val;
00127   for (;process; )
00128   {
00129     targ >> val;
00130     // The end of input must fail.
00131     if (targ.fail())
00132     {
00133       // If it is not the end of the data stream return false.
00134       if (!targ.eof())
00135         return false;
00136 
00137       // Do not add the last element twice.
00138       process=false;
00139     }
00140     else
00141       v.push_back(val);
00142   }
00143   
00144   return true;
00145 }

template<typename T >
boolc vectorstring::serialize ( string &  str,
vector< T > const &  v 
) [inline, static]

Write a vector to a string.

Definition at line 99 of file stringserialization.h.

Referenced by stringserializationtest::test01(), and stringserializationtest::test02().

00100 {
00101   uintc vsz=v.size();
00102   str="";
00103   stringc space(" ");
00104   
00105   for (uint i=0; i<vsz; ++i)
00106   {
00107     stringstream targ;
00108     targ << v[i];
00109     if (targ.good()==false)
00110       return false;
00111    
00112     str += (targ.str()+space);
00113   }
00114 
00115   return true;
00116 }

template<typename T >
static void vectorstring::serializeInverse ( vector< T > &  v,
stringc str 
) [inline, static]

Definition at line 29 of file stringserialization.h.

References deserialize().

Referenced by visconvex::handlecommand().

00030     { deserialize(v,str); };


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

Generated on Fri Mar 4 00:50:23 2011 for Chelton Evans Source by  doxygen 1.5.8