Current Version: 1.0.20
Project Name: csspp
csspp.h
Go to the documentation of this file.
1 #ifndef CSSPP_CSSPP_H
2 #define CSSPP_CSSPP_H
3 // CSS Preprocessor
4 // Copyright (c) 2015-2018 Made to Order Software Corp. All Rights Reserved
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #include "csspp/exceptions.h"
21 
22 #include <cstdint>
23 #include <string>
24 #include <sstream>
25 
26 #ifdef __CYGWIN__
27 namespace std
28 {
29  template<typename T>
30  std::string to_string(T value)
31  {
32  std::stringstream ss;
33  ss << value;
34  return ss.str();
35  }
36 }
37 #endif
38 
39 #ifndef M_PI
40 #define M_PI 3.14159265358979323846
41 #endif
42 
43 namespace csspp
44 {
45 
46 #define CSSPP_VERSION_MAJOR 1
47 #define CSSPP_VERSION_MINOR 0
48 #define CSSPP_VERSION_PATCH 20
49 #define CSSPP_VERSION "1.0.20"
50 
51 typedef int32_t wide_char_t;
52 typedef uint32_t wide_uchar_t;
53 typedef int line_t;
54 typedef int64_t integer_t;
55 typedef double decimal_number_t;
56 
57 char const * csspp_library_version();
58 int get_precision();
59 void set_precision(int precision);
60 std::string decimal_number_to_string(decimal_number_t d, bool remove_leading_zero);
61 
63 {
64 public:
65  safe_bool_t(bool & flag)
66  : f_flag(flag)
67  , f_old_value(flag)
68  {
69  f_flag = true;
70  }
71 
72  safe_bool_t(bool & flag, bool new_value)
73  : f_flag(flag)
74  , f_old_value(flag)
75  {
76  f_flag = new_value;
77  }
78 
80  {
81  f_flag = f_old_value;
82  }
83 
84 private:
85  bool & f_flag;
86  bool f_old_value = false;
87 };
88 
90 {
91 public:
93  : f_precision(get_precision())
94  {
95  }
96 
97  safe_precision_t(int precision)
98  : f_precision(get_precision())
99  {
100  set_precision(precision);
101  }
102 
104  {
105  try
106  {
107  set_precision(f_precision);
108  }
109  catch(csspp_exception_overflow const &)
110  {
111  }
112  }
113 
114 private:
115  int f_precision = 0;
116 };
117 
118 } // namespace csspp
119 #endif
120 // #ifndef CSSPP_CSSPP_H
121 
122 // Local Variables:
123 // mode: cpp
124 // indent-tabs-mode: nil
125 // c-basic-offset: 4
126 // tab-width: 4
127 // End:
128 
129 // vim: ts=4 sw=4 et
int32_t wide_char_t
Definition: csspp.h:51
std::string decimal_number_to_string(decimal_number_t d, bool remove_leading_zero)
Definition: csspp.cpp:75
int64_t integer_t
Definition: csspp.h:54
The namespace of all the classes in the CSS Preprocessor.
Definition: assembler.cpp:40
safe_bool_t(bool &flag)
Definition: csspp.h:65
int line_t
Definition: position.h:27
int get_precision()
Definition: csspp.cpp:60
void set_precision(int precision)
Definition: csspp.cpp:65
char const * csspp_library_version()
Definition: csspp.cpp:55
safe_precision_t(int precision)
Definition: csspp.h:97
uint32_t wide_uchar_t
Definition: csspp.h:52
safe_bool_t(bool &flag, bool new_value)
Definition: csspp.h:72
double decimal_number_t
Definition: csspp.h:55
bool & f_flag
Definition: csspp.h:85

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.