Octane v1.01.20 - The Open Compression Toolkit for C++ | http://octane.sourceforge.net/ |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 //--------------------------------------------------------------------------- 00011 00012 //--------------------------------------------------------------------------- 00013 // application includes 00014 #include "octaneclass.hpp" 00015 //--------------------------------------------------------------------------- 00016 00017 using namespace std; 00018 00019 //--------------------------------------------------------------------------- 00020 bool OctaneClass::ParseParameter(const string ¶metervalue, bool ¶m) 00021 { 00022 // convert and store a bool parameter value 00023 // ATTN: this is case sensitive and should be changed to case-insensitive 00024 if (parametervalue == "true") 00025 param = true; 00026 else if (parametervalue == "false") 00027 param = false; 00028 else if (atoi(parametervalue.c_str()) == 0) 00029 param = false; 00030 else if (atoi(parametervalue.c_str()) == 1) 00031 param = true; 00032 else 00033 return false; 00034 return true; 00035 } 00036 //--------------------------------------------------------------------------- 00037 00038 00039 00040 //--------------------------------------------------------------------------- 00041 void OctaneClass::NiceifyHighAsciiString(std::string &str) 00042 { 00043 // walk through string and replace characters that print out weird (line newlines, tabs, backspaces) 00044 // with a single character. 00045 // ATTN: i would prefer to change this so that it outputs a non-lossy string using standard \0x01 type codes 00046 // and write a helper function to convert from these to binary form, that way we could use this as an alternate 00047 // text+human friendly data saving format. 00048 int count,length; 00049 unsigned char c; 00050 length=(int)(str.length()); 00051 00052 for (count=0;count<length;++count) 00053 { 00054 c=str[count]; 00055 if (c<32) 00056 str[count]=1; 00057 } 00058 } 00059 00060 00061 std::string OctaneClass::PrefixNonEmptyString(const std::string headerstr, const std::string str) 00062 { 00063 // prefix a non empty string with a header 00064 if (str!="") 00065 return headerstr+str; 00066 else 00067 return str; 00068 } 00069 //--------------------------------------------------------------------------- 00070