xtd - Reference Guide
0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Toggle main menu visibility
Home
Categories
Documentation
Namespaces
Classes
Class List
Class Index
Class Hierarchy
Files
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Modules
Pages
Loading...
Searching...
No Matches
xtd.core
include
xtd
web
css
css_writer.h
Go to the documentation of this file.
1
4
#pragma once
5
#include "
selector_map.h
"
6
#include "../../argument_exception.h"
7
#include "../../format_exception.h"
8
#include "../../object.h"
9
#include "../../io/stream_writer.h"
10
12
namespace
xtd
{
13
namespace
web {
14
namespace
css {
15
class
css_writer
:
public
object
{
16
public
:
17
css_writer
(std::ostream& stream) : text_writer_(
new
xtd::io::stream_writer
(stream)) {}
18
css_writer
(
xtd::io::text_writer
& text_writer) : text_writer_(&text_writer), delete_when_destroy_(
false
) {}
19
css_writer
(
const
xtd::ustring
& path) : text_writer_(
new
xtd::io::stream_writer
(path)) {}
20
~css_writer
() {
21
if
(delete_when_destroy_ && text_writer_)
delete
text_writer_;
22
}
23
24
const
xtd::web::css::selector_map& selectors()
const
{
return
selectors_;}
25
xtd::web::css::selector_map& selectors() {
return
selectors_;}
26
void
selectors(
const
xtd::web::css::selector_map&
selector
) {selectors_ =
selector
;}
27
28
void
write() {
29
if
(!text_writer_)
return
;
30
for
(
auto
selector
: selectors_) {
31
text_writer_->
write_line
(
"{} {{"
,
selector
.first);
32
for
(
auto
property
:
selector
.second.properties())
33
text_writer_->
write_line
(
" {}: {};"
,
property
.first,
property
.second);
34
text_writer_->
write_line
(
"}"
);
35
}
36
}
37
38
private
:
39
xtd::web::css::selector_map selectors_;
40
xtd::io::text_writer
* text_writer_ =
nullptr
;
41
bool
delete_when_destroy_ =
true
;
42
};
43
}
44
}
45
}
xtd::io::stream_writer
Implements a xtd::io::text_writer for writing characters to a stream.
Definition:
stream_writer.h:20
xtd::io::text_writer
Represents a writer that can write a sequential series of characters.
Definition:
text_writer.h:29
xtd::io::text_writer::write_line
void write_line()
Writes new line to the text stream.
xtd::object
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition:
object.h:26
xtd::ustring
Represents text as a sequence of UTF-8 code units.
Definition:
ustring.h:48
xtd::web::css::css_writer
Definition:
css_writer.h:15
xtd::web::css::property
Definition:
property.h:13
xtd::web::css::selector
Definition:
selector.h:12
xtd
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition:
system_report.h:17
selector_map.h
Contains xtd::web::css::selector_map typedef.
Generated on Sat Jan 28 2023 18:12:25 for xtd - Reference Guide by
Gammasoft
. All rights reserved.