5 #ifndef LITEHTML_NO_THREADS
7 static std::mutex mutex
;
8 #define lock_guard std::lock_guard<std::mutex> lock(mutex)
16 static std::map
<string
, string_id
> map
;
17 static std::vector
<string
> array
;
22 split_string(initial_string_ids
, names
, ",");
23 for (auto& name
: names
)
26 assert(name
[0] == '_' && name
.back() == '_');
27 name
= name
.substr(1, name
.size() - 2); // _border_color_ -> border_color
28 std::replace(name
.begin(), name
.end(), '_', '-'); // border_color -> border-color
29 _id(name
); // this will create association _border_color_ <-> "border-color"
33 static int dummy
= init();
35 const string_id empty_id
= _id("");
36 const string_id star_id
= _id("*");
38 string_id
_id(const string
& str
)
41 auto it
= map
.find(str
);
42 if (it
!= map
.end()) return it
->second
;
43 // else: str not found, add it to the array and the map
45 return map
[str
] = (string_id
)(array
.size() - 1);
48 const string
& _s(string_id id
)
54 } // namespace litehtml