mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 07:27:23 +01:00
fixes for C++11/14
This commit is contained in:
parent
d39042ba77
commit
450089d5e6
@ -40,7 +40,12 @@ public:
|
|||||||
typedef std::vector<EnumValue*> Values;
|
typedef std::vector<EnumValue*> Values;
|
||||||
typedef Values::const_iterator Iterator;
|
typedef Values::const_iterator Iterator;
|
||||||
|
|
||||||
Enum(const std::string& name, NameSpace* pNameSpace);
|
enum Flags
|
||||||
|
{
|
||||||
|
ENUM_IS_CLASS = 0x01 // C++11 enum class
|
||||||
|
};
|
||||||
|
|
||||||
|
Enum(const std::string& name, NameSpace* pNameSpace, int flags = 0);
|
||||||
/// Creates the Enum.
|
/// Creates the Enum.
|
||||||
///
|
///
|
||||||
/// If name is the empty string, an internal name
|
/// If name is the empty string, an internal name
|
||||||
@ -59,6 +64,8 @@ public:
|
|||||||
Iterator end() const;
|
Iterator end() const;
|
||||||
/// Returns an iterator for iterating over the Enum's EnumValue's.
|
/// Returns an iterator for iterating over the Enum's EnumValue's.
|
||||||
|
|
||||||
|
int flags() const;
|
||||||
|
|
||||||
Symbol::Kind kind() const;
|
Symbol::Kind kind() const;
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
@ -67,10 +74,20 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Values _values;
|
Values _values;
|
||||||
|
int _flags;
|
||||||
static int _count;
|
static int _count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// inlines
|
||||||
|
//
|
||||||
|
inline int Enum::flags() const
|
||||||
|
{
|
||||||
|
return _flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::CppParser
|
} } // namespace Poco::CppParser
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,8 +28,9 @@ namespace CppParser {
|
|||||||
int Enum::_count = 0;
|
int Enum::_count = 0;
|
||||||
|
|
||||||
|
|
||||||
Enum::Enum(const std::string& name, NameSpace* pNameSpace):
|
Enum::Enum(const std::string& name, NameSpace* pNameSpace, int flags):
|
||||||
Symbol(processName(name), pNameSpace)
|
Symbol(processName(name), pNameSpace),
|
||||||
|
_flags(flags)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,6 +287,7 @@ const Token* Parser::parseClass(const Token* pNext, std::string& decl)
|
|||||||
else
|
else
|
||||||
syntaxError("class/struct name");
|
syntaxError("class/struct name");
|
||||||
pNext = next();
|
pNext = next();
|
||||||
|
|
||||||
bool isFinal = false;
|
bool isFinal = false;
|
||||||
if (isIdentifier(pNext) && pNext->asString() == "final")
|
if (isIdentifier(pNext) && pNext->asString() == "final")
|
||||||
{
|
{
|
||||||
@ -398,6 +399,9 @@ const Token* Parser::parseClassMembers(const Token* pNext, Struct* /*pClass*/)
|
|||||||
case IdentifierToken::KW_TYPEDEF:
|
case IdentifierToken::KW_TYPEDEF:
|
||||||
pNext = parseTypeDef(pNext);
|
pNext = parseTypeDef(pNext);
|
||||||
break;
|
break;
|
||||||
|
case IdentifierToken::KW_USING:
|
||||||
|
pNext = parseUsing(pNext);
|
||||||
|
break;
|
||||||
case IdentifierToken::KW_ENUM:
|
case IdentifierToken::KW_ENUM:
|
||||||
pNext = parseEnum(pNext);
|
pNext = parseEnum(pNext);
|
||||||
break;
|
break;
|
||||||
@ -463,6 +467,8 @@ const Token* Parser::parseTemplateArgs(const Token* pNext, std::string& decl)
|
|||||||
++depth;
|
++depth;
|
||||||
else if (isOperator(pNext, OperatorToken::OP_GT))
|
else if (isOperator(pNext, OperatorToken::OP_GT))
|
||||||
--depth;
|
--depth;
|
||||||
|
else if (isOperator(pNext, OperatorToken::OP_SHR))
|
||||||
|
depth -= 2;
|
||||||
pNext = next();
|
pNext = next();
|
||||||
}
|
}
|
||||||
return pNext;
|
return pNext;
|
||||||
@ -483,6 +489,7 @@ const Token* Parser::parseTypeDef(const Token* pNext)
|
|||||||
}
|
}
|
||||||
TypeDef* pTypeDef = new TypeDef(decl, currentNameSpace());
|
TypeDef* pTypeDef = new TypeDef(decl, currentNameSpace());
|
||||||
addSymbol(pTypeDef, line);
|
addSymbol(pTypeDef, line);
|
||||||
|
|
||||||
pNext = next();
|
pNext = next();
|
||||||
_pCurrentSymbol = 0;
|
_pCurrentSymbol = 0;
|
||||||
return pNext;
|
return pNext;
|
||||||
@ -762,6 +769,8 @@ const Token* Parser::parseParameters(const Token* pNext, Function* pFunc)
|
|||||||
++tdepth;
|
++tdepth;
|
||||||
else if (isOperator(pNext, OperatorToken::OP_GT))
|
else if (isOperator(pNext, OperatorToken::OP_GT))
|
||||||
--tdepth;
|
--tdepth;
|
||||||
|
else if (isOperator(pNext, OperatorToken::OP_SHR))
|
||||||
|
tdepth -= 2;
|
||||||
pNext = next();
|
pNext = next();
|
||||||
}
|
}
|
||||||
if (isOperator(pNext, OperatorToken::OP_COMMA))
|
if (isOperator(pNext, OperatorToken::OP_COMMA))
|
||||||
@ -795,9 +804,17 @@ const Token* Parser::parseEnum(const Token* pNext)
|
|||||||
{
|
{
|
||||||
poco_assert (isKeyword(pNext, IdentifierToken::KW_ENUM));
|
poco_assert (isKeyword(pNext, IdentifierToken::KW_ENUM));
|
||||||
|
|
||||||
|
int flags = 0;
|
||||||
_pCurrentSymbol = 0;
|
_pCurrentSymbol = 0;
|
||||||
int line = _istr.getCurrentLineNumber();
|
int line = _istr.getCurrentLineNumber();
|
||||||
pNext = next();
|
pNext = next();
|
||||||
|
|
||||||
|
if (isKeyword(pNext, IdentifierToken::KW_CLASS))
|
||||||
|
{
|
||||||
|
flags = Enum::ENUM_IS_CLASS;
|
||||||
|
pNext = next();
|
||||||
|
}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
if (pNext->is(Token::IDENTIFIER_TOKEN))
|
if (pNext->is(Token::IDENTIFIER_TOKEN))
|
||||||
{
|
{
|
||||||
@ -805,7 +822,7 @@ const Token* Parser::parseEnum(const Token* pNext)
|
|||||||
pNext = next();
|
pNext = next();
|
||||||
}
|
}
|
||||||
expectOperator(pNext, OperatorToken::OP_OPENBRACE, "{");
|
expectOperator(pNext, OperatorToken::OP_OPENBRACE, "{");
|
||||||
Enum* pEnum = new Enum(name, currentNameSpace());
|
Enum* pEnum = new Enum(name, currentNameSpace(), flags);
|
||||||
addSymbol(pEnum, line);
|
addSymbol(pEnum, line);
|
||||||
pNext = next();
|
pNext = next();
|
||||||
while (pNext->is(Token::IDENTIFIER_TOKEN))
|
while (pNext->is(Token::IDENTIFIER_TOKEN))
|
||||||
|
@ -80,6 +80,7 @@ std::string TypeAlias::baseType() const
|
|||||||
std::string::size_type pos = 0;
|
std::string::size_type pos = 0;
|
||||||
while (pos < decl.size() && std::isspace(decl[pos])) pos++;
|
while (pos < decl.size() && std::isspace(decl[pos])) pos++;
|
||||||
while (pos < decl.size() && decl[pos] != '=') pos++;
|
while (pos < decl.size() && decl[pos] != '=') pos++;
|
||||||
|
if (pos < decl.size() && decl[pos] == '=') pos++;
|
||||||
decl.erase(0, pos);
|
decl.erase(0, pos);
|
||||||
Poco::trimInPlace(decl);
|
Poco::trimInPlace(decl);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user