ZVISION: Add documentation to utility functions and add a glorified trim function

This commit is contained in:
richiesams
2013-08-04 13:31:45 -05:00
parent 2ada5a8dd7
commit 8243263b33
+25 -1
View File
@@ -29,7 +29,14 @@
namespace ZVision {
void WriteFileContentsToFile(Common::String sourceFile, Common::String destFile) {
/**
* Opens the sourceFile utilizing Common::File (aka SearchMan) and writes the
* contents to destFile. destFile is created in the working directory
*
* @param sourceFile The 'file' you want the contents of
* @param destFile The name of the file where the content will be written to
*/
void writeFileContentsToFile(Common::String sourceFile, Common::String destFile) {
Common::File f;
f.open(sourceFile);
byte* buffer = new byte[f.size()];
@@ -45,6 +52,23 @@ void WriteFileContentsToFile(Common::String sourceFile, Common::String destFile)
delete[] buffer;
}
/**
* Removes any line comments using '#' as a sequence start.
* Then removes any trailing and leading 'whitespace'.
* Uses isspace() to determine what is whitespace and what is not.
*
* @param string The string to modify. It is modified in place
*/
void trimCommentsAndWhiteSpace(Common::String &string) {
for (int i = string.size(); i >= 0; --i) {
if (string[i] == '#') {
string.erase(i);
}
}
string.trim();
}
} // End namespace ZVision
#endif