Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FormatPrivate.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * FormatPrivate.h
17  * Private implementations of the formatting functions from Format.h
18  * Copyright (C) 2005 Simon Newton
19  */
20 
26 #ifndef INCLUDE_OLA_STRINGS_FORMATPRIVATE_H_
27 #define INCLUDE_OLA_STRINGS_FORMATPRIVATE_H_
28 
29 #include <stdint.h>
30 #include <iomanip>
31 #include <iostream>
32 #include <limits>
33 #include <ostream>
34 #include <sstream>
35 
36 namespace ola {
37 namespace strings {
38 
39 /* @brief the width of a hex character in bits */
40 enum { HEX_BIT_WIDTH = 4 };
41 
42 /*
43  * Internal type used by ToHex().
44  */
45 template<typename T>
46 struct _ToHex {
47  public:
48  _ToHex(T v, int _width, bool _prefix)
49  : width(_width),
50  value(v),
51  prefix(_prefix) {
52  }
53 
54  int width; // setw takes an int
55  T value;
56  bool prefix;
57 };
58 
59 inline uint32_t _HexCast(uint8_t v) { return v; }
60 inline uint32_t _HexCast(int8_t v) { return static_cast<uint8_t>(v); }
61 inline uint16_t _HexCast(uint16_t v) { return v; }
62 inline uint16_t _HexCast(int16_t v) { return static_cast<uint16_t>(v); }
63 inline uint32_t _HexCast(uint32_t v) { return v; }
64 inline uint32_t _HexCast(int32_t v) { return static_cast<uint32_t>(v); }
65 
66 } // namespace strings
67 } // namespace ola
68 #endif // INCLUDE_OLA_STRINGS_FORMATPRIVATE_H_
Definition: FormatPrivate.h:46
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44