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