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)21Table::Table(std::vector<std::string> cloumn_header, std::vector<std::vector<std::string>> record) 22 { 23 uint32_t cols = cloumn_header.size(); 24 uint32_t rows = record.size(); 25 for (uint32_t col = 0; col < cols; col++) { 26 uint32_t max = cloumn_header[col].size(); 27 for (uint32_t row = 0; row < rows; row++) { 28 max = record[row][col].size() > max ? record[row][col].size() : max; 29 } 30 column_size_.push_back(max); 31 } 32 column_header_ = cloumn_header; 33 record_ = record; 34 } 35 SetName(std::string name)36void Table::SetName(std::string name) 37 { 38 name_ = name; 39 } 40 GetName()41std::string Table::GetName() 42 { 43 return name_; 44 } 45 SetDetail(std::string detail)46void Table::SetDetail(std::string detail) 47 { 48 detail_ = detail; 49 } 50 GetDetail()51std::string Table::GetDetail() 52 { 53 return detail_; 54 } 55 GetHeader()56std::vector<std::string> Table::GetHeader() 57 { 58 return column_header_; 59 } 60 GetRecord()61std::vector<std::vector<std::string>> Table::GetRecord() 62 { 63 return record_; 64 } 65 GetColumnSize()66std::vector<int> Table::GetColumnSize() 67 { 68 return column_size_; 69 } 70 } // namespace WuKong 71 } // namespace OHOS