/usr/include/ossim/base/ossimCsvFile.h is in libossim-dev 1.8.16-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | #ifndef ossimCsvFile_HEADER
#define ossimCsvFile_HEADER
#include <ossim/base/ossimReferenced.h>
#include <ossim/base/ossimRefPtr.h>
#include <ossim/base/ossimConstants.h>
#include <ossim/base/ossimFilename.h>
#include <ossim/base/ossimString.h>
#include <map>
#include <vector>
#include <fstream>
class OSSIM_DLL ossimCsvFile : public ossimReferenced
{
public:
typedef std::vector<ossimString> StringListType;
class OSSIM_DLL Record : public ossimReferenced
{
public:
typedef std::map<ossimString, ossimString, ossimStringLtstr> FieldMapType;
typedef std::vector<ossimString> FieldValueListType;
Record(ossimCsvFile* csvFile);
void setCsvFile(ossimCsvFile* file)
{
theCsvFile = file;
}
ossimCsvFile* csvFile()
{
return theCsvFile;
}
const ossimCsvFile* csvFile()const
{
return theCsvFile;
}
StringListType& values()
{
return theValues;
}
const StringListType& values()const
{
return theValues;
}
/**
* Allows access to a field as read only.
*/
bool valueAt(const ossimString& fieldName,
ossimString& value)const;
bool valueAt(ossim_uint32 idx,
ossimString& value)const;
/**
* Allows one to access and write to the field.
*/
ossimString& operator [](const ossimString& fieldName);
const ossimString& operator [](const ossimString& fieldName)const;
ossimString& operator [](ossim_uint32 idx);
const ossimString& operator [](ossim_uint32 idx)const;
protected:
// used in out of bounds returns on the operators []
//
ossimString theDummyValue;
StringListType theValues;
ossimCsvFile* theCsvFile;
};
friend class Record;
ossimCsvFile(const ossimString& separatorList=",");
~ossimCsvFile();
/**
* For now we will only support the read flag and open existing
* csv files. Later we can add support for creating and writing csv files
*
*/
bool open(const ossimFilename& file, const ossimString& flags="r");
void close();
bool readHeader();
/**
* Read one record and returns null if no more records exist or returns a valid pointer
* if a record exists.
*/
ossimRefPtr<ossimCsvFile::Record> nextRecord();
/**
* Returns the header of the CSV file.
*/
const StringListType& fieldHeaderList()const;
ossim_int32 indexOfField(const ossimString& fieldName)const;
static ossim_int32 INVALID_INDEX;
protected:
bool readCsvLine(std::istream& inStream,
ossimCsvFile::StringListType& tokens)const;
StringListType theFieldHeaderList;
ossimRefPtr<ossimCsvFile::Record> theRecordBuffer;
std::istream* theInputStream;
ossimString theSeparatorList;
bool theOpenFlag;
};
#endif
|