14 #include <iostream.hpp>
16 #include <sstream.hpp>
18 #include <strstream.h>
22 #if defined(__TURBOC__)
29 #include <strstream.h>
30 #define __USE_IOSTREAM__
54 const size_t len = strlen(s);
56 assert(len <= INT_MAX);
58 char *t =
new char[len];
59 const int n =
static_cast<int>(len);
62 unsigned int commas = 0;
64 for (
int k = 0; k < n; k++)
87 if (lbraces == 1 && rbraces == 1)
89 unsigned int nch = commas + 1;
95 cerr <<
"Not enough elements to fill vector in "
96 "dvar_vector::fill(const char * s)\n";
102 cerr <<
"Too many elements for size of vector in "
103 "dvar_vector::fill(const char * s)\n";
110 char* err_ptr = NULL;
113 size_t length = strlen(t);
120 if (index >= length)
break;
127 field[field_index] = c;
131 if (index >= length)
break;
135 field[field_index] =
'\0';
136 elem(i)=strtod(field,&err_ptr);
138 if (isalpha((
unsigned char)err_ptr[0]))
140 cerr <<
"Error decoding field "
141 <<
" in dmatrix::dmatrix(char * filename) " <<
"\n";
142 cerr <<
"Error occurred at element " << i <<
"\n";
143 cerr <<
"Offending characters start with "
147 << err_ptr[3] <<
"\n";
150 if (
elem(i) == HUGE_VAL ||
elem(i) == -HUGE_VAL)
152 cerr <<
"Overflow Error decoding field "
153 " in dmatrix::dmatrix(char * ) " <<
"\n";
154 cerr <<
"Error occurred at element " << i <<
"\n";
166 if (lbraces != rbraces)
168 cerr <<
"Unbalanced braces in dvar_vector::fill(const char * s)\n";
174 cerr <<
"Only one level of braces allowed in "
175 "dvar_vector::fill(const char * s)\n";
181 cerr <<
"Missing braces { ... } in dvar_vector::fill(const char * s)\n";
void fill(const char *)
Fill variable vector from values in string s.
const int MAX_FIELD_LENGTH
unsigned int size() const
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
size_t length(const adstring &t)
Returns the size of adstr.