6 #include "../..//io/stream_reader.h" 7 #include "../../argument_exception.h" 8 #include "../../format_exception.h" 9 #include "../../object.h" 34 enum class parse_status {
39 parse_status status = parse_status::selector;
40 size_t start_index = 0;
44 for (
size_t index = 0; index < text.size(); index++) {
45 if (text[index] ==
'/' && text[index + 1] ==
'*') {
47 index = text.
index_of(
"*/", index + 2);
50 start_index = index + 1;
52 }
else if (status == parse_status::selector && text[index] ==
'{') {
53 current_selector_name = text.
substring(start_index, index - start_index).
trim();
54 current_selector.name(text.
substring(start_index, index - start_index).
trim());
55 start_index = index + 1;
56 status = parse_status::key;
57 }
else if (status == parse_status::key && text[index] ==
'}') {
58 selectors_[current_selector_name] = current_selector;
60 start_index = index + 1;
61 status = parse_status::selector;
62 }
else if (status == parse_status::key && text[index] ==
':') {
65 start_index = index + 1;
66 status = parse_status::value;
67 }
else if (status == parse_status::value && text[index] ==
';') {
68 auto value = text.
substring(start_index, index - start_index).
trim();
70 start_index = index + 1;
71 current_selector.properties()[current_key] =
property(value);
72 status = parse_status::key;
size_t index_of(value_type value) const noexcept
Reports the index of the first occurrence of the specified character in this string.
Definition: property.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
virtual xtd::ustring read_to_end()
Reads all characters from the current position to the end of the text_reader and returns them as one ...
Implements a xtd::io::text_reader that reads characters from a byte stream.
Definition: stream_reader.h:26
#define csf_
Provides information about the current stack frame.
Definition: current_stack_frame.h:30
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
ustring substring(size_t start_index) const noexcept
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Definition: css_reader.h:16
ustring trim() const noexcept
Removes all leading and trailing occurrences of white-space characters from the specified xtd::ustrin...
ustring to_lower() const noexcept
Returns a copy of the current string converted to lowercase.
Contains xtd::web::css::selector_map alias.
Represents a reader that can read a sequential series of characters.
Definition: text_reader.h:34
std::map< xtd::ustring, xtd::web::css::selector > selector_map
Represents the map of a selector name - selector pair.
Definition: selector_map.h:13
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
Definition: selector.h:12