Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Char.h
1 /*
2  * Char class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2016, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef ELM_STRING_CHAR_H_
22 #define ELM_STRING_CHAR_H_
23 
24 namespace elm {
25 
26 class Char {
27 public:
28  inline Char(void): c('\0') { }
29  inline Char(char ch): c(ch) { }
30  inline operator char(void) const { return c; }
31  inline Char& operator=(char ch) { c = ch; return *this; }
32  inline Char& operator=(Char ch) { c = ch.c; return *this; }
33 
34  inline int compare(char cc) const { return (unsigned char)c - (unsigned char)cc; }
35  inline int compare(Char ch) const { return (unsigned char)c - (unsigned char)ch.c; }
36 
37  static Char bin(int v);
38  static Char dec(int v);
39  inline static Char hex(int v) { return lowerHex(v); }
40  static Char lowerHex(int v);
41  static Char upperHex(int v);
42 
43  bool isBin(void) const;
44  bool isDec(void) const;
45  bool isHex(void) const;
46  bool isSpace(void) const;
47  bool isPrintable(void) const;
48  bool isLetter(void) const;
49  bool isLowerCase(void) const;
50  bool isUpperCase(void) const;
51 
52  int asBin(void) const;
53  int asDec(void) const;
54  int asHex(void) const;
55 
56  inline bool operator==(char ch) { return compare(ch) == 0; }
57  inline bool operator!=(char ch) { return compare(ch) != 0; }
58  inline bool operator<(char ch) { return compare(ch) < 0; }
59  inline bool operator<=(char ch) { return compare(ch) <= 0; }
60  inline bool operator>(char ch) { return compare(ch) > 0; }
61  inline bool operator>=(char ch) { return compare(ch) >= 0; }
62 
63  inline bool operator==(Char ch) { return compare(ch) == 0; }
64  inline bool operator!=(Char ch) { return compare(ch) != 0; }
65  inline bool operator<(Char ch) { return compare(ch) < 0; }
66  inline bool operator<=(Char ch) { return compare(ch) <= 0; }
67  inline bool operator>(Char ch) { return compare(ch) > 0; }
68  inline bool operator>=(Char ch) { return compare(ch) >= 0; }
69 
70 private:
71  char c;
72 };
73 
74 } // elm
75 
76 #endif /* ELM_STRING_CHAR_H_ */
elm::Char::compare
int compare(Char ch) const
Definition: Char.h:35
elm::Char::operator==
bool operator==(char ch)
Definition: Char.h:56
elm::Char::Char
Char(char ch)
Definition: Char.h:29
elm::Char::operator<
bool operator<(Char ch)
Definition: Char.h:65
elm::Char::compare
int compare(char cc) const
Definition: Char.h:34
elm::Char::isUpperCase
bool isUpperCase(void) const
Definition: string_Char.cpp:173
elm::Char::lowerHex
static Char lowerHex(int v)
Definition: string_Char.cpp:83
elm::Char::operator!=
bool operator!=(Char ch)
Definition: Char.h:64
elm::Char::operator=
Char & operator=(char ch)
Definition: Char.h:31
elm::Char::Char
Char(void)
Definition: Char.h:28
elm::Char::bin
static Char bin(int v)
Definition: string_Char.cpp:53
elm::Char::asDec
int asDec(void) const
Definition: string_Char.cpp:196
elm::Char::asHex
int asHex(void) const
Definition: string_Char.cpp:208
elm::Char::operator>=
bool operator>=(Char ch)
Definition: Char.h:68
elm::Char::operator>
bool operator>(char ch)
Definition: Char.h:60
elm::Char::isSpace
bool isSpace(void) const
Definition: string_Char.cpp:137
elm::Char::upperHex
static Char upperHex(int v)
Definition: string_Char.cpp:97
elm::Char::dec
static Char dec(int v)
Definition: string_Char.cpp:64
elm::Char::operator<
bool operator<(char ch)
Definition: Char.h:58
elm::Char::operator!=
bool operator!=(char ch)
Definition: Char.h:57
elm::Char::hex
static Char hex(int v)
Definition: Char.h:39
elm::Char::operator=
Char & operator=(Char ch)
Definition: Char.h:32
elm::Char::isPrintable
bool isPrintable(void) const
Definition: string_Char.cpp:146
elm::Char::asBin
int asBin(void) const
Definition: string_Char.cpp:182
elm
Definition: adapter.h:26
elm::Char::operator<=
bool operator<=(Char ch)
Definition: Char.h:66
elm::Char::isDec
bool isDec(void) const
Definition: string_Char.cpp:119
elm::Char::operator<=
bool operator<=(char ch)
Definition: Char.h:59
elm::Char::operator==
bool operator==(Char ch)
Definition: Char.h:63
elm::Char::operator>
bool operator>(Char ch)
Definition: Char.h:67
elm::Char::isLetter
bool isLetter(void) const
Definition: string_Char.cpp:155
elm::Char::isLowerCase
bool isLowerCase(void) const
Definition: string_Char.cpp:164
elm::Char::isHex
bool isHex(void) const
Definition: string_Char.cpp:128
Char
Definition: Char.py:1
elm::Char::isBin
bool isBin(void) const
Definition: string_Char.cpp:110
elm::Char::operator>=
bool operator>=(char ch)
Definition: Char.h:61