xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
web
css
css_writer.hpp
Go to the documentation of this file.
1
4
#pragma once
5
#include "
selector_dictionary.hpp
"
6
#include "
../../io/stream_writer.hpp
"
7
#include "
../../object.hpp
"
8
10
namespace
xtd
{
11
namespace
web
{
12
namespace
css {
13
class
css_writer :
public
object
{
14
public
:
16
18
css_writer(std::ostream& stream) : text_writer_(
new
xtd::io::stream_writer
(stream)) {}
19
css_writer(
xtd::io::text_writer
& text_writer) : text_writer_(&text_writer), delete_when_destroy_(
false
) {}
20
css_writer(
const
xtd::string
&
path
) : text_writer_(
new
xtd::io::stream_writer
(
path
)) {}
23
~css_writer() {
if
(delete_when_destroy_)
delete
text_writer_;}
25
27
29
[[nodiscard]]
auto
selectors()
const
noexcept
->
const
xtd::web::css::selector_dictionary
& {
return
selectors_;}
30
[[nodiscard]]
auto
selectors()
noexcept
->
xtd::web::css::selector_dictionary
& {
return
selectors_;}
31
auto
selectors(
const
xtd::web::css::selector_dictionary
&
selector
) ->
void
{selectors_ =
selector
;}
33
35
37
auto
write() ->
void
{
38
if
(!text_writer_)
return
;
39
for
(
const
auto
&
selector
: selectors_) {
40
text_writer_->write_line(
"{} {{"
,
selector
.first);
41
for
(
const
auto
&
property
:
selector
.second.properties())
42
text_writer_->write_line(
" {}: {};"
,
property
.first,
property
.second);
43
text_writer_->write_line(
"}"
);
44
}
45
}
47
48
private
:
49
xtd::web::css::selector_dictionary
selectors_;
50
xtd::io::text_writer
* text_writer_ =
nullptr
;
51
bool
delete_when_destroy_ =
true
;
52
};
53
}
54
}
55
}
xtd::io::stream_writer
Implements a xtd::io::text_writer for writing characters to a stream.
Definition
stream_writer.hpp:28
xtd::io::text_writer
Represents a writer that can write a sequential series of characters.
Definition
text_writer.hpp:36
xtd::object::object
object()=default
Create a new instance of the ultimate base class object.
xtd::web::css::property
Definition
property.hpp:14
xtd::web::css::selector
Definition
selector.hpp:12
xtd::string
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition
__string_definitions.hpp:43
xtd::uri_components::path
@ path
The xtd::uri::local_path data.
Definition
uri_components.hpp:27
xtd::web
Contains classes and interfaces that enable browser-server communication. This namespace includes the...
Definition
css_reader.hpp:12
xtd
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition
abstract_object.hpp:8
object.hpp
Contains xtd::object class.
selector_dictionary.hpp
Contains xtd::web::css::selector_dictionary alias.
xtd::web::css::selector_dictionary
xtd::collections::generic::sorted_dictionary< xtd::string, xtd::web::css::selector > selector_dictionary
Represents the dictionary of a selector name - selector pair.
Definition
selector_dictionary.hpp:13
stream_writer.hpp
Contains xtd::io::stream_writer class.
Generated on
for xtd by
Gammasoft
. All rights reserved.