1 | /** |
2 | * sass2scss |
3 | * Licensed under the MIT License |
4 | * Copyright (c) Marcel Greter |
5 | */ |
6 | |
7 | #ifndef SASS2SCSS_H |
8 | #define SASS2SCSS_H |
9 | |
10 | #ifdef _WIN32 |
11 | |
12 | /* You should define ADD_EXPORTS *only* when building the DLL. */ |
13 | #ifdef ADD_EXPORTS |
14 | #define ADDAPI __declspec(dllexport) |
15 | #define ADDCALL __cdecl |
16 | #else |
17 | #define ADDAPI |
18 | #define ADDCALL |
19 | #endif |
20 | |
21 | #else /* _WIN32 not defined. */ |
22 | |
23 | /* Define with no value on non-Windows OSes. */ |
24 | #define ADDAPI |
25 | #define ADDCALL |
26 | |
27 | #endif |
28 | |
29 | #ifdef __cplusplus |
30 | |
31 | #include <stack> |
32 | #include <string> |
33 | #include <cstring> |
34 | #include <sstream> |
35 | #include <iostream> |
36 | |
37 | #ifndef SASS2SCSS_VERSION |
38 | // Hardcode once the file is copied from |
39 | // https://github.com/mgreter/sass2scss |
40 | #define SASS2SCSS_VERSION "1.1.1" |
41 | #endif |
42 | |
43 | // add namespace for c++ |
44 | namespace Sass |
45 | { |
46 | |
47 | // pretty print options |
48 | const int SASS2SCSS_PRETTIFY_0 = 0; |
49 | const int SASS2SCSS_PRETTIFY_1 = 1; |
50 | const int SASS2SCSS_PRETTIFY_2 = 2; |
51 | const int SASS2SCSS_PRETTIFY_3 = 3; |
52 | |
53 | // remove one-line comment |
54 | const int = 32; |
55 | // remove multi-line comments |
56 | const int = 64; |
57 | // convert one-line to multi-line |
58 | const int = 128; |
59 | |
60 | // String for finding something interesting |
61 | const std::string SASS2SCSS_FIND_WHITESPACE = " \t\n\v\f\r" ; |
62 | |
63 | // converter struct |
64 | // holding all states |
65 | struct converter |
66 | { |
67 | // bit options |
68 | int options; |
69 | // is selector |
70 | bool selector; |
71 | // concat lists |
72 | bool comma; |
73 | // has property |
74 | bool property; |
75 | // has semicolon |
76 | bool semicolon; |
77 | // comment context |
78 | std::string ; |
79 | // flag end of file |
80 | bool end_of_file; |
81 | // whitespace buffer |
82 | std::string whitespace; |
83 | // context/block stack |
84 | std::stack<std::string> indents; |
85 | }; |
86 | |
87 | // function only available in c++ code |
88 | char* sass2scss (const std::string& sass, const int options); |
89 | |
90 | } |
91 | // EO namespace |
92 | |
93 | // declare for c |
94 | extern "C" { |
95 | #endif |
96 | |
97 | // prettyfy print options |
98 | #define SASS2SCSS_PRETTIFY_0 0 |
99 | #define SASS2SCSS_PRETTIFY_1 1 |
100 | #define SASS2SCSS_PRETTIFY_2 2 |
101 | #define SASS2SCSS_PRETTIFY_3 3 |
102 | |
103 | // keep one-line comments |
104 | #define 32 |
105 | // remove multi-line comments |
106 | #define 64 |
107 | // convert one-line to multi-line |
108 | #define 128 |
109 | |
110 | // available to c and c++ code |
111 | ADDAPI char* ADDCALL sass2scss (const char* sass, const int options); |
112 | |
113 | // Get compiled sass2scss version |
114 | ADDAPI const char* ADDCALL sass2scss_version(void); |
115 | |
116 | #ifdef __cplusplus |
117 | } // __cplusplus defined. |
118 | #endif |
119 | |
120 | #endif |