/Users/deen/code/yugabyte-db/src/yb/yql/pggate/pg_table.h
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_YQL_PGGATE_PG_TABLE_H |
15 | | #define YB_YQL_PGGATE_PG_TABLE_H |
16 | | |
17 | | #include "yb/yql/pggate/pg_gate_fwd.h" |
18 | | #include "yb/yql/pggate/pg_tabledesc.h" |
19 | | |
20 | | namespace yb { |
21 | | namespace pggate { |
22 | | |
23 | | class PgTable { |
24 | | public: |
25 | 18.5M | PgTable() = default; |
26 | | explicit PgTable(const PgTableDescPtr& desc); |
27 | | |
28 | 4.10M | bool operator!() const { |
29 | 4.10M | return !desc_; |
30 | 4.10M | } |
31 | | |
32 | 22.3M | explicit operator bool() const { |
33 | 22.3M | return desc_ != nullptr; |
34 | 22.3M | } |
35 | | |
36 | 26.7M | PgTableDesc* operator->() const { |
37 | 26.7M | return desc_.get(); |
38 | 26.7M | } |
39 | | |
40 | 25.2M | PgTableDesc& operator*() const { |
41 | 25.2M | return *desc_; |
42 | 25.2M | } |
43 | | |
44 | 27.3M | std::vector<PgColumn>& columns() { |
45 | 27.3M | return *columns_; |
46 | 27.3M | } |
47 | | |
48 | | Result<PgColumn&> ColumnForAttr(int attr_num); |
49 | | PgColumn& ColumnForIndex(size_t index); |
50 | | |
51 | | private: |
52 | | PgTableDescPtr desc_; |
53 | | std::shared_ptr<std::vector<PgColumn>> columns_; |
54 | | }; |
55 | | |
56 | | } // namespace pggate |
57 | | } // namespace yb |
58 | | |
59 | | #endif // YB_YQL_PGGATE_PG_TABLE_H |