ByteorderMark.h
1 /*
2  * Copyright (C) 2012 Marc Boris Duerner
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * As a special exception, you may use this file as part of a free
10  * software library without restriction. Specifically, if other files
11  * instantiate templates or use macros or inline functions from this
12  * file, or you compile this file and link it with other files to
13  * produce an executable, this file does not by itself cause the
14  * resulting executable to be covered by the GNU General Public
15  * License. This exception does not however invalidate any other
16  * reasons why the executable file might be covered by the GNU Library
17  * General Public License.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  */
28 
29 #ifndef Pt_Xml_ByteoderMark_h
30 #define Pt_Xml_ByteoderMark_h
31 
32 #include <Pt/Xml/Api.h>
33 
34 namespace Pt {
35 
36 namespace Xml {
37 
41 {
42  public:
45  enum Endianess
46  {
47  None = 0,
48  BigEndian = 1,
50  };
51 
54  enum Encoding
55  {
56  Generic = 0,
57  Unicode = 1
58  };
59 
60  public:
64  : _endianess(None)
65  , _width(1)
66  , _encoding(Generic)
67  {}
68 
71  void clear()
72  {
73  _endianess = None;
74  _width = 1;
75  _encoding = Generic;
76  }
77 
81  { return static_cast<Endianess>(_endianess); }
82 
86  { _endianess = static_cast<unsigned char>(e); }
87 
90  int width() const
91  { return _width; }
92 
95  void setWidth(unsigned char w)
96  { _width = w; }
97 
101  { return static_cast<Encoding>(_encoding); }
102 
106  { _encoding = static_cast<unsigned char>(e); }
107 
108  private:
109  unsigned char _endianess;
110  unsigned char _width;
111  unsigned char _encoding;
112 };
113 
114 } // namespace Xml
115 
116 } // namespace Pt
117 
118 #endif // Pt_Xml_ByteoderMark_h
XML byte order mark.
Definition: ByteorderMark.h:40
Encoding encoding() const
Returns the type of encoding.
Definition: ByteorderMark.h:100
void clear()
Clears all content.
Definition: ByteorderMark.h:71
Unicode encoding.
Definition: ByteorderMark.h:57
void setEndianess(Endianess e)
Sets the endianess of the document encoding.
Definition: ByteorderMark.h:85
No endianess.
Definition: ByteorderMark.h:47
ByteorderMark()
Default constructor.
Definition: ByteorderMark.h:63
void setWidth(unsigned char w)
Sets word width of the encoding.
Definition: ByteorderMark.h:95
Big endian.
Definition: ByteorderMark.h:48
Endianess endianess() const
The endianess of the document encoding.
Definition: ByteorderMark.h:80
Generic encoding.
Definition: ByteorderMark.h:56
int width() const
Returns the word width of the encoding.
Definition: ByteorderMark.h:90
void setEncoding(Encoding e)
Sets the type of encoding.
Definition: ByteorderMark.h:105
Endianess
Text encoding endianess.
Definition: ByteorderMark.h:45
Encoding
Text encoding type.
Definition: ByteorderMark.h:54
Little endian.
Definition: ByteorderMark.h:49