12 #include <iostream.hpp>
14 #include <sstream.hpp>
16 #include <strstream.h>
22 #include <strstream.h>
23 #define __USE_IOSTREAM__
47 unsigned int commas = 0;
49 const size_t n = strlen(s);
50 char* t =
new char[n + 1];
54 for (
size_t k = 0; k < n; k++)
76 if (lbraces == 1 && rbraces == 1)
78 unsigned int nch = commas + 1;
83 cerr <<
"Not enough elements to fill vector in "
84 "dvector::fill(const char * s)\n";
90 cerr <<
"Too many elements for size of vector in "
91 "dvector::fill(const char * s)\n";
100 size_t length = strlen(t);
107 if (index >= length)
break;
114 field[field_index] = c;
118 if (index >= length)
break;
122 field[field_index] =
'\0';
123 elem(i)=strtod(field,&err_ptr);
125 if (isalpha((
unsigned char)err_ptr[0]))
127 cerr <<
"Error decoding field "
128 <<
" in dvector::dvector(char * filename) " <<
"\n";
129 cerr <<
"Error occurred at element " << i <<
"\n";
130 cerr <<
"Offending characters start with "
135 if (
elem(i)== HUGE_VAL ||
elem(i)== -HUGE_VAL)
137 cerr <<
"Overflow Error decoding field "
138 " in dvector::dvector(char * ) " <<
"\n";
139 cerr <<
"Error occurred at element " << i <<
"\n";
140 cerr <<
"Offending characters start with "
153 if (lbraces != rbraces)
155 cerr <<
"Unbalanced braces in dvector::fill(const char * s)\n";
161 cerr <<
"Only one level of braces allowed in dvector::fill(const char* s)"
162 <<
'\n' << s <<
'\n';
167 cerr <<
"Missing braces { ... } in dvector::fill(const char * s)\n";
int indexmin() const
Get minimum valid index.
const int MAX_FIELD_LENGTH
prnstream & endl(prnstream &)
int indexmax() const
Get maximum valid index.
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
unsigned int size() const
Get number of elements in array.
void fill(const char *s)
Fill vectors from values in string s.
size_t length(const adstring &t)
Returns the size of adstr.