This class generate the HTML out of a file with the said tags. */
| 36 | /* This class generate the HTML out of a file with the said tags. |
| 37 | */ |
| 38 | class Generator { |
| 39 | |
| 40 | struct Tag { |
| 41 | std::string name; |
| 42 | std::string attributes; |
| 43 | int pos; |
| 44 | int len; |
| 45 | bool operator<(const Tag &other) const { |
| 46 | //This is the order of the opening tag. Order first by position, then by length |
| 47 | // (in the reverse order) with the exception of length of 0 which always goes first. |
| 48 | // Ordered first by position, and then by lenth (reverse order) |
| 49 | return (pos != other.pos) ? pos < other.pos |
| 50 | : len == 0 || (other.len != 0 && len > other.len); |
| 51 | } |
| 52 | bool operator==(const Tag &other) const { |
| 53 | return std::tie(pos, len, name, attributes) == |
| 54 | std::tie(other.pos, other.len, other.name, other.attributes); |
| 55 | } |
| 56 | void open(llvm::raw_ostream& myfile) const; |
| 57 | void close(llvm::raw_ostream& myfile) const; |
| 58 | }; |
| 59 | |
| 60 | std::multiset<Tag> tags; |
| 61 | |
| 62 | std::map<std::string, std::string> projects; |
| 63 | |
| 64 | public: |
| 65 | |
| 66 | void addTag(std::string name, std::string attributes, int pos, int len) { |
| 67 | if (len < 0) { |
| 68 | return; |
| 69 | } |
| 70 | Tag t = {std::move(name), std::move(attributes), pos, len}; |
| 71 | auto it = tags.find(t); |
| 72 | if (it != tags.end() && *it == t) return; //Hapens in macro for example |
| 73 | tags.insert(std::move(t)); |
| 74 | } |
| 75 | void addProject(std::string a, std::string b) { |
| 76 | projects.insert({std::move(a), std::move(b) }); |
| 77 | } |
| 78 | |
| 79 | void generate(llvm::StringRef outputPrefix, std::string dataPath, const std::string &filename, |
| 80 | const char* begin, const char* end, llvm::StringRef footer, llvm::StringRef warningMessage, |
| 81 | const std::set<std::string> &interestingDefitions); |
| 82 | |
| 83 | static llvm::StringRef escapeAttr(llvm::StringRef, llvm::SmallVectorImpl<char> &buffer); |
| 84 | static void escapeAttr(llvm::raw_ostream& os, llvm::StringRef s); |
| 85 | |
| 86 | struct EscapeAttr { llvm::StringRef value; }; |
| 87 | }; |
| 88 | |
| 89 | inline llvm::raw_ostream& operator<<(llvm::raw_ostream& os, Generator::EscapeAttr s) |
| 90 | { Generator::escapeAttr(os, s.value); return os; } |
nothing calls this directly
no outgoing calls
no test coverage detected