llstreamtools.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_STREAM_TOOLS_H
00033 #define LL_STREAM_TOOLS_H
00034 
00035 #include <iostream>
00036 #include <string>
00037 
00038 // unless specifed otherwise these all return input_stream.good()
00039 
00040 // skips spaces and tabs
00041 bool skip_whitespace(std::istream& input_stream);
00042 
00043 // skips whitespace and newlines
00044 bool skip_emptyspace(std::istream& input_stream);
00045 
00046 // skips emptyspace and lines that start with a #
00047 bool skip_comments_and_emptyspace(std::istream& input_stream);
00048 
00049 // skips to character after next newline
00050 bool skip_line(std::istream& input_stream);
00051 
00052 // skips to beginning of next non-emptyspace
00053 bool skip_to_next_word(std::istream& input_stream);
00054 
00055 // skips to character after the end of next keyword 
00056 // a 'keyword' is defined as the first word on a line
00057 bool skip_to_end_of_next_keyword(const char* keyword, std::istream& input_stream);
00058 
00059 // skip_to_start_of_next_keyword() is disabled -- might tickle corruption bug 
00060 // in windows iostream
00061 // skips to beginning of next keyword
00062 // a 'keyword' is defined as the first word on a line
00063 //bool skip_to_start_of_next_keyword(const char* keyword, std::istream& input_stream);
00064 
00065 // characters are pulled out of input_stream and appended to output_string
00066 // returns result of input_stream.good() after characters are pulled
00067 bool get_word(std::string& output_string, std::istream& input_stream);
00068 bool get_line(std::string& output_string, std::istream& input_stream);
00069 
00070 // characters are pulled out of input_stream (up to a max of 'n')
00071 // and appended to output_string 
00072 // returns result of input_stream.good() after characters are pulled
00073 bool get_word(std::string& output_string, std::istream& input_stream, int n);
00074 bool get_line(std::string& output_string, std::istream& input_stream, int n);
00075 
00076 // unget_line() is disabled -- might tickle corruption bug in windows iostream
00078 //bool unget_line(const std::string& line, std::istream& input_stream);
00079 
00080 // TODO -- move these string manipulator functions to a different file
00081 
00082 // removes the last char in 'line' if it matches 'c'
00083 // returns true if removed last char
00084 bool remove_last_char(char c, std::string& line);
00085 
00086 // replaces escaped characters with the correct characters from left to right
00087 // "\\" ---> '\\' 
00088 // "\n" ---> '\n' 
00089 void unescape_string(std::string& line);
00090 
00091 // replaces unescaped characters with expanded equivalents from left to right
00092 // '\\' ---> "\\" 
00093 // '\n' ---> "\n" 
00094 void escape_string(std::string& line);
00095 
00096 // replaces each '\n' character with ' '
00097 void replace_newlines_with_whitespace(std::string& line);
00098 
00099 // erases any double-quote characters in line
00100 void remove_double_quotes(std::string& line);
00101 
00102 // the 'keyword' is defined as the first word on a line
00103 // the 'value' is everything after the keyword on the same line
00104 // starting at the first non-whitespace and ending right before the newline
00105 void get_keyword_and_value(std::string& keyword, 
00106                                                    std::string& value, 
00107                                                    const std::string& line);
00108 
00109 // continue to read from the stream until you really can't
00110 // read anymore or until we hit the count.  Some istream
00111 // implimentations have a max that they will read.
00112 // Returns the number of bytes read.
00113 std::streamsize fullread(
00114         std::istream& istr,
00115         char* buf,
00116         std::streamsize requested);
00117 
00118 
00119 std::istream& operator>>(std::istream& str, const char *tocheck);
00120 
00121 #endif
00122 
00123 

Generated on Fri May 16 08:32:08 2008 for SecondLife by  doxygen 1.5.5