Debian Codegraph @

Utilities/ReferenceDocs/main.cpp

raw ◀ ▶
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 << "<!-- clanlib header end -->" << std::endl;
229 class_file << "<center>" << std::endl;
230 class_file << "<p>" << std::endl;
231 class_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
232 class_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
233 class_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
234 class_file << "<a href=\"index.html\">Index</a> |" << std::endl;
235 class_file << "<a href=\"search.html\">Search</a>" << std::endl;
236 class_file << "</p>" << std::endl;
237 class_file << "</center>" << std::endl;
238
239 class_file << "<h1>Class " << class_name.c_str() << "</h1>" << std::endl;
240 class_file << "<p>" << brief.c_str();
241 if (!detail.empty()) class_file << " <a href=\"#description\">More...</a>";
242 class_file << "</p>" << std::endl;
243 class_file << "<table>" << std::endl;
244 class_file << "<tr><td valign=top nowrap><p>Derived from:</p></td><td valign=top><p>" << std::endl;
245 if (!base_classes.empty())
246 {
247 for (int i=0; i<base_classes.size()-1; i++)
248 class_file << base_classes[i].c_str() << ", ";
249
250 class_file << base_classes[base_classes.size()-1].c_str();
251 }
252 else
253 {
254 class_file << "<i>None</i>";
255 }
256 class_file << "</p></td></tr>" << std::endl;
257 class_file << "<tr><td valign=top><p>Derived by:</p></td><td valign=top><p>" << std::endl;
258 if (!derived_classes.empty())
259 {
260 for (int i=0; i<derived_classes.size()-1; i++)
261 class_file << derived_classes[i].c_str() << ", ";
262
263 class_file << derived_classes[derived_classes.size()-1].c_str();
264 }
265 else
266 {
267 class_file << "<i>None</i>";
268 }
269 class_file << "</p></td></tr>" << std::endl;
270 class_file << "<tr><td><p>Group:</p></td><td><p>" << clan_group.c_str() << " (" << clan_section.c_str() << ")</p></td></tr>" << std::endl;
271 class_file << "</table>" << std::endl;
272 class_file << "<p>#include &lt;ClanLib/" << clan_header.c_str() << "&gt;</p>" << std::endl;
273
274 for (int section_index = 0; section_index < sections.size(); section_index++)
275 {
276 class_file << sections[section_index] << std::endl;
277 }
278
279 if (!detail.empty())
280 {
281 class_file << "<a name=\"#description\"><p><b>Detailed description:</b></p></a>" << std::endl;
282 class_file << detail.c_str() << std::endl;
283 }
284
285
286 // now we need to get the function etc. data
287 refcl.sections.swap(sections);
288 // adding the class to the reference list
289 if (!ishide)
290 {
291 rlist.push_back(refcl);
292 }
293
294 class_file << "<!-- clanlib footer begin -->" << std::endl;
295 class_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
296 class_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
297 class_file << "</font></center>" << std::endl;
298 class_file << "<!-- clanlib footer end -->" << std::endl;
299 class_file << "</body>" << std::endl;
300 class_file << "</html>" << std::endl;
301 }
302
303 std::string ReferenceDocs::parse_sectiondef(const std::string &class_name, CL_DomElement sectiondef)
304 {
305 std::string text;
306
307 std::string section_name;
308 std::vector<std::string> members;
309
310 std::map<std::string, int> member_map;
311
312 CL_DomNode cur_node;
313 for (cur_node = sectiondef.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
314 {
315 CL_DomElement cur_element = cur_node.to_element();
316 if (cur_element.is_null()) continue;
317
318 std::string tag_name = cur_element.get_tag_name();
319
320 if (tag_name == "header")
321 {
322 section_name = cur_element.get_text();
323 if (section_name == "Implementation")
324 {
325 // skip implementation group.
326 return std::string();
327 }
328 }
329 else if (tag_name == "memberdef")
330 {
331 std::string member = parse_memberdef(class_name, section_name, member_map, cur_element);
332 if (!member.empty()) members.push_back(member);
333 }
334 }
335
336 text += CL_String::format("<p><b>%1:</b></p>", section_name);
337 text += "<table border=0 width=100%>";
338 for (int i=0; i<members.size(); i++)
339 {
340 text += members[i];
341 }
342 text += "</table>";
343
344 return text;
345 }
346
347 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)
348 {
349 std::string text;
350
351 std::string kind = memberdef.get_attribute("kind");
352 bool member_static = (memberdef.get_attribute("static") == "yes");
353 bool member_const = (memberdef.get_attribute("const") == "yes");
354 bool member_explicit = (memberdef.get_attribute("explicit") == "yes");
355 bool member_inline = (memberdef.get_attribute("inline") == "yes");
356 bool member_virtual = (memberdef.get_attribute("virtual") == "virtual");
357 std::string prot = memberdef.get_attribute("prot", "public");
358
359 if (prot == "private") return text;
360
361 std::string type, name, definition, argsstring, brief, detail;
362 std::string params_description;
363 std::vector<std::string> params;
364
365 CL_DomNode cur_node;
366 for (cur_node = memberdef.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
367 {
368 CL_DomElement cur_element = cur_node.to_element();
369 if (cur_element.is_null()) continue;
370
371 std::string tag_name = cur_element.get_tag_name();
372
373 if (tag_name == "type")
374 {
375 type = cur_element.get_text();
376 }
377 else if (tag_name == "definition")
378 {
379 definition = cur_element.get_text();
380 }
381 else if (tag_name == "argsstring")
382 {
383 argsstring = cur_element.get_text();
384 }
385 else if (tag_name == "name")
386 {
387 name = cur_element.get_text();
388
389 // Skip destructors.
390 if (!name.empty() && name[0] == '~') return std::string();
391 }
392 else if (tag_name == "param")
393 {
394 std::string param_type = get_formatted(cur_element.named_item("type").to_element());
395 std::string param_name = cur_element.named_item("declname").to_element().get_text();
396 std::string param_defval = cur_element.named_item("defval").to_element().get_text();
397
398 std::string param_text = param_type + " " + param_name;
399 if (!param_defval.empty()) param_text += std::string(" = ") + param_defval;
400 params.push_back(param_text);
401 }
402 else if (tag_name == "briefdescription")
403 {
404 brief = get_formatted(cur_element);
405 }
406 else if (tag_name == "detaileddescription")
407 {
408 detail = get_formatted(cur_element);
409 params_description = get_params_list(cur_element);
410 }
411 else if (tag_name == "location")
412 {
413 }
414 }
415
416 // Group functions:
417 std::map<std::string, int>::iterator it = member_map.find(name);
418 if (it != member_map.end())
419 {
420 if (brief.empty()) return std::string();
421 it->second++;
422 }
423 else
424 {
425 member_map[name] = 0;
426 }
427
428 // Generate output:
429 std::string filename = CL_String::format("%1_func%2_%3.html", class_name, CL_String::from_int(member_map[name]), name);
430 std::string hint;
431 if (member_static) hint += " static";
432 if (member_const) hint += " const";
433 if (member_explicit) hint += " explicit";
434 if (member_inline) hint += " inline";
435 if (member_virtual) hint += " virtual";
436 if (prot == "protected") hint += " protected";
437
438 text += CL_String::format(
439 "<tr>"
440 "<td width=30% valign=top><p><a href=\"%1\">%2</a><i>%3</i></p></td>"
441 "<td valign=top><p>%4</p></td>"
442 "</tr>",
443 filename,
444 name,
445 hint,
446 brief);
447
448
449 std::ofstream function_file(CL_String::format("/home/mbn/public_html/temp/reftest/%1", filename).c_str(), std::ofstream::out);
450 function_file << "<!-- clanlib header begin -->" << std::endl;
451 function_file << "<HTML>" << std::endl;
452 function_file << "<HEAD>" << std::endl;
453 function_file << "<TITLE>" << name.c_str() << " - ClanLib Game SDK</TITLE>" << std::endl;
454 function_file << "<STYLE TYPE=\"text/css\"><!--" << std::endl;
455 function_file << "HTML BODY" << std::endl;
456 function_file << "{" << std::endl;
457 function_file << " font-family: verdana, helvetica, sans-serif;" << std::endl;
458 function_file << " font-size: 12px;" << std::endl;
459 function_file << "}" << std::endl;
460 function_file << "H1 { font-size: 22px; }" << std::endl;
461 function_file << "H2 { font-size: 18px; }" << std::endl;
462 function_file << "H3 { font-size: 16px; }" << std::endl;
463 function_file << "H4 { font-size: 14px; }" << std::endl;
464 function_file << "P { font-size: 12px; }" << std::endl;
465 function_file << "LI { font-size: 12px; }" << std::endl;
466 function_file << ".reflink:link { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
467 function_file << ".reflink:visited { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
468 function_file << ".reflink:active { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
469 function_file << ".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }" << std::endl;
470 function_file << "--></STYLE>" << std::endl;
471 function_file << "</HEAD>" << std::endl;
472 function_file << "<body bgcolor=white text=black link=blue vlink=#800080>" << std::endl;
473 function_file << "<!-- clanlib header end -->" << std::endl;
474 function_file << "<center>" << std::endl;
475 function_file << "<p>" << std::endl;
476 function_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
477 function_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
478 function_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
479 function_file << "<a href=\"index.html\">Index</a> |" << std::endl;
480 function_file << "<a href=\"search.html\">Search</a>" << std::endl;
481 function_file << "</p>" << std::endl;
482 function_file << "</center>" << std::endl;
483
484 function_file << "<h1>Function " << name.c_str() << "</h1>" << std::endl;
485 function_file << "<p>" << brief.c_str() << "</p>" << std::endl;
486 function_file << "<pre>" << std::endl;
487 function_file << "\t" << definition.c_str() << "("; // << argsstring.c_str() << std::endl;
488 for (int index_params = 0; index_params < params.size(); index_params++)
489 {
490 if (index_params > 0) function_file << ",";
491 function_file << std::endl << "\t\t" << params[index_params];
492 }
493 function_file << ");" << std::endl;
494 function_file << "</pre>" << std::endl;
495
496 if (!params_description.empty())
497 {
498 function_file << "<p><b>Parameters:</b></p>" << std::endl;
499 function_file << params_description.c_str() << std::endl;
500 }
501 /*
502 print FILE "<p><b>Return value:</b></p>\n";
503 print FILE "<p>";
504 print_description(&addCrossRef($funcretval{$filename}));
505 print FILE "</p>\n";
506 */
507
508 if (!detail.empty())
509 {
510 function_file << "<p><b>Detailed description:</b></p>" << std::endl;
511 function_file << "<p>" << detail.c_str() << "</p>" << std::endl;
512 }
513
514 function_file << "<p><b>See also:</b></p>" << std::endl;
515 function_file << "<p><a href=\"" << class_name << ".html\">" << class_name << "</a></p>" << std::endl;
516 /*
517 print FILE "<p><b>See also:</b></p>\n";
518 $see_also{$classname} = "<a href=\"$classfilename.html\">$classname</a>";
519
520 my $str;
521 my $cur_also;
522 foreach $cur_also (keys %see_also)
523 {
524 $str .= " | " if ($str ne "");
525 $str .= $see_also{$cur_also};
526 }
527
528 print FILE "<p>$str</p>\n";
529 */
530
531 function_file << "<!-- clanlib footer begin -->" << std::endl;
532 function_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
533 function_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
534 function_file << "</font></center>" << std::endl;
535 function_file << "<!-- clanlib footer end -->" << std::endl;
536 function_file << "</body>" << std::endl;
537 function_file << "</html>" << std::endl;
538
539 return text;
540 }
541
542 std::string ReferenceDocs::get_params_list(const CL_DomElement &element)
543 {
544 std::string text;
545
546 CL_DomNode cur_node;
547 for (cur_node = element.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
548 {
549 if (!cur_node.is_element()) continue;
550
551 CL_DomElement cur_element = cur_node.to_element();
552 if (cur_element.get_tag_name() == "parameterlist")
553 {
554 std::string kind = cur_element.get_attribute("kind");
555 if (kind != "param") continue;
556
557 text += "<dl>";
558
559 std::string param_name, param_description;
560 CL_DomNode param_node;
561 for (param_node = cur_element.get_first_child(); !param_node.is_null(); param_node = param_node.get_next_sibling())
562 {
563 if (!param_node.is_element()) continue;
564 CL_DomElement param_element = param_node.to_element();
565
566 if (param_element.get_tag_name() == "parametername")
567 {
568 param_name = param_element.get_text();
569 }
570 else if (param_element.get_tag_name() == "parameterdescription")
571 {
572 param_description = get_formatted(param_element);
573 text += CL_String::format("<dt><i>%1</i></dt><dd>%2</dd>", param_name, param_description);
574 }
575 }
576
577 text += "</dl>";
578 }
579 else
580 {
581 text += get_params_list(cur_element);
582 }
583 }
584
585 return text;
586 }
587
588 std::string ReferenceDocs::get_formatted(const CL_DomElement &element)
589 {
590 std::string text;
591
592 CL_DomNode cur_node;
593 for (cur_node = element.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
594 {
595 if (cur_node.is_text())
596 {
597 CL_DomText cur_text = cur_node.to_text();
598 text += cur_node.get_node_value();
599 }
600 else if (cur_node.is_element())
601 {
602 CL_DomElement cur_element = cur_node.to_element();
603 if (cur_element.get_tag_name() == "sp")
604 {
605 text += " ";
606 }
607 else if (cur_element.get_tag_name() == "para")
608 {
609 if (text.empty()) text = get_formatted(cur_element);
610 else text += "<p>" + get_formatted(cur_element) + "</p>";
611 }
612 else if (cur_element.get_tag_name() == "ref")
613 {
614 std::string link = "null";
615 text += CL_String::format(
616 " <a href=\"%1\" class=\"reflink\">%2</a> ",
617 link,
618 get_formatted(cur_element));
619 }
620 }
621 }
622
623 return text;
624 }
625
626 void ReferenceDocs::parse_groupedclasses()
627 {
628 const int tabrows = 4;
629 // sorting the list
630 rlist.sort(groupsort);
631 // calculating the lines
632 int lines = 0;
633
634 std::list<RefClass>::iterator it1 = rlist.begin();
635
636 if (it1 == rlist.end())
637 {
638 CL_Log::log("error", "Empty class list, can't create reference");
639 return;
640 }
641
642 std::list<RefClass>::iterator it2 = it1;
643 lines += 3; // group and subgroup of the first element and the first element itself
644 ++it1;
645 while (it1 != rlist.end())
646 {
647 if ((*it1).groupString == (*it2).groupString)
648 {
649 // only a new element
650 lines += 1;
651 }
652 else if ((*it1).groupName == (*it2).groupName)
653 {
654 // space, new subgroup, the element
655 lines += 3;
656 }
657 else
658 {
659 // space, new group, new subgroup, the element
660 lines += 4;
661 }
662 it2 = it1; ++it1;
663 }
664
665 int newtabevery = (lines/tabrows)+1;
666
667
668 std::ofstream function_file("/home/mbn/public_html/temp/reftest/modules.html", std::ofstream::out);
669 function_file << "<!-- clanlib header begin -->" << std::endl;
670 function_file << "<HTML>" << std::endl;
671 function_file << "<HEAD>" << std::endl;
672 function_file << "<TITLE>" << "Grouped Classes" << " - ClanLib Game SDK</TITLE>" << std::endl;
673 function_file << "<STYLE TYPE=\"text/css\"><!--" << std::endl;
674 function_file << "HTML BODY" << std::endl;
675 function_file << "{" << std::endl;
676 function_file << " font-family: verdana, helvetica, sans-serif;" << std::endl;
677 function_file << " font-size: 12px;" << std::endl;
678 function_file << "}" << std::endl;
679 function_file << "H1 { font-size: 22px; }" << std::endl;
680 function_file << "H2 { font-size: 18px; }" << std::endl;
681 function_file << "H3 { font-size: 16px; }" << std::endl;
682 function_file << "H4 { font-size: 14px; }" << std::endl;
683 function_file << "P { font-size: 12px; }" << std::endl;
684 function_file << "LI { font-size: 12px; }" << std::endl;
685 function_file << ".reflink:link { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
686 function_file << ".reflink:visited { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
687 function_file << ".reflink:active { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
688 function_file << ".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }" << std::endl;
689 function_file << "--></STYLE>" << std::endl;
690 function_file << "</HEAD>" << std::endl;
691 function_file << "<body bgcolor=white text=black link=blue vlink=#800080>" << std::endl;
692 function_file << "<!-- clanlib header end -->" << std::endl;
693 function_file << "<center>" << std::endl;
694 function_file << "<p>" << std::endl;
695 function_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
696 function_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
697 function_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
698 function_file << "<a href=\"index.html\">Index</a> |" << std::endl;
699 function_file << "<a href=\"search.html\">Search</a>" << std::endl;
700 function_file << "</p>" << std::endl;
701 function_file << "</center>" << std::endl;
702
703
704 function_file << "<h1>Grouped Classes</h1>" << std::endl;
705 function_file << "<table width=100%>" << std::endl;
706 function_file << "<tr><td valign=top><p>" << std::endl;
707 int intabline = 0;
708 int sumintablines = 0;
709 it1 = rlist.begin();
710 it2 = rlist.begin(); bool b1 = true; // b1 is true at the first time
711 while (it1 != rlist.end())
712 {
713 bool needspace = false;
714 bool needgroup = false;
715 bool needsubgroup = false;
716 if (b1)
717 {
718 //necessary because it2 is not valid
719 intabline = 3; needgroup = true; needsubgroup = true;
720 b1 = false;
721 }
722 else
723 {
724 if ((*it1).groupString == (*it2).groupString)
725 {
726 // only a new element
727 intabline += 1;
728 }
729 else if ((*it1).groupName == (*it2).groupName)
730 {
731 // space, new subgroup, the element
732 intabline += 3;
733 needsubgroup = true; needspace = true;
734 }
735 else
736 {
737 // space, new group, new subgroup, the element
738 intabline += 4;
739 needgroup = true; needsubgroup = true; needspace = true;
740 }
741 }
742
743
744 if (intabline > newtabevery)
745 {
746 function_file << "</p></td>" << std::endl;
747 function_file << "<td valign=top><p>" << std::endl;
748 sumintablines += intabline;
749 intabline = 0; needspace = false;
750 if (needgroup) { intabline += 1; }
751 if (needsubgroup) { intabline += 1; }
752 intabline += 1; // for the next object
753 }
754
755
756 if (needspace)
757 {
758 function_file << "<br>";
759 }
760 if (needgroup)
761 {
762 function_file << "<b>" << (*it1).groupName << "</b><br>" << std::endl;
763 }
764 if (needsubgroup)
765 {
766 function_file << "<i>" << (*it1).subGroupName << "</i><br>" << std::endl;
767 }
768 function_file << "<a href=\"" << (*it1).className << ".html\">" << (*it1).className << "</a><br>" << std::endl;
769
770 it2 = it1;
771 ++it1;
772 }
773 sumintablines += intabline;
774 printf("\n exspected lines %d real lines %d\n",lines,sumintablines);
775
776 function_file << "</p></td></tr>" << std::endl;
777 function_file << "</table>" << std::endl;
778
779
780 function_file << "<!-- clanlib footer begin -->" << std::endl;
781 function_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
782 function_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
783 function_file << "</font></center>" << std::endl;
784 function_file << "<!-- clanlib footer end -->" << std::endl;
785 function_file << "</body>" << std::endl;
786 function_file << "</html>" << std::endl;
787
788 }
789
790 void ReferenceDocs::parse_allclasses()
791 {
792 const int tabrows = 4;
793 // sorting the list
794 rlist.sort(indexsort);
795
796 std::list<RefClass>::iterator it1 = rlist.begin();
797
798 if (it1 == rlist.end())
799 {
800 CL_Log::log("error", "Empty class list, can't create reference");
801 return;
802 }
803
804 // determin the carracter which needs to be indexed
805 int indexchar = -1;
806 std::list<RefClass>::iterator it2 = it1;
807 ++it1;
808 if (it1 == rlist.end()) { indexchar = 0; }
809 else
810 {
811 int i2 = (*it2).className.size();
812 if ((*it1).className.size() < i2) { i2 = (*it1).className.size(); }
813 int i1 = 0; while (i1 < i2) { if ((*it1).className[i1] != (*it2).className[i1]) { break; } ++i1; }
814 indexchar = i1; // ok we have our begining difference (it could only get smaller)
815 it2 = it1;
816 while (it1 != rlist.end())
817 {
818 if ((*it1).className.size() < indexchar) { indexchar = (*it1).className.size(); }
819 i1 = 0; while (i1 < indexchar) {if ((*it1).className[i1] != (*it2).className[i1]) { indexchar = i1; break; } ++i1; }
820 it2 = it1;
821 ++it1;
822 }
823 }
824 // ok we have our character
825 // calculating the lines
826 int lines = 0;
827 it1 = rlist.begin();
828 it2 = it1; // reset
829 lines += 2; // The "A" and the first class
830 ++it1;
831 while (it1 != rlist.end())
832 {
833 if ((*it1).className[indexchar] == (*it2).className[indexchar])
834 {
835 // only a new element
836 lines += 1;
837 }
838 else
839 {
840 // space, the charackter, the element
841 lines += 3;
842 }
843 it2 = it1; ++it1;
844 }
845
846 int newtabevery = (lines/tabrows)+1;
847
848
849 std::ofstream function_file("/home/mbn/public_html/temp/reftest/classes.html", std::ofstream::out);
850 function_file << "<!-- clanlib header begin -->" << std::endl;
851 function_file << "<HTML>" << std::endl;
852 function_file << "<HEAD>" << std::endl;
853 function_file << "<TITLE>" << "All Classes" << " - ClanLib Game SDK</TITLE>" << std::endl;
854 function_file << "<STYLE TYPE=\"text/css\"><!--" << std::endl;
855 function_file << "HTML BODY" << std::endl;
856 function_file << "{" << std::endl;
857 function_file << " font-family: verdana, helvetica, sans-serif;" << std::endl;
858 function_file << " font-size: 12px;" << std::endl;
859 function_file << "}" << std::endl;
860 function_file << "H1 { font-size: 22px; }" << std::endl;
861 function_file << "H2 { font-size: 18px; }" << std::endl;
862 function_file << "H3 { font-size: 16px; }" << std::endl;
863 function_file << "H4 { font-size: 14px; }" << std::endl;
864 function_file << "P { font-size: 12px; }" << std::endl;
865 function_file << "LI { font-size: 12px; }" << std::endl;
866 function_file << ".reflink:link { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
867 function_file << ".reflink:visited { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
868 function_file << ".reflink:active { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
869 function_file << ".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }" << std::endl;
870 function_file << "--></STYLE>" << std::endl;
871 function_file << "</HEAD>" << std::endl;
872 function_file << "<body bgcolor=white text=black link=blue vlink=#800080>" << std::endl;
873 function_file << "<!-- clanlib header end -->" << std::endl;
874 function_file << "<center>" << std::endl;
875 function_file << "<p>" << std::endl;
876 function_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
877 function_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
878 function_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
879 function_file << "<a href=\"index.html\">Index</a> |" << std::endl;
880 function_file << "<a href=\"search.html\">Search</a>" << std::endl;
881 function_file << "</p>" << std::endl;
882 function_file << "</center>" << std::endl;
883
884
885 function_file << "<h1>All Classes</h1>" << std::endl;
886 function_file << "<table width=100%>" << std::endl;
887 function_file << "<tr><td valign=top><p>" << std::endl;
888 int intabline = 0;
889 int sumintablines = 0;
890 it1 = rlist.begin();
891 it2 = rlist.begin(); bool b1 = true; // b1 is true at the first time
892 while (it1 != rlist.end())
893 {
894 bool needspace = false;
895 bool needchar = false;
896 if (b1)
897 {
898 //necessary because it2 is not valid
899 intabline = 2; needchar = true;
900 b1 = false;
901 }
902 else
903 {
904 if ((*it1).className[indexchar] == (*it2).className[indexchar])
905 {
906 // only a new element
907 intabline += 1;
908 }
909 else
910 {
911 // space, the charackter, the element
912 intabline += 3; needspace = true; needchar = true;
913 }
914 }
915
916
917 if (intabline > newtabevery)
918 {
919 function_file << "</p></td>" << std::endl;
920 function_file << "<td valign=top><p>" << std::endl;
921 sumintablines += intabline;
922 intabline = 0; needspace = false;
923 if (needchar) { intabline += 1; }
924 intabline += 1; // for the next object
925 }
926
927
928 if (needspace)
929 {
930 function_file << "<br>";
931 }
932 if (needchar)
933 {
934 // there is no need for makeuppercharackter because sorting is case sensetive and Classes should be C lass ;-)
935 function_file << "<b>" << (*it1).className[indexchar] << "</b><br>" << std::endl;
936 }
937 function_file << "<a href=\"" << (*it1).className << ".html\">" << (*it1).className << "</a><br>" << std::endl;
938
939 it2 = it1;
940 ++it1;
941 }
942 sumintablines += intabline;
943 printf("\n exspected lines %d real lines %d\n",lines,sumintablines);
944
945 function_file << "</p></td></tr>" << std::endl;
946 function_file << "</table>" << std::endl;
947
948
949 function_file << "<!-- clanlib footer begin -->" << std::endl;
950 function_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
951 function_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
952 function_file << "</font></center>" << std::endl;
953 function_file << "<!-- clanlib footer end -->" << std::endl;
954 function_file << "</body>" << std::endl;
955 function_file << "</html>" << std::endl;
956
957 }
958
959
960 void ReferenceDocs::parse_indexedclasses()
961 {
962 std::ofstream function_file("/home/mbn/public_html/temp/reftest/index.html", std::ofstream::out);
963 function_file << "<!-- clanlib header begin -->" << std::endl;
964 function_file << "<HTML>" << std::endl;
965 function_file << "<HEAD>" << std::endl;
966 function_file << "<TITLE>" << "Index" << " - ClanLib Game SDK</TITLE>" << std::endl;
967 function_file << "<STYLE TYPE=\"text/css\"><!--" << std::endl;
968 function_file << "HTML BODY" << std::endl;
969 function_file << "{" << std::endl;
970 function_file << " font-family: verdana, helvetica, sans-serif;" << std::endl;
971 function_file << " font-size: 12px;" << std::endl;
972 function_file << "}" << std::endl;
973 function_file << "H1 { font-size: 22px; }" << std::endl;
974 function_file << "H2 { font-size: 18px; }" << std::endl;
975 function_file << "H3 { font-size: 16px; }" << std::endl;
976 function_file << "H4 { font-size: 14px; }" << std::endl;
977 function_file << "P { font-size: 12px; }" << std::endl;
978 function_file << "LI { font-size: 12px; }" << std::endl;
979 function_file << ".reflink:link { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
980 function_file << ".reflink:visited { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
981 function_file << ".reflink:active { text-decoration: none; font-weight: bold; color: black; }" << std::endl;
982 function_file << ".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }" << std::endl;
983 function_file << "--></STYLE>" << std::endl;
984 function_file << "</HEAD>" << std::endl;
985 function_file << "<body bgcolor=white text=black link=blue vlink=#800080>" << std::endl;
986 function_file << "<!-- clanlib header end -->" << std::endl;
987 function_file << "<center>" << std::endl;
988 function_file << "<p>" << std::endl;
989 function_file << "<a href=\"http://clanlib.org/docs.html\">Home</a> |" << std::endl;
990 function_file << "<a href=\"classes.html\">All Classes</a> |" << std::endl;
991 function_file << "<a href=\"modules.html\">Grouped Classes</a> |" << std::endl;
992 function_file << "<a href=\"index.html\">Index</a> |" << std::endl;
993 function_file << "<a href=\"search.html\">Search</a>" << std::endl;
994 function_file << "</p>" << std::endl;
995 function_file << "</center>" << std::endl;
996
997
998 function_file << "<h1>Index</h1>" << std::endl;
999
1000
1001 rlist.sort(indexsort);
1002 std::list<RefClass>::iterator it1 = rlist.begin();
1003 while (it1 != rlist.end())
1004 {
1005 function_file << "<p><dt>" << (*it1).className << "</dt>" << std::endl;
1006 function_file << "<dd><a href=\"" << (*it1).className << ".html\">" << (*it1).className << "</a></dd>" << std::endl;
1007 std::vector<std::string>::iterator it3 = (*it1).sections.begin();
1008 while (it3 != (*it1).sections.end())
1009 {
1010 function_file << "<dd>" << (*it3) << "</dd>" << std::endl;
1011 ++it3;
1012 }
1013 function_file << "</p>" << std::endl;
1014 ++it1;
1015 }
1016
1017 function_file << "<!-- clanlib footer begin -->" << std::endl;
1018 function_file << "<center><br><br><font color=\"#a0a0a0\">" << std::endl;
1019 function_file << "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>." << std::endl;
1020 function_file << "</font></center>" << std::endl;
1021 function_file << "<!-- clanlib footer end -->" << std::endl;
1022 function_file << "</body>" << std::endl;
1023 function_file << "</html>" << std::endl;
1024
1025 }
1026
1027
1028 void ReferenceDocs::on_log_message(const std::string &channel, int level, const std::string &text)
1029 {
1030 if (channel == "spam") return;
1031 std::cout << "[" << channel.c_str() << "] " << text.c_str() << std::endl;
1032 }