aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichiesams2013-06-24 00:46:27 -0500
committerrichiesams2013-08-04 13:31:45 -0500
commit8243263b33fe7aaf4e1144104f1189cd03636ff0 (patch)
treee3c0e5abbf12b6184f357a47f7b637dd2db458f8
parent2ada5a8dd7d953d35ddb8ad56a6827cc95daa1cb (diff)
downloadscummvm-rg350-8243263b33fe7aaf4e1144104f1189cd03636ff0.tar.gz
scummvm-rg350-8243263b33fe7aaf4e1144104f1189cd03636ff0.tar.bz2
scummvm-rg350-8243263b33fe7aaf4e1144104f1189cd03636ff0.zip
ZVISION: Add documentation to utility functions and add a glorified trim function
-rw-r--r--engines/zvision/utility.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 15f9490a4b..0777ba9ebc 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -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