• 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
16import { TGeneralInfo } from '../entity/DatabaseEntity';
17import { TIndexInfo } from '../entity/DatabaseEntity';
18
19//垂直生成 TGenneralInfo to string
20export function csvGeneralInfo(tGeneralInfo: TGeneralInfo): string {
21  let data = '';
22  for (let k of Object.keys(tGeneralInfo)) {
23    data += k + ',' + tGeneralInfo[k] + '\n';
24  }
25  return data;
26}
27
28//水平生成 TIndexInfo to string
29export function csvTIndexInfo(tIndexInfos: Array<TIndexInfo>): string {
30  let tittle = csvTIndexInfoTittle();
31  let data = '';
32  for (let index = 0; index < tIndexInfos.length; index++) {
33    const t = tIndexInfos[index];
34    for (let k of Object.keys(t)) {
35      data += t[k] + ',';
36    }
37    data = data.substring(0, data.lastIndexOf(','));
38    data += '\n';
39  }
40  let result = tittle + data;
41  return result;
42}
43
44//水平生成 TIndexInfo TITTLE to string
45export function csvTIndexInfoTittle(): string {
46  let tIndexInfo: TIndexInfo = new TIndexInfo();
47  let data = '';
48  for (let k of Object.keys(tIndexInfo)) {
49    data += k + ',';
50  }
51  data = data.substring(0, data.lastIndexOf(','));
52  data += '\n';
53  return data;
54}
55