See header for documentation. */
| 72 | |
| 73 | /* See header for documentation. */ |
| 74 | TraceNode::TraceNode( |
| 75 | const char* format, |
| 76 | ... |
| 77 | ) { |
| 78 | // Format the name string |
| 79 | constexpr size_t bufsz = 256; |
| 80 | char buffer[bufsz]; |
| 81 | |
| 82 | va_list args; |
| 83 | va_start (args, format); |
| 84 | vsnprintf (buffer, bufsz, format, args); |
| 85 | va_end (args); |
| 86 | |
| 87 | // Guarantee there is a NUL terminator |
| 88 | buffer[bufsz - 1] = 0; |
| 89 | |
| 90 | // Generate the node |
| 91 | TraceNode* parent = g_TraceLog->get_current_leaf(); |
| 92 | size_t depth = g_TraceLog->get_depth(); |
| 93 | g_TraceLog->m_stack.push_back(this); |
| 94 | |
| 95 | bool comma = parent && parent->m_attrib_count; |
| 96 | auto& out = g_TraceLog->m_file; |
| 97 | |
| 98 | if (parent) |
| 99 | { |
| 100 | parent->m_attrib_count++; |
| 101 | } |
| 102 | |
| 103 | if (comma) |
| 104 | { |
| 105 | out << ','; |
| 106 | } |
| 107 | |
| 108 | if (depth) |
| 109 | { |
| 110 | out << '\n'; |
| 111 | } |
| 112 | |
| 113 | size_t out_indent = (depth * 2) * g_trace_indent; |
| 114 | size_t in_indent = (depth * 2 + 1) * g_trace_indent; |
| 115 | |
| 116 | std::string out_indents(""); |
| 117 | if (out_indent) |
| 118 | { |
| 119 | out_indents = std::string(out_indent, ' '); |
| 120 | } |
| 121 | |
| 122 | std::string in_indents(in_indent, ' '); |
| 123 | |
| 124 | out << out_indents << "[ \"node\", \"" << buffer << "\",\n"; |
| 125 | out << in_indents << "["; |
| 126 | } |
| 127 | |
| 128 | /* See header for documentation. */ |
| 129 | void TraceNode::add_attrib( |
nothing calls this directly
no test coverage detected