librevenge_internal.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* librevenge
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
11 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
12 *
13 * For minor contributions see the git repository.
14 *
15 * Alternatively, the contents of this file may be used under the terms
16 * of the GNU Lesser General Public License Version 2.1 or later
17 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18 * applicable instead of those above.
19 */
20
21#ifndef LIBREVENGE_INTERNAL_H
22#define LIBREVENGE_INTERNAL_H
23
24#include <cstring>
25#include <limits>
26#include <string>
27
29
30#define RVNG_NUM_ELEMENTS(array) (sizeof(array) / sizeof((array)[0]))
31
32#ifdef DEBUG
33#include <stdio.h>
34
35#define RVNG_DEBUG_MSG(M) printf M
36#else
37#define RVNG_DEBUG_MSG(M)
38#endif
39
41{
42};
43
45inline std::string toCSSValue(const librevenge::RVNGString &str)
46{
47 std::string value;
48 for (const char *c = str.cstr(); *c; ++c)
49 {
50 if (!std::strchr("<>{};\"'\\", *c))
51 value += *c;
52 }
53 return value;
54}
55
56inline long saturatingAdd(long base, long offset)
57{
58 if (offset > 0 && base > (std::numeric_limits<long>::max)() - offset)
59 return (std::numeric_limits<long>::max)();
60 if (offset < 0 && base < (std::numeric_limits<long>::min)() - offset)
61 return (std::numeric_limits<long>::min)();
62 return base + offset;
63}
64
65#endif /* LIBREVENGE_INTERNAL_H */
66/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
Definition librevenge_internal.h:41
UTF-8 string.
Definition RVNGString.h:35
const char * cstr() const
Definition RVNGString.cpp:233
std::string toCSSValue(const librevenge::RVNGString &str)
returns the string without the characters that end or escape a CSS value or style block
Definition librevenge_internal.h:45
long saturatingAdd(long base, long offset)
Definition librevenge_internal.h:56

Generated for librevenge by doxygen 1.18.0