parseDoxytags.cpp 1.88 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <map>

using boost::property_tree::ptree;

int main() {
	ptree pt;
	read_xml("xerus.tagfile", pt);
	
	std::map<std::string, std::string> tags;
	for (const auto &compound : pt.get_child("tagfile")) {
		std::string currNamespace = "";
		if (compound.first != "compound") {
			std::cout << "*** skipping " << compound.first << " tag" << std::endl;
			continue;
		}
		std::string kind = compound.second.get<std::string>("<xmlattr>.kind", "N/A");
		if (kind == "page") {
			continue;
		}
		if (kind == "class" || kind == "struct" || kind == "namespace") {
			currNamespace = compound.second.get<std::string>("name");
		}
		
		for (const auto &subc : compound.second) {
			// we are looking for namespaces (in order! -.-) and members
			if (subc.first == "namespace") {
				currNamespace = subc.second.get<std::string>("");
			} else if (subc.first == "member") {
				std::string name = subc.second.get<std::string>("name");
				std::string subkind = subc.second.get<std::string>("<xmlattr>.kind", "N/A");
				std::string anchorfile = subc.second.get<std::string>("anchorfile");
				std::string anchor = subc.second.get<std::string>("anchor");
				std::string args = subc.second.get<std::string>("arglist");
				if (currNamespace!= "" && subkind != "define") {
					name = currNamespace+"::"+name;
				}
				boost::replace_all(name, " ", "");
44
				tags.insert({name, anchorfile + '#' + anchor});
45
46
47
48
49
50
51
52
53
54
55
56
57
			} else {
// 				std::cout << "* skipping " << subc.first << std::endl;
			}
		}
	}
	
	std::ofstream outFile("xerus.tags");
	for (const auto &t : tags) {
		outFile << t.first << "\t/doxygen/" << t.second << '\n';
	}
	
	std::cout << "### found " << tags.size() << " unique tags in xerus.tagfile created by doxygen." << std::endl;
}