mirror of
				https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
				synced 2025-10-31 18:47:47 +00:00 
			
		
		
		
	add support for typed enums and deleted functions
This commit is contained in:
		| @@ -52,6 +52,13 @@ public: | |||||||
| 		/// in the form #AnonEnum<n> (where <n> is a unique integer) | 		/// in the form #AnonEnum<n> (where <n> is a unique integer) | ||||||
| 		/// will be assigned. | 		/// will be assigned. | ||||||
|  |  | ||||||
|  | 	Enum(const std::string& name, NameSpace* pNameSpace, const std::string& baseType, int flags = 0); | ||||||
|  | 		/// Creates the Enum. | ||||||
|  | 		/// | ||||||
|  | 		/// If name is the empty string, an internal name | ||||||
|  | 		/// in the form #AnonEnum<n> (where <n> is a unique integer) | ||||||
|  | 		/// will be assigned. | ||||||
|  |  | ||||||
| 	~Enum(); | 	~Enum(); | ||||||
| 		/// Destroys the Enum. | 		/// Destroys the Enum. | ||||||
|  |  | ||||||
| @@ -64,7 +71,11 @@ 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. | ||||||
| 	 | 	 | ||||||
|  | 	const std::string& baseType() const; | ||||||
|  | 		/// Returns the base type or an empty string if no base type has been specified. | ||||||
|  |  | ||||||
| 	int flags() const; | 	int flags() const; | ||||||
|  | 		/// Returns the flags. | ||||||
|  |  | ||||||
| 	Symbol::Kind kind() const; | 	Symbol::Kind kind() const; | ||||||
| 	std::string toString() const; | 	std::string toString() const; | ||||||
| @@ -74,6 +85,7 @@ protected: | |||||||
|  |  | ||||||
| private:	 | private:	 | ||||||
| 	Values _values; | 	Values _values; | ||||||
|  | 	std::string _baseType; | ||||||
| 	int _flags; | 	int _flags; | ||||||
| 	static int _count; | 	static int _count; | ||||||
| }; | }; | ||||||
| @@ -82,6 +94,12 @@ private: | |||||||
| // | // | ||||||
| // inlines | // inlines | ||||||
| // | // | ||||||
|  | inline const std::string& Enum::baseType() const | ||||||
|  | { | ||||||
|  | 	return _baseType; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| inline int Enum::flags() const | inline int Enum::flags() const | ||||||
| { | { | ||||||
| 	return _flags; | 	return _flags; | ||||||
|   | |||||||
| @@ -113,6 +113,12 @@ public: | |||||||
| 	bool isConst() const; | 	bool isConst() const; | ||||||
| 		/// Returns true iff the method is const. | 		/// Returns true iff the method is const. | ||||||
| 		 | 		 | ||||||
|  | 	bool isDefault() const; | ||||||
|  | 		/// Returns true iff the method has a default implementation. | ||||||
|  |  | ||||||
|  | 	bool isDeleted() const; | ||||||
|  | 		/// Returns true iff the method has been deleted. | ||||||
|  |  | ||||||
| 	int countParameters() const; | 	int countParameters() const; | ||||||
| 		/// Returns the number of parameters. | 		/// Returns the number of parameters. | ||||||
| 	 | 	 | ||||||
| @@ -160,6 +166,18 @@ inline bool Function::isConst() const | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | inline bool Function::isDefault() const | ||||||
|  | { | ||||||
|  | 	return (flags() & FN_DEFAULT) != 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | inline bool Function::isDeleted() const | ||||||
|  | { | ||||||
|  | 	return (flags() & FN_DELETE) != 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| } } // namespace Poco::CppParser | } } // namespace Poco::CppParser | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -35,6 +35,14 @@ Enum::Enum(const std::string& name, NameSpace* pNameSpace, int flags): | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | Enum::Enum(const std::string& name, NameSpace* pNameSpace, const std::string& baseType, int flags): | ||||||
|  | 	Symbol(processName(name), pNameSpace), | ||||||
|  | 	_baseType(baseType), | ||||||
|  | 	_flags(flags) | ||||||
|  | { | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| Enum::~Enum() | Enum::~Enum() | ||||||
| { | { | ||||||
| } | } | ||||||
| @@ -81,7 +89,11 @@ Symbol::Kind Enum::kind() const | |||||||
| std::string Enum::toString() const | std::string Enum::toString() const | ||||||
| { | { | ||||||
| 	std::ostringstream ostr; | 	std::ostringstream ostr; | ||||||
| 	ostr << "enum " << name() << "\n{\n"; | 	ostr << "enum "; | ||||||
|  | 	if (_flags & ENUM_IS_CLASS) ostr << "class "; | ||||||
|  | 	ostr << name(); | ||||||
|  | 	if (!_baseType.empty()) ostr << ": " << _baseType; | ||||||
|  | 	ostr << "\n{\n"; | ||||||
| 	for (Iterator it = begin(); it != end(); ++it) | 	for (Iterator it = begin(); it != end(); ++it) | ||||||
| 	{ | 	{ | ||||||
| 		ostr << "\t" << (*it)->toString() << "\n"; | 		ostr << "\t" << (*it)->toString() << "\n"; | ||||||
|   | |||||||
| @@ -804,6 +804,7 @@ const Token* Parser::parseEnum(const Token* pNext) | |||||||
| { | { | ||||||
| 	poco_assert (isKeyword(pNext, IdentifierToken::KW_ENUM)); | 	poco_assert (isKeyword(pNext, IdentifierToken::KW_ENUM)); | ||||||
|  |  | ||||||
|  | 	std::string baseType; | ||||||
| 	int flags = 0; | 	int flags = 0; | ||||||
| 	_pCurrentSymbol = 0; | 	_pCurrentSymbol = 0; | ||||||
| 	int line = _istr.getCurrentLineNumber(); | 	int line = _istr.getCurrentLineNumber(); | ||||||
| @@ -821,8 +822,15 @@ const Token* Parser::parseEnum(const Token* pNext) | |||||||
| 		name = pNext->tokenString(); | 		name = pNext->tokenString(); | ||||||
| 		pNext = next(); | 		pNext = next(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if (isOperator(pNext, OperatorToken::OP_COLON)) | ||||||
|  | 	{ | ||||||
|  | 		pNext = next(); | ||||||
|  | 		pNext = parseIdentifier(pNext, baseType); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	expectOperator(pNext, OperatorToken::OP_OPENBRACE, "{"); | 	expectOperator(pNext, OperatorToken::OP_OPENBRACE, "{"); | ||||||
| 	Enum* pEnum = new Enum(name, currentNameSpace(), flags); | 	Enum* pEnum = new Enum(name, currentNameSpace(), baseType, flags); | ||||||
| 	addSymbol(pEnum, line); | 	addSymbol(pEnum, line); | ||||||
| 	pNext = next(); | 	pNext = next(); | ||||||
| 	while (pNext->is(Token::IDENTIFIER_TOKEN)) | 	while (pNext->is(Token::IDENTIFIER_TOKEN)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Günter Obiltschnig
					Günter Obiltschnig