Initial commit
[yaffs-website] / node_modules / node-sass / src / libsass / src / util.hpp
1 #ifndef SASS_UTIL_H
2 #define SASS_UTIL_H
3
4 #include <vector>
5 #include <string>
6 #include <assert.h>
7 #include "sass.hpp"
8 #include "sass/base.h"
9 #include "ast_fwd_decl.hpp"
10
11 #define SASS_ASSERT(cond, msg) assert(cond && msg)
12
13 namespace Sass {
14
15   #define out_of_memory() do {            \
16       std::cerr << "Out of memory.\n";    \
17       exit(EXIT_FAILURE);                 \
18     } while (0)
19
20   double round(double val, size_t precision = 0);
21   double sass_atof(const char* str);
22   const char* safe_str(const char *, const char* = "");
23   void free_string_array(char **);
24   char **copy_strings(const std::vector<std::string>&, char ***, int = 0);
25   std::string read_css_string(const std::string& str);
26   std::string evacuate_escapes(const std::string& str);
27   std::string string_to_output(const std::string& str);
28   std::string comment_to_string(const std::string& text);
29   void newline_to_space(std::string& str);
30
31   std::string quote(const std::string&, char q = 0);
32   std::string unquote(const std::string&, char* q = 0, bool keep_utf8_sequences = false, bool strict = true);
33   char detect_best_quotemark(const char* s, char qm = '"');
34
35   bool is_hex_doublet(double n);
36   bool is_color_doublet(double r, double g, double b);
37
38   bool peek_linefeed(const char* start);
39
40   namespace Util {
41
42     std::string rtrim(const std::string& str);
43
44     std::string normalize_underscores(const std::string& str);
45     std::string normalize_decimals(const std::string& str);
46
47     bool isPrintable(Ruleset_Ptr r, Sass_Output_Style style = NESTED);
48     bool isPrintable(Supports_Block_Ptr r, Sass_Output_Style style = NESTED);
49     bool isPrintable(Media_Block_Ptr r, Sass_Output_Style style = NESTED);
50     bool isPrintable(Comment_Ptr b, Sass_Output_Style style = NESTED);
51     bool isPrintable(Block_Obj b, Sass_Output_Style style = NESTED);
52     bool isPrintable(String_Constant_Ptr s, Sass_Output_Style style = NESTED);
53     bool isPrintable(String_Quoted_Ptr s, Sass_Output_Style style = NESTED);
54     bool isPrintable(Declaration_Ptr d, Sass_Output_Style style = NESTED);
55     bool isAscii(const char chr);
56
57   }
58 }
59 #endif