Coverage Report

Created: 2025-07-23 06:45

/proc/self/cwd/cpp/htmlparser/atomutil.h
Line
Count
Source
1
// Helper class to do a lookup of a tag/entity/event to its Atom and convert
2
// atom to string.
3
4
#ifndef CPP_HTMLPARSER_ATOMUTIL_H_
5
#define CPP_HTMLPARSER_ATOMUTIL_H_
6
7
#include <string>
8
9
#include "cpp/htmlparser/atom.h"
10
11
namespace htmlparser {
12
13
class AtomUtil {
14
 public:
15
  static Atom ToAtom(const std::string& s);
16
  // Returns the string representation (tag name) of the atom.
17
  // If the atom is unknown, returns the optional unknown_tag_name which
18
  // defaults to empty (no tagname).
19
  static std::string ToString(Atom a, std::string_view unknown_tag_name = "");
20
21
 private:
22
7.13M
  inline static std::string ToString(uint32_t atom_as_int) {
23
7.13M
    return ToString(static_cast<Atom>(atom_as_int));
24
7.13M
  }
25
26
7.12M
  inline static Atom CastToAtom(uint32_t atom_as_int) {
27
7.12M
    return static_cast<Atom>(atom_as_int);
28
7.12M
  }
29
30
  // No instances of this class.
31
  AtomUtil() = delete;
32
};
33
34
}  // namespace htmlparser
35
36
#endif  // CPP_HTMLPARSER_ATOMUTIL_H_