IDL compiler front-end library
Loading...
Searching...
No Matches
Identifier.h
Go to the documentation of this file.
1
2/*
3* Nirvana IDL front-end library.
4*
5* This is a part of the Nirvana project.
6*
7* Author: Igor Popov
8*
9* Copyright (c) 2021 Igor Popov.
10*
11* This program is free software; you can redistribute it and/or modify
12* it under the terms of the GNU Lesser General Public License as published by
13* the Free Software Foundation; either version 3 of the License, or
14* (at your option) any later version.
15*
16* This program is distributed in the hope that it will be useful,
17* but WITHOUT ANY WARRANTY; without even the implied warranty of
18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19* GNU General Public License for more details.
20*
21* You should have received a copy of the GNU Lesser General Public
22* License along with this library. If not, see <http://www.gnu.org/licenses/>.
23*
24* Send comments and/or bug reports to:
25* popov.nirvana@gmail.com
26*/
27#ifndef IDLFE_AST_IDENTIFIER_H_
28#define IDLFE_AST_IDENTIFIER_H_
29#pragma once
30
31#include <string>
32
33namespace AST {
34
36class Identifier : public std::string
37{
38public:
40 bool operator < (const Identifier& r) const noexcept;
41
44
48 Identifier (const char* s, size_t len) :
49 std::string (s, len)
50 {}
51
55 Identifier (const char* s) :
56 std::string (s)
57 {}
58
62 Identifier (std::string&& s) noexcept :
63 std::string (std::move (s))
64 {}
65
69 bool valid () const noexcept;
70
72 bool operator == (const char* s) const noexcept;
73
74 Identifier (const Identifier&) = default;
75 Identifier (Identifier&&) = default;
76 Identifier& operator = (const Identifier&) = default;
77 Identifier& operator = (Identifier&&) = default;
78
79 // Simplified tolower. We don't need to consider the locale settings.
80 static char tolower (char c)
81 {
82 return ('A' <= c && c <= 'Z') ? c + 32 : c;
83 }
84
85private:
86 static const char* const reserved_words_ [];
87};
88
90bool operator < (const Identifier& l, const char* r) noexcept;
91
93bool operator < (const char* l, const Identifier& r) noexcept;
94
95}
96
97#endif
An identifier.
Definition Identifier.h:37
Identifier(const char *s)
Definition Identifier.h:55
Identifier()
Default constructor.
Definition Identifier.h:43
bool valid() const noexcept
bool operator<(const Identifier &r) const noexcept
CORBA IDL identifiers are case-insensitive.
Identifier(const char *s, size_t len)
Definition Identifier.h:48
Identifier(std::string &&s) noexcept
Definition Identifier.h:62
Abstract Syntax Tree namespace.
Definition Array.h:34
bool operator<(const Identifier &l, const char *r) noexcept
Case-insensitive compare.