-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathParser.h
65 lines (50 loc) · 1.88 KB
/
Parser.h
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
//
// Parser.h
//
// Copyright (c) 2020, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef ActiveRecordCompiler_Parser_INCLUDED
#define ActiveRecordCompiler_Parser_INCLUDED
#include "Types.h"
#include "Poco/SAX/DefaultHandler.h"
#include <istream>
namespace Poco {
namespace ActiveRecord {
namespace Compiler {
class Parser: protected Poco::XML::DefaultHandler
/// A parser for the XML ORM (project/class/property) class specification file.
{
public:
Parser();
/// Creates the Parser.
ClassMap parse(const std::string& systemId, std::istream& stream);
/// Parses the XML file.
protected:
// ContentHandler
void setDocumentLocator(const Poco::XML::Locator* pLocator);
void startElement(const Poco::XML::XMLString& uri, const Poco::XML::XMLString& localName, const Poco::XML::XMLString& qname, const Poco::XML::Attributes& attributes);
void endElement(const Poco::XML::XMLString& uri, const Poco::XML::XMLString& localName, const Poco::XML::XMLString& qname);
void handleProject(const Poco::XML::Attributes& attributes);
void handleClass(const Poco::XML::Attributes& attributes);
void handleProperty(const Poco::XML::Attributes& attributes);
std::string where() const;
std::string parseType(const std::string& type) const;
char parseCardinality(const std::string& cardinality) const;
bool parseBool(const std::string& name, const std::string& value, bool deflt = false) const;
std::string convertCamelCase(const std::string& name);
std::string toDatabaseName(const std::string& name);
private:
const Poco::XML::Locator* _pLocator = nullptr;
bool _convertCamelCase = false;
std::string _nameSpace;
std::string _dllExport;
std::string _precompiledHeader;
Class _class;
ClassMap _classes;
std::vector<std::string> _elemStack;
};
} } } // namespace Poco::ActiveRecord::Compiler
#endif // ActiveRecordCompiler_Parser_INCLUDED