#pragma once #include #include #include #include #include #include #include class TEnumParser { public: struct TItem { TMaybe Value; TString CppName; TVector Aliases; TString CommentText; void Clear() { *this = TItem(); } void NormalizeValue() { if (!Value) return; StripInPlace(*Value); } }; // vector is to preserve declaration order typedef TVector TItems; typedef TVector TScope; struct TEnum { TItems Items; TString CppName; TScope Scope; // enum or enum class bool EnumClass = false; bool BodyDetected = false; bool ForwardDeclaration = false; void Clear() { *this = TEnum(); } }; typedef TVector TEnums; /// Parse results stored here TEnums Enums; /// Parse enums from file containing C++ code TEnumParser(const TString& fileName); /// Parse enums from memory buffer containing C++ code TEnumParser(const char* data, size_t length); /// Parse enums from input stream TEnumParser(IInputStream& in); static TString ScopeStr(const TScope& scope) { TString result; for (const TString& name : scope) { result += name; result += "::"; } return result; } private: void Parse(const char* data, size_t length); protected: TString SourceFileName; };