Blame src/emitter.hpp

Packit Service 7770af
#ifndef SASS_EMITTER_H
Packit Service 7770af
#define SASS_EMITTER_H
Packit Service 7770af
Packit Service 7770af
#include <string>
Packit Service 7770af
#include "sass.hpp"
Packit Service 7770af
#include "sass/base.h"
Packit Service 7770af
#include "source_map.hpp"
Packit Service 7770af
#include "ast_fwd_decl.hpp"
Packit Service 7770af
Packit Service 7770af
namespace Sass {
Packit Service 7770af
  class Context;
Packit Service 7770af
Packit Service 7770af
  class Emitter {
Packit Service 7770af
Packit Service 7770af
    public:
Packit Service 7770af
      Emitter(struct Sass_Output_Options& opt);
Packit Service 7770af
      virtual ~Emitter() { }
Packit Service 7770af
Packit Service 7770af
    protected:
Packit Service 7770af
      OutputBuffer wbuf;
Packit Service 7770af
    public:
Packit Service 7770af
      const std::string& buffer(void) { return wbuf.buffer; }
Packit Service 7770af
      const SourceMap smap(void) { return wbuf.smap; }
Packit Service 7770af
      const OutputBuffer output(void) { return wbuf; }
Packit Service 7770af
      // proxy methods for source maps
Packit Service 7770af
      void add_source_index(size_t idx);
Packit Service 7770af
      void set_filename(const std::string& str);
Packit Service 7770af
      void add_open_mapping(const AST_Node_Ptr node);
Packit Service 7770af
      void add_close_mapping(const AST_Node_Ptr node);
Packit Service 7770af
      void schedule_mapping(const AST_Node_Ptr node);
Packit Service 7770af
      std::string render_srcmap(Context &ctx;;
Packit Service 7770af
      ParserState remap(const ParserState& pstate);
Packit Service 7770af
Packit Service 7770af
    public:
Packit Service 7770af
      struct Sass_Output_Options& opt;
Packit Service 7770af
      size_t indentation;
Packit Service 7770af
      size_t scheduled_space;
Packit Service 7770af
      size_t scheduled_linefeed;
Packit Service 7770af
      bool scheduled_delimiter;
Packit Service 7770af
      AST_Node_Ptr scheduled_mapping;
Packit Service 7770af
Packit Service 7770af
    public:
Packit Service 7770af
      // output strings different in comments
Packit Service 7770af
      bool in_comment;
Packit Service 7770af
      // selector list does not get linefeeds
Packit Service 7770af
      bool in_wrapped;
Packit Service 7770af
      // lists always get a space after delimiter
Packit Service 7770af
      bool in_media_block;
Packit Service 7770af
      // nested list must not have parentheses
Packit Service 7770af
      bool in_declaration;
Packit Service 7770af
      // nested lists need parentheses
Packit Service 7770af
      bool in_space_array;
Packit Service 7770af
      bool in_comma_array;
Packit Service 7770af
Packit Service 7770af
    public:
Packit Service 7770af
      // return buffer as std::string
Packit Service 7770af
      std::string get_buffer(void);
Packit Service 7770af
      // flush scheduled space/linefeed
Packit Service 7770af
      Sass_Output_Style output_style(void) const;
Packit Service 7770af
      // add outstanding linefeed
Packit Service 7770af
      void finalize(bool final = true);
Packit Service 7770af
      // flush scheduled space/linefeed
Packit Service 7770af
      void flush_schedules(void);
Packit Service 7770af
      // prepend some text or token to the buffer
Packit Service 7770af
      void prepend_string(const std::string& text);
Packit Service 7770af
      void prepend_output(const OutputBuffer& out);
Packit Service 7770af
      // append some text or token to the buffer
Packit Service 7770af
      void append_string(const std::string& text);
Packit Service 7770af
      // append some white-space only text
Packit Service 7770af
      void append_wspace(const std::string& text);
Packit Service 7770af
      // append some text or token to the buffer
Packit Service 7770af
      // this adds source-mappings for node start and end
Packit Service 7770af
      void append_token(const std::string& text, const AST_Node_Ptr node);
Packit Service 7770af
Packit Service 7770af
    public: // syntax sugar
Packit Service 7770af
      void append_indentation();
Packit Service 7770af
      void append_optional_space(void);
Packit Service 7770af
      void append_mandatory_space(void);
Packit Service 7770af
      void append_special_linefeed(void);
Packit Service 7770af
      void append_optional_linefeed(void);
Packit Service 7770af
      void append_mandatory_linefeed(void);
Packit Service 7770af
      void append_scope_opener(AST_Node_Ptr node = 0);
Packit Service 7770af
      void append_scope_closer(AST_Node_Ptr node = 0);
Packit Service 7770af
      void append_comma_separator(void);
Packit Service 7770af
      void append_colon_separator(void);
Packit Service 7770af
      void append_delimiter(void);
Packit Service 7770af
Packit Service 7770af
  };
Packit Service 7770af
Packit Service 7770af
}
Packit Service 7770af
Packit Service 7770af
#endif