|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// Configuratino Data //////////////////////////////////////////////////////// |
|
|
//// Configuratino Data //////////////////////////////////////////////////////// |
|
|
|
|
|
|
|
|
|
|
|
char* newCStringBuffer(size_t requestedSize) { |
|
|
|
|
|
const char NullTerminator = 0; |
|
|
|
|
|
size_t safeSize = requestedSize + 1; |
|
|
|
|
|
char* theBufferPointer = new char[safeSize]; |
|
|
|
|
|
theBufferPointer[requestedSize] = NullTerminator; |
|
|
|
|
|
return theBufferPointer; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ConfigurationData::ConfigurationData(const char* Data, int Length) : // Raw constructor from buffer. |
|
|
ConfigurationData::ConfigurationData(const char* Data, int Length) : // Raw constructor from buffer. |
|
|
myBufferSize(Length), // and it's length. |
|
|
myBufferSize(Length), // and it's length. |
|
|
myIndex(0), // Our Index is zero |
|
|
myIndex(0), // Our Index is zero |
|
|
myLine(1) { // We start on line 1 |
|
|
myLine(1) { // We start on line 1 |
|
|
myDataBuffer = new char[myBufferSize]; // Allocate a buffer. |
|
|
|
|
|
|
|
|
myDataBuffer = newCStringBuffer(myBufferSize); // Allocate a buffer. |
|
|
memcpy(myDataBuffer, Data, myBufferSize); // Copy the data. |
|
|
memcpy(myDataBuffer, Data, myBufferSize); // Copy the data. |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ifstream CFGFile(FileName); // Open the file. |
|
|
ifstream CFGFile(FileName); // Open the file. |
|
|
CFGFile.seekg(0,ios::end); // Seek to the end |
|
|
CFGFile.seekg(0,ios::end); // Seek to the end |
|
|
myBufferSize = CFGFile.tellg(); // to find out what size it is. |
|
|
myBufferSize = CFGFile.tellg(); // to find out what size it is. |
|
|
myDataBuffer = new char[myBufferSize]; // Make a new buffer the right size. |
|
|
|
|
|
|
|
|
myDataBuffer = newCStringBuffer(myBufferSize); // Make a new buffer the right size. |
|
|
CFGFile.seekg(0,ios::beg); // Seek to the beginning and |
|
|
CFGFile.seekg(0,ios::beg); // Seek to the beginning and |
|
|
CFGFile.read(myDataBuffer, myBufferSize); // read the file into the buffer. |
|
|
CFGFile.read(myDataBuffer, myBufferSize); // read the file into the buffer. |
|
|
if(CFGFile.bad()) { // If the read failed, we're unusable! |
|
|
if(CFGFile.bad()) { // If the read failed, we're unusable! |
|
|
|
|
|
|
|
|
ifstream CFGFile(FileName.c_str()); // Open the file. |
|
|
ifstream CFGFile(FileName.c_str()); // Open the file. |
|
|
CFGFile.seekg(0,ios::end); // Seek to the end |
|
|
CFGFile.seekg(0,ios::end); // Seek to the end |
|
|
myBufferSize = CFGFile.tellg(); // to find out what size it is. |
|
|
myBufferSize = CFGFile.tellg(); // to find out what size it is. |
|
|
myDataBuffer = new char[myBufferSize]; // Make a new buffer the right size. |
|
|
|
|
|
|
|
|
myDataBuffer = newCStringBuffer(myBufferSize); // Make a new buffer the right size. |
|
|
CFGFile.seekg(0,ios::beg); // Seek to the beginning and |
|
|
CFGFile.seekg(0,ios::beg); // Seek to the beginning and |
|
|
CFGFile.read(myDataBuffer, myBufferSize); // read the file into the buffer. |
|
|
CFGFile.read(myDataBuffer, myBufferSize); // read the file into the buffer. |
|
|
if(CFGFile.bad()) { // If the read failed, we're unusable! |
|
|
if(CFGFile.bad()) { // If the read failed, we're unusable! |