Debian Codegraph @

Utilities/ReferenceDocs/main.cpp

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1
2 #include "main.h"
3 #include <iostream>
4 #include <fstream>
5
6 /////////////////////////////////////////////////////////////////////////////
7 // RefClass
8
9 void RefClass::setGroupName(const std::string &group_string)
10 {
11 int i1 = group_string.find('/');
12 if (i1 < 0)
13 {
14 if (group_string.size() > 0)
15 {
16 // just no subgroup
17 i1 = group_string.size();
18 }
19 else
20 {
21 groupString = "Incorrect/no Group";
22 subGroupName = "no Group";
23 groupName = "Incorrect";
24 return;
25 }
26 }
27 groupName = group_string.substr(0,i1);
28 printf("dba3 information %d %d",i1, group_string.size());
29 if (i1+1 >= group_string.size()) { subGroupName=""; }
30 else { subGroupName = group_string.substr(i1+1,group_string.size()-i1); }
31 groupString = group_string;
32 }
33
34 RefClass::RefClass(const std::string &class_name,const std::string &group_string)
35 {
36 className = class_name;
37 setGroupName(group_string);
38 }
39
40 RefClass::~RefClass()
41 {
42 }
43
44 bool groupsort(RefClass &u1,RefClass &u2)
45 {
46 return (u1.groupString.compare(u2.groupString) < 0);
47 }
48
49 bool indexsort(RefClass &u1,RefClass &u2)
50 {
51 return (u1.className.compare(u2.className) < 0);
52 }
53
54 /////////////////////////////////////////////////////////////////////////////
55 // ReferenceDocs startup:
56
57 ReferenceDocs app;
58
59 int ReferenceDocs::main(int argc, char **argv)
60 {
61 CL_SetupCore::init();
62 slots.connect(CL_Log::sig_log(), this, &ReferenceDocs::on_log_message);
63
64 try
65 {
66 CL_DirectoryScanner scanner;
67 bool result = scanner.scan("../../Documentation/Reference/doxyoutput/xml", "*.xml");
68 if (!result)
69 {
70 CL_Log::log("parser", "Unable to find xml doc input!");
71 return 255;
72 }
73
74 while (scanner.next())
75 {
76 std::string filename = scanner.get_pathname();
77 CL_Log::log("spam", "Parsing %1", filename);
78
79 CL_DomDocument doc(new CL_InputSource_File(filename), true);
80 CL_DomElement doc_element = doc.get_document_element();
81 if (doc_element.get_tag_name() != "doxygen")
82 {
83 CL_Log::log("error", "Not a doxygen doxygen document: %1 (%2)", filename, doc_element.get_tag_name());
84 continue;
85 }
86
87 CL_DomNode cur_node = doc_element.get_first_child();
88 while (!cur_node.is_null())
89 {
90 if (cur_node.is_element())
91 {
92 CL_DomElement cur_element = cur_node.to_element();
93 if (cur_element.get_tag_name() == "compounddef")
94 {
95 parse_compounddef(cur_element);
96 }
97 }
98
99 cur_node = cur_node.get_next_sibling();
100 }
101
102 }
103 parse_groupedclasses();
104 parse_allclasses();
105 parse_indexedclasses();
106 }
107 catch (CL_Error err)
108 {
109 CL_Log::log("ClanLib ReferenceDocs Fatal Error: %1", err.message.c_str());
110 }
111
112 CL_SetupCore::deinit();
113
114 return 0;
115 }
116
117 void ReferenceDocs::parse_compounddef(CL_DomElement compounddef)
118 {
119 if (compounddef.get_tag_name() != "compounddef")
120 {
121 CL_Log::log("debug", "Tag name is wrong. Expected 'compounddef' but got '%1'", compounddef.get_tag_name());
122 return;
123 }
124
125 // Right now, we only deal with classes.
126 if (compounddef.get_attribute("kind") != "class")
127 {
128 CL_Log::log("spam", "Wrong compound kind. Expected 'class' but got '%1", compounddef.get_attribute("kind"));
129 return;
130 }
131
132 std::string class_name = "unknown";
133 std::vector<std::string> base_classes, derived_classes, sections;
134 std::string brief, detail, clan_group, clan_section, clan_header;
135 bool ishide = false;
136
137 CL_DomNode cur_node;
138 for (cur_node = compounddef.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
139 {
140 CL_DomElement cur_element = cur_node.to_element();
141 if (cur_element.is_null()) continue;
142
143 std::string tag_name = cur_element.get_tag_name();
144
145 if (tag_name == "compoundname")
146 {
147 class_name = cur_element.get_text();
148 }
149 else if (tag_name == "basecompoundref")
150 {
151 std::string flags;
152 if (cur_element.has_attribute("prot")) flags += cur_element.get_attribute("prot")+" ";
153 if (cur_element.get_attribute("virt") == "virtual") flags += "virtual ";
154 std::string str = CL_String::format("%1<a href=\"%2.html\" class=\"reflink\">%3</a>", flags, cur_element.get_text(), cur_element.get_text());
155 base_classes.push_back(str);
156 }
157 else if (tag_name == "derivedcompoundref")
158 {
159 std::string str = CL_String::format("<a href=\"%1.html\" class=\"reflink\">%2</a>", cur_element.get_text(), cur_element.get_text());
160 derived_classes.push_back(str);
161 }
162 else if (tag_name == "sectiondef" && cur_element.get_attribute("kind") == "user-defined")
163 {
164 std::string section = parse_sectiondef(class_name, cur_element);
165 sections.push_back(section);
166 }
167 else if (tag_name == "briefdescription")
168 {
169 brief = get_formatted(cur_element);
170 }
171 else if (tag_name == "detaileddescription")
172 {
173 detail = get_formatted(cur_element);
174 // extracting the ClanGroup information
175 int m1 = detail.find("!hide!");
176 if (m1 >= 0)
177 {
178 ishide = true; int m2 = m1+6;
179 detail = std::string() + detail.substr(0,m1) + detail.substr(m2,detail.size()-m2);
180 }
181 int i1 = detail.find("!group=");
182 int i3 = i1 + 7;
183 int i2 = detail.find('!',i1+1);
184 if (i1+2 >= i2 || i1 < 0)
185 {
186 if (!ishide) { CL_Log::log("spam", "No Groupinformation at '%1", class_name); }
187 }
188 else
189 {
190 clan_group = detail.substr(i3,i2-i3);
191 std::string s1 = detail.substr(0,i1);
192 std::string s2 = detail.substr(i2+1,detail.size()-i2);
193 detail = std::string() + detail.substr(0,i1) + detail.substr(i2+1,detail.size()-i2);
194 printf("DETAIL %d %d \"%s\" \"%s\" \"%s\"",i1,i2,detail.c_str(),s1.c_str(),s2.c_str());
195 }
196 }
197 }
198
199 // sometimes you have to hack to make something look nice
200 RefClass refcl = RefClass(class_name,clan_group);
201 clan_group = refcl.groupName;
202 clan_section = refcl.subGroupName;
203
204 std::ofstream class_file(CL_String::format("/home/mbn/public_html/temp/reftest/%1.html", class_name).c_str(), std::ofstream::out);
205 class_file << "<!-- clanlib header begin -->" << std::endl;
206 class_file << "<HTML>" << std::endl;
207 class_file << "<HEAD>" << std::endl;
208 class_file << "<TITLE>" << class_name.c_str() << " - ClanLib Game SDK</TITLE>" << std::endl;
209 class_file << "<STYLE TYPE=\"text/css\"><!--" << std::endl;
210 class_file << "HTML BODY" << std::endl;
211 class_file << "{" << std::endl;
212 class_file << " font-family: verdana, helvetica, sans-serif;" << std::endl;
213 class_file << " font-size: 12px;" << std::endl;
214 class_file << "}" << std::endl;
215 class_file << "H1 { font-size: 22px; }" << std::endl;
216 class_file << "H2 { font-size: 18px; }" << std::endl;
217 class_file << "H3 { font-size: 16px; }" << std::endl;
218 class_file << "H4 { font-size: 14px; }" << std::endl;
219 class_file << "P { font-size: 12px; }" << std::endl;
220 class_file << "LI { font-size: 12px; }" << std::endl;
221 class_file << ".reflink:link { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
222 class_file << ".reflink:visited { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
223 class_file << ".reflink:active { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
224 class_file << ".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }" << std::endl;
225 class_file << "--></STYLE>" << std::endl;
226 class_file << "</HEAD>" << std::endl;
227 class_file << "<body bgcolor=white text=black link=blue vlink=#800080>" << std::endl;
228 class_file << "<center>" << std::endl;
229 class_file << "<img src=\"http://clanlib.org/gfx/clanlib.png\">" << std::endl;
230 class_file << "</center>" << std::endl;
231 class_file << "<!-- clanlib header end -->" << std::endl;
232 class_file << "<center>" << std::endl;
233 class_file << "<p>" << std::endl;
234 class_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
235 class_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
236 class_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
237 class_file << "<a href=\"index.html\">Index</a> |" << std::endl;
238 class_file << "<a href=\"search.html\">Search</a>" << std::endl;
239 class_file << "</p>" << std::endl;
240 class_file << "</center>" << std::endl;
241
242 class_file << "<h1>Class " << class_name.c_str() << "</h1>" << std::endl;
243 class_file << "<p>" << brief.c_str();
244 if (!detail.empty()) class_file << " <a href=\"#description\">More...</a>";
245 class_file << "</p>" << std::endl;
246 class_file << "<table>" << std::endl;
247 class_file << "<tr><td valign=top nowrap><p>Derived from:</p></td><td valign=top><p>" << std::endl;
248 if (!base_classes.empty())
249 {
250 for (int i=0; i<base_classes.size()-1; i++)
251 class_file << base_classes[i].c_str() << ", ";
252
253 class_file << base_classes[base_classes.size()-1].c_str();
254 }
255 else
256 {
257 class_file << "<i>None</i>";
258 }
259 class_file << "</p></td></tr>" << std::endl;
260 class_file << "<tr><td valign=top><p>Derived by:</p></td><td valign=top><p>" << std::endl;
261 if (!derived_classes.empty())
262 {
263 for (int i=0; i<derived_classes.size()-1; i++)
264 class_file << derived_classes[i].c_str() << ", ";
265
266 class_file << derived_classes[derived_classes.size()-1].c_str();
267 }
268 else
269 {
270 class_file << "<i>None</i>";
271 }
272 class_file << "</p></td></tr>" << std::endl;
273 class_file << "<tr><td><p>Group:</p></td><td><p>" << clan_group.c_str() << " (" << clan_section.c_str() << ")</p></td></tr>" << std::endl;
274 class_file << "</table>" << std::endl;
275 class_file << "<p>#include &lt;ClanLib/" << clan_header.c_str() << "&gt;</p>" << std::endl;
276
277 for (int section_index = 0; section_index < sections.size(); section_index++)
278 {
279 class_file << sections[section_index] << std::endl;
280 }
281
282 if (!detail.empty())
283 {
284 class_file << "<a name=\"#description\"><p><b>Detailed description:</b></p></a>" << std::endl;
285 class_file << detail.c_str() << std::endl;
286 }
287
288
289 // now we need to get the function etc. data
290 refcl.sections.swap(sections);
291 // adding the class to the reference list
292 if (!ishide)
293 {
294 rlist.push_back(refcl);
295 }
296
297 class_file << "<!-- clanlib footer begin -->" << std::endl;
298 class_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
299 class_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
300 class_file << "</font></center>" << std::endl;
301 class_file << "<!-- clanlib footer end -->" << std::endl;
302 class_file << "</body>" << std::endl;
303 class_file << "</html>" << std::endl;
304 }
305
306 std::string ReferenceDocs::parse_sectiondef(const std::string &class_name, CL_DomElement sectiondef)
307 {
308 std::string text;
309
310 std::string section_name;
311 std::vector<std::string> members;
312
313 std::map<std::string, int> member_map;
314
315 CL_DomNode cur_node;
316 for (cur_node = sectiondef.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
317 {
318 CL_DomElement cur_element = cur_node.to_element();
319 if (cur_element.is_null()) continue;
320
321 std::string tag_name = cur_element.get_tag_name();
322
323 if (tag_name == "header")
324 {
325 section_name = cur_element.get_text();
326 if (section_name == "Implementation")
327 {
328 // skip implementation group.
329 return std::string();
330 }
331 }
332 else if (tag_name == "memberdef")
333 {
334 std::string member = parse_memberdef(class_name, section_name, member_map, cur_element);
335 if (!member.empty()) members.push_back(member);
336 }
337 }
338
339 text += CL_String::format("<p><b>%1:</b></p>", section_name);
340 text += "<table border=0 width=100%>";
341 for (int i=0; i<members.size(); i++)
342 {
343 text += members[i];
344 }
345 text += "</table>";
346
347 return text;
348 }
349
350 std::string ReferenceDocs::parse_memberdef(const std::string &class_name, const std::string &section_name, std::map<std::string, int> &member_map, CL_DomElement memberdef)
351 {
352 std::string text;
353
354 std::string kind = memberdef.get_attribute("kind");
355 bool member_static = (memberdef.get_attribute("static") == "yes");
356 bool member_const = (memberdef.get_attribute("const") == "yes");
357 bool member_explicit = (memberdef.get_attribute("explicit") == "yes");
358 bool member_inline = (memberdef.get_attribute("inline") == "yes");
359 bool member_virtual = (memberdef.get_attribute("virtual") == "virtual");
360 std::string prot = memberdef.get_attribute("prot", "public");
361
362 if (prot == "private") return text;
363
364 std::string type, name, definition, argsstring, brief, detail;
365 std::string params_description;
366 std::vector<std::string> params;
367
368 CL_DomNode cur_node;
369 for (cur_node = memberdef.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
370 {
371 CL_DomElement cur_element = cur_node.to_element();
372 if (cur_element.is_null()) continue;
373
374 std::string tag_name = cur_element.get_tag_name();
375
376 if (tag_name == "type")
377 {
378 type = cur_element.get_text();
379 }
380 else if (tag_name == "definition")
381 {
382 definition = cur_element.get_text();
383 }
384 else if (tag_name == "argsstring")
385 {
386 argsstring = cur_element.get_text();
387 }
388 else if (tag_name == "name")
389 {
390 name = cur_element.get_text();
391
392 // Skip destructors.
393 if (!name.empty() && name[0] == '~') return std::string();
394 }
395 else if (tag_name == "param")
396 {
397 std::string param_type = get_formatted(cur_element.named_item("type").to_element());
398 std::string param_name = cur_element.named_item("declname").to_element().get_text();
399 std::string param_defval = cur_element.named_item("defval").to_element().get_text();
400
401 std::string param_text = param_type + " " + param_name;
402 if (!param_defval.empty()) param_text += std::string(" = ") + param_defval;
403 params.push_back(param_text);
404 }
405 else if (tag_name == "briefdescription")
406 {
407 brief = get_formatted(cur_element);
408 }
409 else if (tag_name == "detaileddescription")
410 {
411 detail = get_formatted(cur_element);
412 params_description = get_params_list(cur_element);
413 }
414 else if (tag_name == "location")
415 {
416 }
417 }
418
419 // Group functions:
420 std::map<std::string, int>::iterator it = member_map.find(name);
421 if (it != member_map.end())
422 {
423 if (brief.empty()) return std::string();
424 it->second++;
425 }
426 else
427 {
428 member_map[name] = 0;
429 }
430
431 // Generate output:
432 std::string filename = CL_String::format("%1_func%2_%3.html", class_name, CL_String::from_int(member_map[name]), name);
433 std::string hint;
434 if (member_static) hint += " static";
435 if (member_const) hint += " const";
436 if (member_explicit) hint += " explicit";
437 if (member_inline) hint += " inline";
438 if (member_virtual) hint += " virtual";
439 if (prot == "protected") hint += " protected";
440
441 text += CL_String::format(
442 "<tr>"
443 "<td width=30% valign=top><p><a href=\"%1\">%2</a><i>%3</i></p></td>"
444 "<td valign=top><p>%4</p></td>"
445 "</tr>",
446 filename,
447 name,
448 hint,
449 brief);
450
451
452 std::ofstream function_file(CL_String::format("/home/mbn/public_html/temp/reftest/%1", filename).c_str(), std::ofstream::out);
453 function_file << "<!-- clanlib header begin -->" << std::endl;
454 function_file << "<HTML>" << std::endl;
455 function_file << "<HEAD>" << std::endl;
456 function_file << "<TITLE>" << name.c_str() << " - ClanLib Game SDK</TITLE>" << std::endl;
457 function_file << "<STYLE TYPE=\"text/css\"><!--" << std::endl;
458 function_file << "HTML BODY" << std::endl;
459 function_file << "{" << std::endl;
460 function_file << " font-family: verdana, helvetica, sans-serif;" << std::endl;
461 function_file << " font-size: 12px;" << std::endl;
462 function_file << "}" << std::endl;
463 function_file << "H1 { font-size: 22px; }" << std::endl;
464 function_file << "H2 { font-size: 18px; }" << std::endl;
465 function_file << "H3 { font-size: 16px; }" << std::endl;
466 function_file << "H4 { font-size: 14px; }" << std::endl;
467 function_file << "P { font-size: 12px; }" << std::endl;
468 function_file << "LI { font-size: 12px; }" << std::endl;
469 function_file << ".reflink:link { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
470 function_file << ".reflink:visited { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
471 function_file << ".reflink:active { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
472 function_file << ".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }" << std::endl;
473 function_file << "--></STYLE>" << std::endl;
474 function_file << "</HEAD>" << std::endl;
475 function_file << "<body bgcolor=white text=black link=blue vlink=#800080>" << std::endl;
476 function_file << "<center>" << std::endl;
477 function_file << "<img src=\"http://clanlib.org/gfx/clanlib.png\">" << std::endl;
478 function_file << "</center>" << std::endl;
479 function_file << "<!-- clanlib header end -->" << std::endl;
480 function_file << "<center>" << std::endl;
481 function_file << "<p>" << std::endl;
482 function_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
483 function_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
484 function_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
485 function_file << "<a href=\"index.html\">Index</a> |" << std::endl;
486 function_file << "<a href=\"search.html\">Search</a>" << std::endl;
487 function_file << "</p>" << std::endl;
488 function_file << "</center>" << std::endl;
489
490 function_file << "<h1>Function " << name.c_str() << "</h1>" << std::endl;
491 function_file << "<p>" << brief.c_str() << "</p>" << std::endl;
492 function_file << "<pre>" << std::endl;
493 function_file << "\t" << definition.c_str() << "("; // << argsstring.c_str() << std::endl;
494 for (int index_params = 0; index_params < params.size(); index_params++)
495 {
496 if (index_params > 0) function_file << ",";
497 function_file << std::endl << "\t\t" << params[index_params];
498 }
499 function_file << ");" << std::endl;
500 function_file << "</pre>" << std::endl;
501
502 if (!params_description.empty())
503 {
504 function_file << "<p><b>Parameters:</b></p>" << std::endl;
505 function_file << params_description.c_str() << std::endl;
506 }
507 /*
508 print FILE "<p><b>Return value:</b></p>\n";
509 print FILE "<p>";
510 print_description(&addCrossRef($funcretval{$filename}));
511 print FILE "</p>\n";
512 */
513
514 if (!detail.empty())
515 {
516 function_file << "<p><b>Detailed description:</b></p>" << std::endl;
517 function_file << "<p>" << detail.c_str() << "</p>" << std::endl;
518 }
519
520 function_file << "<p><b>See also:</b></p>" << std::endl;
521 function_file << "<p><a href=\"" << class_name << ".html\">" << class_name << "</a></p>" << std::endl;
522 /*
523 print FILE "<p><b>See also:</b></p>\n";
524 $see_also{$classname} = "<a href=\"$classfilename.html\">$classname</a>";
525
526 my $str;
527 my $cur_also;
528 foreach $cur_also (keys %see_also)
529 {
530 $str .= " | " if ($str ne "");
531 $str .= $see_also{$cur_also};
532 }
533
534 print FILE "<p>$str</p>\n";
535 */
536
537 function_file << "<!-- clanlib footer begin -->" << std::endl;
538 function_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
539 function_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
540 function_file << "</font></center>" << std::endl;
541 function_file << "<!-- clanlib footer end -->" << std::endl;
542 function_file << "</body>" << std::endl;
543 function_file << "</html>" << std::endl;
544
545 return text;
546 }
547
548 std::string ReferenceDocs::get_params_list(const CL_DomElement &element)
549 {
550 std::string text;
551
552 CL_DomNode cur_node;
553 for (cur_node = element.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
554 {
555 if (!cur_node.is_element()) continue;
556
557 CL_DomElement cur_element = cur_node.to_element();
558 if (cur_element.get_tag_name() == "parameterlist")
559 {
560 std::string kind = cur_element.get_attribute("kind");
561 if (kind != "param") continue;
562
563 text += "<dl>";
564
565 std::string param_name, param_description;
566 CL_DomNode param_node;
567 for (param_node = cur_element.get_first_child(); !param_node.is_null(); param_node = param_node.get_next_sibling())
568 {
569 if (!param_node.is_element()) continue;
570 CL_DomElement param_element = param_node.to_element();
571
572 if (param_element.get_tag_name() == "parametername")
573 {
574 param_name = param_element.get_text();
575 }
576 else if (param_element.get_tag_name() == "parameterdescription")
577 {
578 param_description = get_formatted(param_element);
579 text += CL_String::format("<dt><i>%1</i></dt><dd>%2</dd>", param_name, param_description);
580 }
581 }
582
583 text += "</dl>";
584 }
585 else
586 {
587 text += get_params_list(cur_element);
588 }
589 }
590
591 return text;
592 }
593
594 std::string ReferenceDocs::get_formatted(const CL_DomElement &element)
595 {
596 std::string text;
597
598 CL_DomNode cur_node;
599 for (cur_node = element.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
600 {
601 if (cur_node.is_text())
602 {
603 CL_DomText cur_text = cur_node.to_text();
604 text += cur_node.get_node_value();
605 }
606 else if (cur_node.is_element())
607 {
608 CL_DomElement cur_element = cur_node.to_element();
609 if (cur_element.get_tag_name() == "sp")
610 {
611 text += " ";
612 }
613 else if (cur_element.get_tag_name() == "para")
614 {
615 if (text.empty()) text = get_formatted(cur_element);
616 else text += "<p>" + get_formatted(cur_element) + "</p>";
617 }
618 else if (cur_element.get_tag_name() == "ref")
619 {
620 std::string link = "null";
621 text += CL_String::format(
622 " <a href=\"%1\" class=\"reflink\">%2</a> ",
623 link,
624 get_formatted(cur_element));
625 }
626 }
627 }
628
629 return text;
630 }
631
632 void ReferenceDocs::parse_groupedclasses()
633 {
634 const int tabrows = 4;
635 // sorting the list
636 rlist.sort(groupsort);
637 // calculating the lines
638 int lines = 0;
639
640 std::list<RefClass>::iterator it1 = rlist.begin();
641
642 if (it1 == rlist.end())
643 {
644 CL_Log::log("error", "Empty class list, can't create reference");
645 return;
646 }
647
648 std::list<RefClass>::iterator it2 = it1;
649 lines += 3; // group and subgroup of the first element and the first element itself
650 ++it1;
651 while (it1 != rlist.end())
652 {
653 if ((*it1).groupString == (*it2).groupString)
654 {
655 // only a new element
656 lines += 1;
657 }
658 else if ((*it1).groupName == (*it2).groupName)
659 {
660 // space, new subgroup, the element
661 lines += 3;
662 }
663 else
664 {
665 // space, new group, new subgroup, the element
666 lines += 4;
667 }
668 it2 = it1; ++it1;
669 }
670
671 int newtabevery = (lines/tabrows)+1;
672
673
674 std::ofstream function_file("/home/mbn/public_html/temp/reftest/modules.html", std::ofstream::out);
675 function_file << "<!-- clanlib header begin -->" << std::endl;
676 function_file << "<HTML>" << std::endl;
677 function_file << "<HEAD>" << std::endl;
678 function_file << "<TITLE>" << "Grouped Classes" << " - ClanLib Game SDK</TITLE>" << std::endl;
679 function_file << "<STYLE TYPE=\"text/css\"><!--" << std::endl;
680 function_file << "HTML BODY" << std::endl;
681 function_file << "{" << std::endl;
682 function_file << " font-family: verdana, helvetica, sans-serif;" << std::endl;
683 function_file << " font-size: 12px;" << std::endl;
684 function_file << "}" << std::endl;
685 function_file << "H1 { font-size: 22px; }" << std::endl;
686 function_file << "H2 { font-size: 18px; }" << std::endl;
687 function_file << "H3 { font-size: 16px; }" << std::endl;
688 function_file << "H4 { font-size: 14px; }" << std::endl;
689 function_file << "P { font-size: 12px; }" << std::endl;
690 function_file << "LI { font-size: 12px; }" << std::endl;
691 function_file << ".reflink:link { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
692 function_file << ".reflink:visited { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
693 function_file << ".reflink:active { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
694 function_file << ".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }" << std::endl;
695 function_file << "--></STYLE>" << std::endl;
696 function_file << "</HEAD>" << std::endl;
697 function_file << "<body bgcolor=white text=black link=blue vlink=#800080>" << std::endl;
698 function_file << "<center>" << std::endl;
699 function_file << "<img src=\"http://clanlib.org/gfx/clanlib.png\">" << std::endl;
700 function_file << "</center>" << std::endl;
701 function_file << "<!-- clanlib header end -->" << std::endl;
702 function_file << "<center>" << std::endl;
703 function_file << "<p>" << std::endl;
704 function_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
705 function_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
706 function_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
707 function_file << "<a href=\"index.html\">Index</a> |" << std::endl;
708 function_file << "<a href=\"search.html\">Search</a>" << std::endl;
709 function_file << "</p>" << std::endl;
710 function_file << "</center>" << std::endl;
711
712
713 function_file << "<h1>Grouped Classes</h1>" << std::endl;
714 function_file << "<table width=100%>" << std::endl;
715 function_file << "<tr><td valign=top><p>" << std::endl;
716 int intabline = 0;
717 int sumintablines = 0;
718 it1 = rlist.begin();
719 it2 = rlist.begin(); bool b1 = true; // b1 is true at the first time
720 while (it1 != rlist.end())
721 {
722 bool needspace = false;
723 bool needgroup = false;
724 bool needsubgroup = false;
725 if (b1)
726 {
727 //necessary because it2 is not valid
728 intabline = 3; needgroup = true; needsubgroup = true;
729 b1 = false;
730 }
731 else
732 {
733 if ((*it1).groupString == (*it2).groupString)
734 {
735 // only a new element
736 intabline += 1;
737 }
738 else if ((*it1).groupName == (*it2).groupName)
739 {
740 // space, new subgroup, the element
741 intabline += 3;
742 needsubgroup = true; needspace = true;
743 }
744 else
745 {
746 // space, new group, new subgroup, the element
747 intabline += 4;
748 needgroup = true; needsubgroup = true; needspace = true;
749 }
750 }
751
752
753 if (intabline > newtabevery)
754 {
755 function_file << "</p></td>" << std::endl;
756 function_file << "<td valign=top><p>" << std::endl;
757 sumintablines += intabline;
758 intabline = 0; needspace = false;
759 if (needgroup) { intabline += 1; }
760 if (needsubgroup) { intabline += 1; }
761 intabline += 1; // for the next object
762 }
763
764
765 if (needspace)
766 {
767 function_file << "<br>";
768 }
769 if (needgroup)
770 {
771 function_file << "<b>" << (*it1).groupName << "</b><br>" << std::endl;
772 }
773 if (needsubgroup)
774 {
775 function_file << "<i>" << (*it1).subGroupName << "</i><br>" << std::endl;
776 }
777 function_file << "<a href=\"" << (*it1).className << ".html\">" << (*it1).className << "</a><br>" << std::endl;
778
779 it2 = it1;
780 ++it1;
781 }
782 sumintablines += intabline;
783 printf("\n exspected lines %d real lines %d\n",lines,sumintablines);
784
785 function_file << "</p></td></tr>" << std::endl;
786 function_file << "</table>" << std::endl;
787
788
789 function_file << "<!-- clanlib footer begin -->" << std::endl;
790 function_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
791 function_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
792 function_file << "</font></center>" << std::endl;
793 function_file << "<!-- clanlib footer end -->" << std::endl;
794 function_file << "</body>" << std::endl;
795 function_file << "</html>" << std::endl;
796
797 }
798
799 void ReferenceDocs::parse_allclasses()
800 {
801 const int tabrows = 4;
802 // sorting the list
803 rlist.sort(indexsort);
804
805 std::list<RefClass>::iterator it1 = rlist.begin();
806
807 if (it1 == rlist.end())
808 {
809 CL_Log::log("error", "Empty class list, can't create reference");
810 return;
811 }
812
813 // determin the carracter which needs to be indexed
814 int indexchar = -1;
815 std::list<RefClass>::iterator it2 = it1;
816 ++it1;
817 if (it1 == rlist.end()) { indexchar = 0; }
818 else
819 {
820 int i2 = (*it2).className.size();
821 if ((*it1).className.size() < i2) { i2 = (*it1).className.size(); }
822 int i1 = 0; while (i1 < i2) { if ((*it1).className[i1] != (*it2).className[i1]) { break; } ++i1; }
823 indexchar = i1; // ok we have our begining difference (it could only get smaller)
824 it2 = it1;
825 while (it1 != rlist.end())
826 {
827 if ((*it1).className.size() < indexchar) { indexchar = (*it1).className.size(); }
828 i1 = 0; while (i1 < indexchar) {if ((*it1).className[i1] != (*it2).className[i1]) { indexchar = i1; break; } ++i1; }
829 it2 = it1;
830 ++it1;
831 }
832 }
833 // ok we have our character
834 // calculating the lines
835 int lines = 0;
836 it1 = rlist.begin();
837 it2 = it1; // reset
838 lines += 2; // The "A" and the first class
839 ++it1;
840 while (it1 != rlist.end())
841 {
842 if ((*it1).className[indexchar] == (*it2).className[indexchar])
843 {
844 // only a new element
845 lines += 1;
846 }
847 else
848 {
849 // space, the charackter, the element
850 lines += 3;
851 }
852 it2 = it1; ++it1;
853 }
854
855 int newtabevery = (lines/tabrows)+1;
856
857
858 std::ofstream function_file("/home/mbn/public_html/temp/reftest/classes.html", std::ofstream::out);
859 function_file << "<!-- clanlib header begin -->" << std::endl;
860 function_file << "<HTML>" << std::endl;
861 function_file << "<HEAD>" << std::endl;
862 function_file << "<TITLE>" << "All Classes" << " - ClanLib Game SDK</TITLE>" << std::endl;
863 function_file << "<STYLE TYPE=\"text/css\"><!--" << std::endl;
864 function_file << "HTML BODY" << std::endl;
865 function_file << "{" << std::endl;
866 function_file << " font-family: verdana, helvetica, sans-serif;" << std::endl;
867 function_file << " font-size: 12px;" << std::endl;
868 function_file << "}" << std::endl;
869 function_file << "H1 { font-size: 22px; }" << std::endl;
870 function_file << "H2 { font-size: 18px; }" << std::endl;
871 function_file << "H3 { font-size: 16px; }" << std::endl;
872 function_file << "H4 { font-size: 14px; }" << std::endl;
873 function_file << "P { font-size: 12px; }" << std::endl;
874 function_file << "LI { font-size: 12px; }" << std::endl;
875 function_file << ".reflink:link { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
876 function_file << ".reflink:visited { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
877 function_file << ".reflink:active { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
878 function_file << ".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }" << std::endl;
879 function_file << "--></STYLE>" << std::endl;
880 function_file << "</HEAD>" << std::endl;
881 function_file << "<body bgcolor=white text=black link=blue vlink=#800080>" << std::endl;
882 function_file << "<center>" << std::endl;
883 function_file << "<img src=\"http://clanlib.org/gfx/clanlib.png\">" << std::endl;
884 function_file << "</center>" << std::endl;
885 function_file << "<!-- clanlib header end -->" << std::endl;
886 function_file << "<center>" << std::endl;
887 function_file << "<p>" << std::endl;
888 function_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
889 function_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
890 function_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
891 function_file << "<a href=\"index.html\">Index</a> |" << std::endl;
892 function_file << "<a href=\"search.html\">Search</a>" << std::endl;
893 function_file << "</p>" << std::endl;
894 function_file << "</center>" << std::endl;
895
896
897 function_file << "<h1>All Classes</h1>" << std::endl;
898 function_file << "<table width=100%>" << std::endl;
899 function_file << "<tr><td valign=top><p>" << std::endl;
900 int intabline = 0;
901 int sumintablines = 0;
902 it1 = rlist.begin();
903 it2 = rlist.begin(); bool b1 = true; // b1 is true at the first time
904 while (it1 != rlist.end())
905 {
906 bool needspace = false;
907 bool needchar = false;
908 if (b1)
909 {
910 //necessary because it2 is not valid
911 intabline = 2; needchar = true;
912 b1 = false;
913 }
914 else
915 {
916 if ((*it1).className[indexchar] == (*it2).className[indexchar])
917 {
918 // only a new element
919 intabline += 1;
920 }
921 else
922 {
923 // space, the charackter, the element
924 intabline += 3; needspace = true; needchar = true;
925 }
926 }
927
928
929 if (intabline > newtabevery)
930 {
931 function_file << "</p></td>" << std::endl;
932 function_file << "<td valign=top><p>" << std::endl;
933 sumintablines += intabline;
934 intabline = 0; needspace = false;
935 if (needchar) { intabline += 1; }
936 intabline += 1; // for the next object
937 }
938
939
940 if (needspace)
941 {
942 function_file << "<br>";
943 }
944 if (needchar)
945 {
946 // there is no need for makeuppercharackter because sorting is case sensetive and Classes should be C lass ;-)
947 function_file << "<b>" << (*it1).className[indexchar] << "</b><br>" << std::endl;
948 }
949 function_file << "<a href=\"" << (*it1).className << ".html\">" << (*it1).className << "</a><br>" << std::endl;
950
951 it2 = it1;
952 ++it1;
953 }
954 sumintablines += intabline;
955 printf("\n exspected lines %d real lines %d\n",lines,sumintablines);
956
957 function_file << "</p></td></tr>" << std::endl;
958 function_file << "</table>" << std::endl;
959
960
961 function_file << "<!-- clanlib footer begin -->" << std::endl;
962 function_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
963 function_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
964 function_file << "</font></center>" << std::endl;
965 function_file << "<!-- clanlib footer end -->" << std::endl;
966 function_file << "</body>" << std::endl;
967 function_file << "</html>" << std::endl;
968
969 }
970
971
972 void ReferenceDocs::parse_indexedclasses()
973 {
974 std::ofstream function_file("/home/mbn/public_html/temp/reftest/index.html", std::ofstream::out);
975 function_file << "<!-- clanlib header begin -->" << std::endl;
976 function_file << "<HTML>" << std::endl;
977 function_file << "<HEAD>" << std::endl;
978 function_file << "<TITLE>" << "Index" << " - ClanLib Game SDK</TITLE>" << std::endl;
979 function_file << "<STYLE TYPE=\"text/css\"><!--" << std::endl;
980 function_file << "HTML BODY" << std::endl;
981 function_file << "{" << std::endl;
982 function_file << " font-family: verdana, helvetica, sans-serif;" << std::endl;
983 function_file << " font-size: 12px;" << std::endl;
984 function_file << "}" << std::endl;
985 function_file << "H1 { font-size: 22px; }" << std::endl;
986 function_file << "H2 { font-size: 18px; }" << std::endl;
987 function_file << "H3 { font-size: 16px; }" << std::endl;
988 function_file << "H4 { font-size: 14px; }" << std::endl;
989 function_file << "P { font-size: 12px; }" << std::endl;
990 function_file << "LI { font-size: 12px; }" << std::endl;
991 function_file << ".reflink:link { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
992 function_file << ".reflink:visited { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
993 function_file << ".reflink:active { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
994 function_file << ".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }" << std::endl;
995 function_file << "--></STYLE>" << std::endl;
996 function_file << "</HEAD>" << std::endl;
997 function_file << "<body bgcolor=white text=black link=blue vlink=#800080>" << std::endl;
998 function_file << "<center>" << std::endl;
999 function_file << "<img src=\"http://clanlib.org/gfx/clanlib.png\">" << std::endl;
1000 function_file << "</center>" << std::endl;
1001 function_file << "<!-- clanlib header end -->" << std::endl;
1002 function_file << "<center>" << std::endl;
1003 function_file << "<p>" << std::endl;
1004 function_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
1005 function_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
1006 function_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
1007 function_file << "<a href=\"index.html\">Index</a> |" << std::endl;
1008 function_file << "<a href=\"search.html\">Search</a>" << std::endl;
1009 function_file << "</p>" << std::endl;
1010 function_file << "</center>" << std::endl;
1011
1012
1013 function_file << "<h1>Index</h1>" << std::endl;
1014
1015
1016 rlist.sort(indexsort);
1017 std::list<RefClass>::iterator it1 = rlist.begin();
1018 while (it1 != rlist.end())
1019 {
1020 function_file << "<p><dt>" << (*it1).className << "</dt>" << std::endl;
1021 function_file << "<dd><a href=\"" << (*it1).className << ".html\">" << (*it1).className << "</a></dd>" << std::endl;
1022 std::vector<std::string>::iterator it3 = (*it1).sections.begin();
1023 while (it3 != (*it1).sections.end())
1024 {
1025 function_file << "<dd>" << (*it3) << "</dd>" << std::endl;
1026 ++it3;
1027 }
1028 function_file << "</p>" << std::endl;
1029 ++it1;
1030 }
1031
1032 function_file << "<!-- clanlib footer begin -->" << std::endl;
1033 function_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
1034 function_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
1035 function_file << "</font></center>" << std::endl;
1036 function_file << "<!-- clanlib footer end -->" << std::endl;
1037 function_file << "</body>" << std::endl;
1038 function_file << "</html>" << std::endl;
1039
1040 }
1041
1042
1043 void ReferenceDocs::on_log_message(const std::string &channel, int level, const std::string &text)
1044 {
1045 if (channel == "spam") return;
1046 std::cout << "[" << channel.c_str() << "] " << text.c_str() << std::endl;
1047 }