Current Version: 1.0.10
Project Name: csspp
assembler.h
Go to the documentation of this file.
1 #ifndef CSSPP_ASSEMBLER_H
2 #define CSSPP_ASSEMBLER_H
3 // CSS Preprocessor
4 // Copyright (C) 2015-2016 Made to Order Software Corp.
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #include "csspp/node.h"
21 
22 namespace csspp
23 {
24 
25 enum class output_mode_t
26 {
27  COMPACT, // one rule per line, spaces around all objects
28  COMPRESSED, // as compressed as possible
29  EXPANDED, // beautified for human consumption
30  TIDY // one rule per line, no spaces
31 };
32 
33 class assembler_impl;
34 
35 class assembler
36 {
37 public:
38  assembler(std::ostream & out);
39 
40  void output(node::pointer_t n, output_mode_t mode);
41 
42 private:
43  std::string escape_id(std::string const & id);
44 
45  void output(node::pointer_t n);
47  void output_parenthesis(node::pointer_t n, int flags);
50  void output_string(std::string const & str);
51  void output_url(std::string const & str);
52 
53  std::shared_ptr<assembler_impl> f_impl;
54  std::ostream & f_out;
56 };
57 
58 } // namespace csspp
59 
60 std::ostream & operator << (std::ostream & out, csspp::output_mode_t const type);
61 
62 #endif
63 // #ifndef CSSPP_ASSEMBLER_H
64 
65 // Local Variables:
66 // mode: cpp
67 // indent-tabs-mode: nil
68 // c-basic-offset: 4
69 // tab-width: 4
70 // End:
71 
72 // vim: ts=4 sw=4 et
std::shared_ptr< node > pointer_t
Definition: node.h:122
void output_string(std::string const &str)
Definition: assembler.cpp:874
void output_url(std::string const &str)
Definition: assembler.cpp:928
void output_component_value(node::pointer_t n)
Definition: assembler.cpp:677
std::shared_ptr< assembler_impl > f_impl
Definition: assembler.h:53
std::ostream & f_out
Definition: assembler.h:54
output_mode_t
Definition: assembler.h:25
assembler(std::ostream &out)
Definition: assembler.cpp:247
void output(node::pointer_t n, output_mode_t mode)
Definition: assembler.cpp:327
void output_at_keyword(node::pointer_t n)
Definition: assembler.cpp:752
std::ostream & operator<<(std::ostream &out, csspp::output_mode_t const type)
Definition: assembler.cpp:971
std::string escape_id(std::string const &id)
Definition: assembler.cpp:252
node::pointer_t f_root
Definition: assembler.h:55
void output_parenthesis(node::pointer_t n, int flags)
Definition: assembler.cpp:719
void output_comment(node::pointer_t n)
Definition: assembler.cpp:816

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.