1 | /* |
2 | * PROGRAM: Client/Server Common Code |
3 | * MODULE: QualifiedName.h |
4 | * DESCRIPTION: Qualified metadata name holder. |
5 | * |
6 | * The contents of this file are subject to the Initial |
7 | * Developer's Public License Version 1.0 (the "License"); |
8 | * you may not use this file except in compliance with the |
9 | * License. You may obtain a copy of the License at |
10 | * http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. |
11 | * |
12 | * Software distributed under the License is distributed AS IS, |
13 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. |
14 | * See the License for the specific language governing rights |
15 | * and limitations under the License. |
16 | * |
17 | * The Original Code was created by Adriano dos Santos Fernandes |
18 | * for the Firebird Open Source RDBMS project. |
19 | * |
20 | * Copyright (c) 2009 Adriano dos Santos Fernandes <adrianosf@uol.com.br> |
21 | * and all contributors signed below. |
22 | * |
23 | * All Rights Reserved. |
24 | * Contributor(s): ______________________________________. |
25 | */ |
26 | |
27 | #ifndef COMMON_QUALIFIEDNAME_H |
28 | #define COMMON_QUALIFIEDNAME_H |
29 | |
30 | #include "MetaName.h" |
31 | #include "array.h" |
32 | |
33 | namespace Firebird { |
34 | |
35 | class QualifiedName |
36 | { |
37 | public: |
38 | QualifiedName(MemoryPool& p, const MetaName& aIdentifier, const MetaName& aPackage) |
39 | : identifier(p, aIdentifier), |
40 | package(p, aPackage) |
41 | { |
42 | } |
43 | |
44 | QualifiedName(const MetaName& aIdentifier, const MetaName& aPackage) |
45 | : identifier(aIdentifier), |
46 | package(aPackage) |
47 | { |
48 | } |
49 | |
50 | explicit QualifiedName(const MetaName& aIdentifier) |
51 | : identifier(aIdentifier) |
52 | { |
53 | } |
54 | |
55 | explicit QualifiedName(MemoryPool& p) |
56 | : identifier(p), |
57 | package(p) |
58 | { |
59 | } |
60 | |
61 | QualifiedName() |
62 | { |
63 | } |
64 | |
65 | QualifiedName(MemoryPool& p, const QualifiedName& src) |
66 | : identifier(p, src.identifier), |
67 | package(p, src.package) |
68 | { |
69 | } |
70 | |
71 | public: |
72 | bool operator >(const QualifiedName& m) const |
73 | { |
74 | return package > m.package || (package == m.package && identifier > m.identifier); |
75 | } |
76 | |
77 | bool operator ==(const QualifiedName& m) const |
78 | { |
79 | return identifier == m.identifier && package == m.package; |
80 | } |
81 | |
82 | public: |
83 | string toString() const |
84 | { |
85 | string s; |
86 | if (package.hasData()) |
87 | { |
88 | s = package.c_str(); |
89 | s.append("." ); |
90 | } |
91 | s.append(identifier.c_str()); |
92 | return s; |
93 | } |
94 | |
95 | public: |
96 | MetaName identifier; |
97 | MetaName package; |
98 | }; |
99 | |
100 | } // namespace Firebird |
101 | |
102 | #endif // COMMON_QUALIFIEDNAME_H |
103 | |