6 #include "../../argument_exception.h"
7 #include "../../format_exception.h"
8 #include "../../object.h"
9 #include "../..//io/stream_reader.h"
22 const xtd::web::css::selector_map& selectors()
const {
return selectors_;}
26 enum class parse_status {
31 parse_status status = parse_status::selector;
32 size_t start_index = 0;
36 for (
size_t index = 0; index < text.size(); index++) {
37 if (text[index] ==
'/' && text[index+1] ==
'*') {
39 index = text.
index_of(
"*/", index+2);
42 start_index = index + 1;
44 }
else if (status == parse_status::selector && text[index] ==
'{') {
45 current_selector_name = text.
substring(start_index, index - start_index).
trim();
46 current_selector.name(text.
substring(start_index, index - start_index).
trim());
47 start_index = index + 1;
48 status = parse_status::key;
49 }
else if (status == parse_status::key && text[index] ==
'}') {
50 selectors_[current_selector_name] = current_selector;
52 start_index = index + 1;
53 status = parse_status::selector;
54 }
else if (status == parse_status::key && text[index] ==
':') {
55 current_key = text.
substring(start_index, index - start_index).
trim();
57 start_index = index + 1;
58 status = parse_status::value;
59 }
else if (status == parse_status::value && text[index] ==
';') {
60 auto value = text.
substring(start_index, index - start_index).
trim();
62 start_index = index + 1;
63 current_selector.properties()[current_key] =
property(value);
64 status = parse_status::key;
69 xtd::web::css::selector_map selectors_;
Implements a xtd::io::text_reader that reads characters from a byte stream.
Definition: stream_reader.h:20
Represents a reader that can read a sequential series of characters.
Definition: text_reader.h:29
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 ...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
ustring trim() const noexcept
Removes all leading and trailing occurrences of white-space characters from the specified String.
size_t index_of(value_type value) const noexcept
Reports the index of the first occurrence of the specified character in this string.
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
Definition: property.h:13
Definition: selector.h:12
#define current_stack_frame_
Provides information about the current stack frame.
Definition: stack_frame.h:201
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::web::css::selector_map typedef.