/[cvs]/api/Classes/String/ConfigInput.cpp
ViewVC logotype

Annotation of /api/Classes/String/ConfigInput.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Sun Jul 1 20:47:58 2001 UTC (23 years, 5 months ago) by bearsoft
Branch: lazy, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
First import

1 bearsoft 1.1 #include "../String/String.h"
2     #include "../System/System.h"
3     #include "ConfigInput.h"
4     #include "../System/SystemDefine.h"
5    
6    
7     ConfigInput::ConfigInput()
8     {
9     objectLinkedList=null;
10     stringInput=null;
11     }
12    
13     ConfigInput::~ConfigInput()
14     {
15     if (objectLinkedList!=null)
16     {
17     delete objectLinkedList;
18     }
19     if (stringInput!=null)
20     {
21     delete stringInput;
22     }
23     }
24    
25    
26     void ConfigInput::readFile(char *fileName)
27     {
28     objectLinkedList=new ObjectLinkedList<ExtPropertiesElement>();
29    
30     stringInput=new StringInput();
31    
32     stringInput->readFile(fileName);
33    
34     ExtPropertiesElement *extPropertiesElement=null;
35    
36     bool structKey=true;
37    
38     while (stringInput->getScanWordStatus())
39     {
40     if (structKey)
41     {
42     extPropertiesElement=objectLinkedList->addLast(new ExtPropertiesElement(stringInput->scanWord(),"info"));
43    
44     if(stringInput->getScanWordStatus())
45     {
46     String start=stringInput->scanWord();
47     }
48     structKey=false;
49     }
50    
51     String key=stringInput->scanWord();
52    
53     if (!key.equals("};"))
54     {
55     if(stringInput->getScanWordStatus())
56     {
57     String data=stringInput->scanWord();
58    
59     if(stringInput->getScanWordStatus())
60     {
61     if ( (!key.isNull()) && (!data.isNull()) )
62     {
63     extPropertiesElement->addLast(key.buffer,data.buffer);
64     /* System::println(key);
65     System::println(data);*/
66     }
67     }
68     }
69     }
70     else
71     {
72     structKey=true;
73     }
74     }
75    
76     stringInput->resetScanWord(); //moves the pointer to the begining of the string buffer again
77    
78     }
79    
80     char *ConfigInput::getData(int index, int iKey)
81     {
82     if (index>=0 && index<objectLinkedList->size())
83     {
84     ExtPropertiesElement *extPropertiesElement=objectLinkedList->getElement(index);
85     return extPropertiesElement->getData(iKey);
86     }
87    
88     return null;
89     }
90    
91    
92    
93     char *ConfigInput::getData(char *iType, char *iKey)
94     {
95     String type=iType;
96     String key=iKey;
97    
98     return getData(type, key);
99     }
100    
101     char *ConfigInput::getData(String &type, String &iKey)
102     {
103     int size=objectLinkedList->size();
104    
105     for ( int i=0; i<size ; i++ )
106     {
107     ExtPropertiesElement *extPropertiesElement=objectLinkedList->getElement(i);
108     if(extPropertiesElement->key->equals(type))
109     {
110     return extPropertiesElement->getKeyData(iKey);
111     }
112     }
113    
114     return null;
115     }

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26