forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeDef.cpp
More file actions
91 lines (69 loc) · 1.52 KB
/
TypeDef.cpp
File metadata and controls
91 lines (69 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// TypeDef.cpp
//
// Library: CppParser
// Package: SymbolTable
// Module: TypeDef
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/CppParser/TypeDef.h"
#include "Poco/String.h"
#include <cctype>
namespace Poco {
namespace CppParser {
TypeDef::TypeDef(const std::string& decl, NameSpace* pNameSpace):
Decl(decl, pNameSpace)
{
}
TypeDef::~TypeDef()
{
}
Symbol::Kind TypeDef::kind() const
{
return Symbol::SYM_TYPEDEF;
}
std::string TypeDef::baseType() const
{
std::string decl = declaration();
if (decl.compare(0, 7, "typedef") == 0)
{
decl.erase(0, 7);
std::string::size_type pos = decl.size() - 1;
while (pos > 0 && std::isspace(decl[pos])) pos--;
while (pos > 0 && !std::isspace(decl[pos])) pos--;
decl.resize(pos + 1);
Poco::trimInPlace(decl);
}
return decl;
}
TypeAlias::TypeAlias(const std::string& decl, NameSpace* pNameSpace):
Decl(decl, pNameSpace)
{
}
TypeAlias::~TypeAlias()
{
}
Symbol::Kind TypeAlias::kind() const
{
return Symbol::SYM_TYPEALIAS;
}
std::string TypeAlias::baseType() const
{
std::string decl = declaration();
if (decl.compare(0, 5, "using") == 0)
{
decl.erase(0, 5);
std::string::size_type pos = 0;
while (pos < decl.size() && std::isspace(decl[pos])) pos++;
while (pos < decl.size() && decl[pos] != '=') pos++;
if (pos < decl.size() && decl[pos] == '=') pos++;
decl.erase(0, pos);
Poco::trimInPlace(decl);
}
return decl;
}
} } // namespace Poco::CppParser