| 116 | typename tok |
| 117 | > |
| 118 | void cpp_pretty_printer_kernel_1<stack,tok>:: |
| 119 | print ( |
| 120 | std::istream& in, |
| 121 | std::ostream& out, |
| 122 | const std::string& title |
| 123 | ) const |
| 124 | { |
| 125 | if (!out) |
| 126 | throw std::ios::failure("error occurred in cpp_pretty_printer_kernel_1::print"); |
| 127 | |
| 128 | t.set_stream(in); |
| 129 | |
| 130 | out << "<html><!-- " |
| 131 | << "Created using the cpp_pretty_printer from the dlib C++ library. See http://dlib.net for updates." |
| 132 | << " --><head><title>" << title << "</title></head><body bgcolor='white'><pre>\n"; |
| 133 | if (!out) |
| 134 | throw std::ios::failure("error occurred in cpp_pretty_printer_kernel_1::print"); |
| 135 | |
| 136 | unsigned long scope = 0; // counts the number of new scopes we have entered |
| 137 | // since we were at a scope where functions can be declared |
| 138 | |
| 139 | bool recently_seen_class_keyword = false; |
| 140 | // true if we have seen the keywords class, struct, or enum and |
| 141 | // we have not seen any identifiers or { characters |
| 142 | |
| 143 | bool recently_seen_include = false; |
| 144 | // true if we have seen the #include keyword and have not seen double |
| 145 | // quoted text or > |
| 146 | |
| 147 | bool recently_seen_new_scope = false; |
| 148 | // true if we have seen the keywords class, namespace, or struct and |
| 149 | // we have not seen the characters {, ), or ; since then |
| 150 | |
| 151 | bool recently_seen_paren = false; |
| 152 | // true if we have seen a ) and we have only seen white_space or comments since |
| 153 | |
| 154 | bool in_initialization_list = false; |
| 155 | // true if we have seen a ) followed by any white space or comments and then |
| 156 | // followed by a : (in scope==0 with recently_seen_preprocessor==false) and we |
| 157 | // have not yet seen the character { or ; |
| 158 | |
| 159 | bool recently_seen_preprocessor = false; |
| 160 | // true if we have seen the #pragma or #if or #define or #elif keywords and have |
| 161 | // not seen an end of line. |
| 162 | |
| 163 | bool recently_seen_extern = false; |
| 164 | // true if we have seen the extern keyword and haven't seen a ; or { yet. |
| 165 | |
| 166 | unsigned long paren_count = 0; |
| 167 | // this is the number of ( we have seen minus the number of ) we have |
| 168 | // seen. |
| 169 | |
| 170 | |
| 171 | int type; |
| 172 | stack scopes; // a stack to hold old scopes |
| 173 | std::string token, temp; |
| 174 | t.get_token(type,token); |
| 175 | while (type != tok::END_OF_FILE) |