Initial commit
[yaffs-website] / node_modules / node-sass / src / libsass / src / source_map.hpp
1 #ifndef SASS_SOURCE_MAP_H
2 #define SASS_SOURCE_MAP_H
3
4 #include <string>
5 #include <vector>
6
7 #include "ast_fwd_decl.hpp"
8 #include "base64vlq.hpp"
9 #include "position.hpp"
10 #include "mapping.hpp"
11
12 #define VECTOR_PUSH(vec, ins) vec.insert(vec.end(), ins.begin(), ins.end())
13 #define VECTOR_UNSHIFT(vec, ins) vec.insert(vec.begin(), ins.begin(), ins.end())
14
15 namespace Sass {
16
17   class Context;
18   class OutputBuffer;
19
20   class SourceMap {
21
22   public:
23     std::vector<size_t> source_index;
24     SourceMap();
25     SourceMap(const std::string& file);
26
27     void append(const Offset& offset);
28     void prepend(const Offset& offset);
29     void append(const OutputBuffer& out);
30     void prepend(const OutputBuffer& out);
31     void add_open_mapping(const AST_Node_Ptr node);
32     void add_close_mapping(const AST_Node_Ptr node);
33
34     std::string render_srcmap(Context &ctx);
35     ParserState remap(const ParserState& pstate);
36
37   private:
38
39     std::string serialize_mappings();
40
41     std::vector<Mapping> mappings;
42     Position current_position;
43 public:
44     std::string file;
45 private:
46     Base64VLQ base64vlq;
47   };
48
49   class OutputBuffer {
50     public:
51       OutputBuffer(void)
52       : buffer(""),
53         smap()
54       { }
55     public:
56       std::string buffer;
57       SourceMap smap;
58   };
59
60 }
61
62 #endif