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

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.