2 * Amiga Generic Set - set of libraries and includes to ease sw development for all Amiga platforms
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "ConfigParser.h"
21 using namespace GenNS
;
23 ConfigParser::~ConfigParser()
27 ConfigParser::ConfigParser(ConfigParser
*pParent
, String sName
, long lID
)
29 sElemName
= sName
; // set element name
30 this->pParent
= pParent
; // set parent element
36 const char *ConfigParser::getValue(const char* sName
, const char *sDefault
)
41 XMLElement
*pElem
= pElement
->FindChild(const_cast<char*>(sName
));
45 return pElem
->GetValue().Data();
48 long ConfigParser::getValue(const char* sName
, long lDefault
)
53 XMLElement
*pElem
= pElement
->FindChild(const_cast<char*>(sName
));
57 return pElem
->GetValue().ToLong();
60 void ConfigParser::setValue(const char* sName
, const char* sValue
)
65 XMLElement
*pElem
= pElement
->FindChild(const_cast<char*>(sName
));
68 pElem
= pElement
->AddChild(const_cast<char*>(sName
), "");
71 pElem
->SetValue(sValue
);
74 void ConfigParser::setValue(const char* sName
, long sValue
)
79 XMLElement
*pElem
= pElement
->FindChild(const_cast<char*>(sName
));
82 pElem
= pElement
->AddChild(const_cast<char*>(sName
), "");
85 pElem
->SetValue(sValue
);
88 XMLElement
*ConfigParser::addChild(const char* sElemName
)
93 return pElement
->AddChild(const_cast<char*>(sElemName
), "");
96 void ConfigParser::locateElement()
100 for (int i
=0; i
<pParent
->pElement
->GetChildrenCount(); i
++)
102 XMLElement
*pElem
= pParent
->pElement
->GetChild(i
);
103 if (pElem
->GetName().Equals(sElemName
))
112 XMLAttribute
*pAttr
= pElem
->FindAttribute("id");
115 if (pAttr
->GetValue().ToLong() == lID
)
125 pElement
= pParent
->addChild(sElemName
);
128 pElement
->AddAttribute("id", lID
);
133 XMLElement
*ConfigParser::getElement()