31 if ( ch==
',' || isspace(ch) ) {
return true; }
33 if ( ch==
'(' || ch==
')' ) {
return true; }
34 if ( ch==
'<' || ch==
'>' ) {
return true; }
35 if ( ch==
'{' || ch==
'}' ) {
return true; }
36 if ( ch==
'[' || ch==
']' ) {
return true; }
61 template <
class STRING>
62 const char*
str2list( std::list<STRING>& L ,
const char* str ) {
64 if ( str == 0) {
return 0; }
65 if (*str == 0) {
return str; }
67 if (*str==
'|') { ++str; }
70 const bool IN_WHITESPACE =
false;
const bool IN_STRING = !IN_WHITESPACE;
71 bool state = IN_WHITESPACE;
72 while ( (*str != 0) && (*str !=
'|') ) {
73 if ( state == IN_WHITESPACE ) {
83 state = IN_WHITESPACE;
91 if ( !val.empty() ) { L.push_back(val); }
104 inline std::list<std::string>
str2list(
const char* str ) {
105 std::list<std::string> L;
116 template <
class N,
class ATON_wrap>
118 std::list<std::string> L;
122 std::list< std::string >::const_iterator it;
123 for ( it= L.begin(); it!=L.end(); ++it ) {
124 RES.push_back( ATON_wrap::ATON(it->c_str()) );
132 static int ATON(
const char * str ) {
return atoi(str); }
138 static long ATON(
const char * str ) {
return atol(str); }
144 static double ATON(
const char * str ) {
return atof(str); }
147 inline std::list<int>
intlist(
const char* str ) {
148 return str2list_wrap<int, str2list_int_wrap>( str );
160 return str2list_wrap<int, str2list_int_wrap>( str );
164 inline std::list<long>
longlist(
const char* str ) {
165 return str2list_wrap<long, str2list_long_wrap>( str );
177 return str2list_wrap<long, str2list_long_wrap>( str );
190 return str2list_wrap<double, str2list_double_wrap>( str );
194 std::list<std::string> Lstr;
195 std::list<char> Lchar;
198 std::list< std::string >::const_iterator it;
199 for ( it= Lstr.begin(); it!=Lstr.end(); ++it ) {
200 if ( (*it)[0] ==
'\'' ) {
201 if ( it->size() == 1 ) {
202 Lchar.push_back(
' ' );
206 Lchar.push_back( (*it)[1] );
210 Lchar.push_back( (*it)[0] );
245 template <
class STRING>
246 size_t str2matrix( std::list< std::list<STRING> >& M ,
const char* str ) {
248 if ( str == 0) {
return 0; }
249 if (*str == 0) {
return 0; }
252 M.push_back( std::list<STRING>() );
253 while ( *str != 0 ) {
254 typename std::list<STRING> & L = M.back();
256 if ( *str!=0 ) { str++; }
257 mx = ( L.size()<mx ? mx : L.size() );
258 if ( ! M.back().empty() ) {
259 M.push_back( std::list<STRING>() );
262 if ( M.back().empty() ) { M.pop_back(); }
275 template <
class N,
class ATON_wrap,
unsigned Nrows,
unsigned Ncols>
277 std::list< std::list<std::string> > Mlist;
279 size_t NROWS = Mlist.size();
281 NROWS = ( NROWS<Nrows ? NROWS : Nrows );
282 NCOLS = ( NCOLS<Ncols ? NCOLS : Ncols );
284 typename std::list< std::list<std::string> > :: const_iterator it;
285 typename std::list<std::string> :: const_iterator jt;
288 for (
size_t i=0; i<NROWS; ++i,++it ) {
290 for (
size_t j=0; j<NCOLS; ++j ) {
291 if ( jt==it->end() ) { MATRIX[i][j] = 0; }
293 MATRIX[i][j] = ATON_wrap::ATON( jt->c_str() );
308 template <
unsigned Nrows,
unsigned Ncols>
309 inline void intmatrix(
int M[Nrows][Ncols] ,
const char* str ) {
310 return matrix2list_wrap<int, str2list_int_wrap, Nrows, Ncols>( M , str );
320 template <
unsigned Nrows,
unsigned Ncols>
321 inline void longmatrix(
long M[Nrows][Ncols] ,
const char* str ) {
322 return matrix2list_wrap<long, str2list_long_wrap, Nrows, Ncols>( M , str );
332 template <
unsigned Nrows,
unsigned Ncols>
334 return matrix2list_wrap<double,str2list_double_wrap,Nrows,Ncols>( M,str );
349 template <
unsigned Nrows,
unsigned Ncols>
350 inline void charmatrix(
char M[Nrows][Ncols] ,
const char* str ) {
351 std::list< std::list<std::string> > Mstr;
353 memset( M,
' ',
sizeof(M) );
356 std::list< std::list<std::string> >::const_iterator it;
357 std::list<std::string>::const_iterator jt;
358 for ( i=0,it=Mstr.begin(); (i<Nrows && it!=Mstr.end()); ++i,++it ) {
359 const std::list<std::string>& Mrenglon = (*it);
360 for ( j=0,jt=Mrenglon.begin(); (j<Ncols && jt!=Mrenglon.end()); ++j,++jt ) {
361 if ( (*jt)[0] ==
'\'' ) {
362 if ( jt->size() == 1 ) {