OSDN Git Service

79009a335a08a17648e0c065908a1579e0c08e54
[nysol/mining.git] / include / kgArgFld.h
1 /* ////////// LICENSE INFO ////////////////////
2
3  * Copyright (C) 2013 by NYSOL CORPORATION
4  *
5  * Unless you have received this program directly from NYSOL pursuant
6  * to the terms of a commercial license agreement with NYSOL, then
7  * this program is licensed to you under the terms of the GNU Affero General
8  * Public License (AGPL) as published by the Free Software Foundation,
9  * either version 3 of the License, or (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF 
13  * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
14  *
15  * Please refer to the AGPL (http://www.gnu.org/licenses/agpl-3.0.txt)
16  * for more details.
17
18  ////////// LICENSE INFO ////////////////////*/
19 // ============================================================================
20 // kgArgFld.h 引数項目クラス
21 // ============================================================================
22 #pragma once
23 #include <iostream>
24 #include <string>
25 #include <vector>
26 #include <kgConfig.h>
27 #include <kgError.h>
28 #include <kgCSV.h>
29
30 using namespace std;
31
32 namespace kglib ////////////////////////////////////////////// start namespace
33 {
34
35 // コマンドライン引数クラス
36 class kgArgFld 
37 {
38         kgCSV*          _csv;  // 対象CSVクラス
39         vector<kgstr_t> _name; // 項目名
40         vector<kgstr_t> _attr; // 属性
41         vector<int>     _num;  // name位置->CSV項目番号
42         vector<int>     _flg;  // csv項目番号->name位置
43
44         // _name,_attrの項目名展開&
45         // _name,_attrから_num,_flgへのデータセット(set関数で使用)
46         void _num_flg_Set(kgCSV* csv ,bool fldno,bool attrEval=true);
47
48 public:
49
50         // コンストラクタ
51         kgArgFld() : _csv(0){}
52
53         // set関数
54         void set(vector< vector<kgstr_t> >& vvs, kgCSV* csv ,bool fldno, bool attrEval=true) throw(kgError);
55         void set(vector<kgstr_t>& vs, kgCSV* csv,bool fldno) throw(kgError);
56         void set(kgstr_t& s, kgCSV* csv,bool fldno) throw(kgError);
57
58         // 登録されている項目名数
59         size_t size(void)                       const { return _name.size();}
60         size_t attrSize(void)   const { return _attr.size();}
61         size_t numSize(void)    const { return _num.size(); }
62
63         //アクセッサ
64         const kgCSV*                                    csv(void)                               const   { return _csv; }        
65         const vector<kgstr_t> getAttr(void)     const { return _attr; }
66         const vector<kgstr_t> getName(void)     const { return _name; }
67         const vector<int>     getNum(void)      const { return _num;  }
68         const vector<int>     getFlg(void)      const { return _flg;  }
69         const vector<int>*    getFlg_p(void)    const { return &_flg; }
70
71         const kgstr_t name(size_t num) const;
72         const kgstr_t attr(size_t num) const;
73         int   num (size_t num) const;
74         int   flg (size_t num) const;
75
76 };
77
78 } //////////////////////////////////////////////////////////////// end namespace