1 /*----------------------------------------------------------------------------
2                   valbuff.h (definitions of variable buffer)
3                        This file is a part of topaz systems
4                   Copyright: Hisao Kawaura, All rights reserved
5                                    1997 - 98
6 
7 
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 
22 ----------------------------------------------------------------------------*/
23 
24 #if !defined(__varbuff_h)
25 #define __varbuff_h
26 
27 # include <string>
28 #include "buffarray.h"
29 
30 #define ELEMENTLENGTH 100
31 
32 class BuffElement
33 {
34  public:
35   BuffElement();
BuffElement(BuffElement * ele)36   BuffElement(BuffElement *ele)
37     {label = ele->label, *value = *ele->value; isreadonly = ele->isreadonly;}
~BuffElement()38   ~BuffElement(){delete value;}
39   std::string label;
40   buffarray *value;
41   int isreadonly;
42   BuffElement& operator = (const BuffElement& ele);
43 
44 };
45 
46 
47 class VariantBuff
48 {
49  public:
50  VariantBuff();
51  ~VariantBuff();
52 
53  bool SetArray (std::string *label, int length);
54  bool SystemSetArray (std::string *label, int length);
55  bool SetScalar (std::string *label, std::string *value);
56  bool SetSystemScalar (std::string *label, std::string *value);
57  bool GetScalar(std::string *label, std::string *value);
58  bool SystemSet (std::string *label, int pos, std::string *value);
59  bool Set (std::string *label, int pos, std::string *value);
60  bool Get(std::string *label, int pos, std::string *value);
61  bool Add(std::string *label, std::string *val);
62  int getarraylength();
63  int ArrayLength(std::string *label);
64  int arraylength;
65  int increment;
66  int  bufflength;
67 
68  bool setbuff(int length);
69  bool add(std::string *label, std::string *val);
70  bool add(BuffElement *buffele);
71  bool addat(std::string *label, int pos, std::string *val);
72  bool remove(int pos);
73  bool search(std::string *label,  int *SeachedIndex);
74 
75  VariantBuff& operator = (const VariantBuff& buff);
76  BuffElement& operator [] (int pos);
77 
78  private:
79  BuffElement **element;
80  int labelnum;
81  bool changebufflength(int length);
82 
83 };
84 
85 
86 
87 #endif
88 
89