Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

Functions

The PCG functions layer. More...

Classes

class  functions::Exporter
class  functions::Importer
 Write brief comment for Importer here. More...
class  BadConversion
 Write brief comment for BadConversion here. More...
class  log
 Write brief comment for log here. More...

Functions

std::string stringify (const char *c)
 Write brief comment for stringify here.
template<typename T>
void convert (const std::string &s, T &x, bool failIfLeftoverChars=true)
 Write brief comment for convert here.
template<typename T>
convertTo (const std::string &s, bool failIfLeftoverChars=true)
 Write brief comment for convertTo here.
void Tokenize (const string &str, vector< string > &tokens, const string &delimiters=" ")
 Write brief comment for Tokenize here.

Detailed Description

The PCG functions layer.


Function Documentation

template<typename T>
void convert const std::string &  s,
T &  x,
bool  failIfLeftoverChars = true
[inline]
 

Write brief comment for convert here.

Parameters:
s Description of parameter s.
x Description of parameter x.
failIfLeftoverChars Description of parameter failIfLeftoverChars.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for convert here.

Remarks:
Write remarks for convert here.
See also:
Separate items with the '|' character.

Definition at line 91 of file func.h.

Referenced by convertTo().

00091                                                                                 {
00092    std::istringstream i(s);
00093    char c;
00094    if (!(i >> x) || (failIfLeftoverChars && i.get(c))) {
00095                 throw BadConversion(s);
00096    }
00097 }

template<typename T>
T convertTo const std::string &  s,
bool  failIfLeftoverChars = true
[inline]
 

Write brief comment for convertTo here.

Parameters:
s Description of parameter s.
failIfLeftoverChars Description of parameter failIfLeftoverChars.
Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for convertTo here.

Remarks:
Write remarks for convertTo here.
See also:
Separate items with the '|' character.

Definition at line 124 of file func.h.

References convert().

00124                                                                          {
00125         T x;
00126         convert(s, x, failIfLeftoverChars);
00127         return x;
00128  }

Here is the call graph for this function:

std::string stringify const char *  c  )  [inline]
 

Write brief comment for stringify here.

Parameters:
c Description of parameter c.
Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for stringify here.

Remarks:
Write remarks for stringify here.
See also:
Separate items with the '|' character.

Definition at line 58 of file func.h.

00059  {
00060    std::ostringstream o;
00061    if (!(o << c))
00062      throw BadConversion("stringify(const char*)");
00063    return o.str();
00064  }

void Tokenize const string &  str,
vector< string > &  tokens,
const string &  delimiters = " "
[inline]
 

Write brief comment for Tokenize here.

Parameters:
str Description of parameter str.
tokens Description of parameter tokens.
delimiters Description of parameter delimiters.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for Tokenize here.

Remarks:
Write remarks for Tokenize here.
See also:
Separate items with the '|' character.

Definition at line 154 of file func.h.

Referenced by model::Model::load(), model::Analyzer::load(), and functions::Importer::readAttributes().

00154                                                                                                 {
00155     // Skip delimiters at beginning.
00156     string::size_type lastPos = str.find_first_not_of(delimiters, 0);
00157     // Find first "non-delimiter".
00158     string::size_type pos     = str.find_first_of(delimiters, lastPos);
00159 
00160     while (string::npos != pos || string::npos != lastPos)
00161     {
00162         // Found a token, add it to the vector.
00163                 string tmp = str.substr(lastPos, pos - lastPos);
00164                 string::size_type loc = tmp.find( "\n", 0 );
00165                 if(loc != string::npos) {
00166                         tmp.erase(loc,1);
00167                 }
00168         tokens.push_back(tmp);
00169                 //cout << "Token: " << tokens[tokens.size()-1] << "\n";
00170         // Skip delimiters.  Note the "not_of"
00171         lastPos = str.find_first_not_of(delimiters, pos);
00172                 
00173         // Find next "non-delimiter"
00174         pos = str.find_first_of(delimiters, lastPos);
00175                 
00176     }
00177 }


Generated on Tue Apr 17 09:39:51 2007 for PCG Library by  doxygen 1.3.9.1