| 116 | typename tok |
| 117 | > |
| 118 | void cpp_pretty_printer_kernel_2<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_2::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>" |
| 133 | << "<title>" << title << "</title></head><body bgcolor='white'>" |
| 134 | << "<h1><center>" << title << "</center></h1><pre>\n" |
| 135 | << "<font style='font-size:9pt' face='Lucida Console'>\n"; |
| 136 | if (!out) |
| 137 | throw std::ios::failure("error occurred in cpp_pretty_printer_kernel_2::print"); |
| 138 | |
| 139 | unsigned long scope = 0; // counts the number of new scopes we have entered |
| 140 | // since we were at a scope where functions can be declared |
| 141 | |
| 142 | bool recently_seen_class_keyword = false; |
| 143 | // true if we have seen the keywords class or struct and |
| 144 | // we have not seen any identifiers or { characters |
| 145 | |
| 146 | bool recently_seen_include = false; |
| 147 | // true if we have seen the #include keyword and have not seen double |
| 148 | // quoted text or > |
| 149 | |
| 150 | bool recently_seen_new_scope = false; |
| 151 | // true if we have seen the keywords class, namespace, or struct and |
| 152 | // we have not seen the characters {, ), or ; since then |
| 153 | |
| 154 | bool recently_seen_paren = false; |
| 155 | // true if we have seen a ) and we have only seen white_space or comments since |
| 156 | |
| 157 | bool in_initialization_list = false; |
| 158 | // true if we have seen a ) followed by any white space or comments and then |
| 159 | // followed by a : (in scope==0 with recently_seen_preprocessor==false) and we |
| 160 | // have not yet seen the character { or ; |
| 161 | |
| 162 | bool recently_seen_preprocessor = false; |
| 163 | // true if we have seen the #pragma or #if or #define or #elif keyword and |
| 164 | // have not seen an identifier. |
| 165 | |
| 166 | |
| 167 | bool recently_seen_extern = false; |
| 168 | // true if we have seen the extern keyword and haven't yet seen a |
| 169 | // { or ; character. |
| 170 | |
| 171 | unsigned long paren_count = 0; |
| 172 | // this is the number of ( we have seen minus the number of ) we have |
| 173 | // seen. |
| 174 | |
| 175 | |