10 while(!in.fail()&& ( (c ==
' ')||(c ==
'\t')||(c ==
'\n')||(c ==
'\r') ) )
30 ossim_int32 idx = theCsvFile->indexOfField(fieldName);
31 if((idx > 0)&&(idx < (
ossim_int32)theValues.size()))
33 value = theValues[idx];
45 if(idx < theValues.size())
47 value = theValues[idx];
58 ossim_int32 idx = theCsvFile->indexOfField(fieldName);
59 if((idx >= 0)&&(idx < (
ossim_int32)theValues.size()))
61 return theValues[idx];
72 ossim_int32 idx = theCsvFile->indexOfField(fieldName);
73 if((idx >= 0)&&(idx < (
ossim_int32)theValues.size()))
75 return theValues[idx];
84 if(idx < theValues.size())
86 return theValues[idx];
94 if(idx < theValues.size())
96 return theValues[idx];
120 const char quote =
'\"';
121 bool inQuotedString =
false;
122 bool inDoubleQuote =
false;
124 inStream >> csvSkipWhiteSpace;
125 while(!done&&inStream.get(c)&&inStream.good())
138 if(inStream.peek() == quote)
140 currentToken += quote;
144 inDoubleQuote =
true;
148 inDoubleQuote =
false;
155 inQuotedString =
true;
159 inQuotedString =
false;
167 if(inQuotedString||inDoubleQuote)
174 currentToken = currentToken.
trim();
177 inStream >> csvSkipWhiteSpace;
185 else if(!inQuotedString||inDoubleQuote)
187 currentToken = currentToken.
trim();
197 return (inStream.good()&&(tokens.size()>0));
204 if((*flags.
begin()) ==
'r')
ossimRefPtr< ossimCsvFile::Record > nextRecord()
Read one record and returns null if no more records exist or returns a valid pointer if a record exis...
ossimRefPtr< ossimCsvFile::Record > theRecordBuffer
StringListType & values()
bool open(const ossimFilename &file, const ossimString &flags="r")
For now we will only support the read flag and open existing csv files.
StringListType theFieldHeaderList
std::basic_ifstream< char > ifstream
Class for char input file streams.
std::istream * theInputStream
static ossim_int32 INVALID_INDEX
bool contains(char aChar) const
void push_back(char c)
Equivalent to insert(end(), c).
bool readCsvLine(std::istream &inStream, ossimCsvFile::StringListType &tokens) const
ossimString & operator[](const ossimString &fieldName)
Allows one to access and write to the field.
std::string::iterator begin()
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
ossim_int32 indexOfField(const ossimString &fieldName) const
Record(ossimCsvFile *csvFile)
ossimString theSeparatorList
std::basic_istream< char > istream
Base class for char input streams.
ossimCsvFile(const ossimString &separatorList=",")
const StringListType & fieldHeaderList() const
Returns the header of the CSV file.
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
bool valueAt(const ossimString &fieldName, ossimString &value) const
Allows access to a field as read only.
std::vector< ossimString > StringListType