• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "table.h"
17 
18 namespace OHOS {
19 namespace WuKong {
20 
Table(std::vector<std::string> cloumn_header,std::vector<std::vector<std::string>> record)21 Table::Table(std::vector<std::string> cloumn_header, std::vector<std::vector<std::string>> record)
22 {
23     uint32_t cols = cloumn_header.size(), rows = record.size();
24     for (uint32_t col = 0; col < cols; col++) {
25         uint32_t max = cloumn_header[col].size();
26         for (uint32_t row = 0; row < rows; row++) {
27             max = record[row][col].size() > max ? record[row][col].size() : max;
28         }
29         column_size_.push_back(max);
30     }
31     column_header_ = cloumn_header;
32     record_ = record;
33 }
34 
SetName(std::string name)35 void Table::SetName(std::string name)
36 {
37     name_ = name;
38 }
39 
GetName()40 std::string Table::GetName()
41 {
42     return name_;
43 }
44 
SetDetail(std::string detail)45 void Table::SetDetail(std::string detail)
46 {
47     detail_ = detail;
48 }
49 
GetDetail()50 std::string Table::GetDetail()
51 {
52     return detail_;
53 }
54 
GetHeader()55 std::vector<std::string> Table::GetHeader()
56 {
57     return column_header_;
58 }
59 
GetRecord()60 std::vector<std::vector<std::string>> Table::GetRecord()
61 {
62     return record_;
63 }
64 
GetColumnSize()65 std::vector<int> Table::GetColumnSize()
66 {
67     return column_size_;
68 }
69 }  // namespace WuKong
70 }  // namespace OHOS