1#ifndef SASS_EMITTER_H
2#define SASS_EMITTER_H
3
4// sass.hpp must go before all system headers to get the
5// __EXTENSIONS__ fix on Solaris.
6#include "sass.hpp"
7
8#include "sass/base.h"
9#include "source_map.hpp"
10#include "ast_fwd_decl.hpp"
11
12namespace Sass {
13 class Context;
14
15 class Emitter {
16
17 public:
18 Emitter(struct Sass_Output_Options& opt);
19 virtual ~Emitter() { }
20
21 protected:
22 OutputBuffer wbuf;
23 public:
24 const sass::string& buffer(void) { return wbuf.buffer; }
25 const SourceMap smap(void) { return wbuf.smap; }
26 const OutputBuffer output(void) { return wbuf; }
27 // proxy methods for source maps
28 void add_source_index(size_t idx);
29 void set_filename(const sass::string& str);
30 void add_open_mapping(const AST_Node* node);
31 void add_close_mapping(const AST_Node* node);
32 void schedule_mapping(const AST_Node* node);
33 sass::string render_srcmap(Context &ctx);
34 SourceSpan remap(const SourceSpan& pstate);
35
36 public:
37 struct Sass_Output_Options& opt;
38 size_t indentation;
39 size_t scheduled_space;
40 size_t scheduled_linefeed;
41 bool scheduled_delimiter;
42 const AST_Node* scheduled_crutch;
43 const AST_Node* scheduled_mapping;
44
45 public:
46 // output strings different in custom css properties
47 bool in_custom_property;
48 // output strings different in comments
49 bool in_comment;
50 // selector list does not get linefeeds
51 bool in_wrapped;
52 // lists always get a space after delimiter
53 bool in_media_block;
54 // nested list must not have parentheses
55 bool in_declaration;
56 // nested lists need parentheses
57 bool in_space_array;
58 bool in_comma_array;
59
60 public:
61 // return buffer as sass::string
62 sass::string get_buffer(void);
63 // flush scheduled space/linefeed
64 Sass_Output_Style output_style(void) const;
65 // add outstanding linefeed
66 void finalize(bool final = true);
67 // flush scheduled space/linefeed
68 void flush_schedules(void);
69 // prepend some text or token to the buffer
70 void prepend_string(const sass::string& text);
71 void prepend_output(const OutputBuffer& out);
72 // append some text or token to the buffer
73 void append_string(const sass::string& text);
74 // append a single character to buffer
75 void append_char(const char chr);
76 // append some white-space only text
77 void append_wspace(const sass::string& text);
78 // append some text or token to the buffer
79 // this adds source-mappings for node start and end
80 void append_token(const sass::string& text, const AST_Node* node);
81 // query last appended character
82 char last_char();
83
84 public: // syntax sugar
85 void append_indentation();
86 void append_optional_space(void);
87 void append_mandatory_space(void);
88 void append_special_linefeed(void);
89 void append_optional_linefeed(void);
90 void append_mandatory_linefeed(void);
91 void append_scope_opener(AST_Node* node = 0);
92 void append_scope_closer(AST_Node* node = 0);
93 void append_comma_separator(void);
94 void append_colon_separator(void);
95 void append_delimiter(void);
96
97 };
98
99}
100
101#endif
102

source code of gtk/subprojects/libsass/src/emitter.hpp