summaryrefslogtreecommitdiffstats
path: root/src/UiGuiIniFileParser.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2022-08-05 10:54:12 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2022-08-05 11:10:14 +0900
commit430373ae38565e0d7f62b8fca0cbad73de73ec7f (patch)
tree670a7322ddd2732c8824b1fb73090b937e2a1f82 /src/UiGuiIniFileParser.cpp
parentd833de5bbe40d780fe02dc95d1c981a4b1007108 (diff)
downloaduniversal-indent-gui-tqt-430373ae38565e0d7f62b8fca0cbad73de73ec7f.tar.gz
universal-indent-gui-tqt-430373ae38565e0d7f62b8fca0cbad73de73ec7f.zip
Format code using uncrustify
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'src/UiGuiIniFileParser.cpp')
-rw-r--r--[-rwxr-xr-x]src/UiGuiIniFileParser.cpp147
1 files changed, 78 insertions, 69 deletions
diff --git a/src/UiGuiIniFileParser.cpp b/src/UiGuiIniFileParser.cpp
index 3f1ee7f..e690139 100755..100644
--- a/src/UiGuiIniFileParser.cpp
+++ b/src/UiGuiIniFileParser.cpp
@@ -43,46 +43,47 @@
/*!
\brief Init and empty all needed lists and strings.
*/
-UiGuiIniFileParser::UiGuiIniFileParser(void) {
+UiGuiIniFileParser::UiGuiIniFileParser(void)
+{
init();
}
-
/*!
\brief Directly loads and parses the file with name \a iniFileName.
*/
-UiGuiIniFileParser::UiGuiIniFileParser(const TQString &iniFileName) {
+UiGuiIniFileParser::UiGuiIniFileParser(const TQString &iniFileName)
+{
init();
- _iniFileName = iniFileName;
- parseIniFile();
+ _iniFileName = iniFileName;
+ parseIniFile();
}
-
-void UiGuiIniFileParser::init() {
+void UiGuiIniFileParser::init()
+{
_sections.clear();
_keyValueMap.clear();
_iniFileName = "";
}
-
-UiGuiIniFileParser::~UiGuiIniFileParser(void) {
+UiGuiIniFileParser::~UiGuiIniFileParser(void)
+{
}
-
/*!
\brief Returns the group/section names in the same order as they occurr in the ini file as TQStringList.
*/
-TQStringList UiGuiIniFileParser::childGroups() {
- TQStringList sectionsStringList;
+TQStringList UiGuiIniFileParser::childGroups()
+{
+ TQStringList sectionsStringList;
- for( unsigned int i = 0; i < _sections.size(); i++ ) {
- sectionsStringList << _sections[i];
- }
+ for (unsigned int i = 0; i < _sections.size(); i++)
+ {
+ sectionsStringList << _sections[i];
+ }
- return sectionsStringList;
+ return sectionsStringList;
}
-
/*!
\brief Returns the value of the defined \a keyName as TQVariant.
@@ -91,61 +92,69 @@ TQStringList UiGuiIniFileParser::childGroups() {
<code>[NiceSection]</br>niceKeyName=2</code> you would have to call
value("NiceSection/niceKeyName").
*/
-TQVariant UiGuiIniFileParser::value(const TQString &keyName, const TQString &defaultValue) {
- return _keyValueMap.value( keyName, defaultValue );
+TQVariant UiGuiIniFileParser::value(const TQString &keyName, const TQString &defaultValue)
+{
+ return _keyValueMap.value(keyName, defaultValue);
}
-
/*!
\brief Parses the ini file and stores the key value pairs in the internal vectors \a keys and \a values.
*/
-void UiGuiIniFileParser::parseIniFile() {
- TQFile iniFile(_iniFileName);
-
- if ( iniFile.open(TQFile::ReadOnly) ) {
- // Clear the vectors holding the keys and values.
- _sections.clear();
- _keyValueMap.clear();
-
- TQTextStream iniFileStream( &iniFile );
- TQString line;
- TQString currentSectionName = "";
- TQString keyName = "";
- TQString valueAsString = "";
-
- while ( !iniFileStream.atEnd() ) {
- line = iniFileStream.readLine().trimmed();
-
- // Test if the read line is a section name and if so remeber it.
- if ( line.startsWith("[") && line.endsWith("]") ) {
- currentSectionName = line.remove(0, 1);
- currentSectionName.chop(1);
-
- // Store the section name.
- _sections.push_back( currentSectionName );
- }
- // Otherwise test whether the line has a assign char
- else if ( line.contains("=") ) {
- int indexOfFirstAssign = line.indexOf("=");
- keyName = line.left(indexOfFirstAssign);
-
- if ( !keyName.isEmpty() ) {
- valueAsString = line.remove(0, indexOfFirstAssign+1);
- // Remove any existing double quotes from the value.
- if ( valueAsString.startsWith("\"") && valueAsString.endsWith("\"") ) {
- valueAsString = valueAsString.remove(0, 1);
- valueAsString.chop(1);
- }
-
- // Prepend an eventually section name to the key name.
- if ( !currentSectionName.isEmpty() ) {
- keyName = currentSectionName + "/" + keyName;
- }
-
- // Store the key and value in the map.
- _keyValueMap.insert(keyName, valueAsString );
- }
- }
- }
- }
+void UiGuiIniFileParser::parseIniFile()
+{
+ TQFile iniFile(_iniFileName);
+
+ if (iniFile.open(TQFile::ReadOnly))
+ {
+ // Clear the vectors holding the keys and values.
+ _sections.clear();
+ _keyValueMap.clear();
+
+ TQTextStream iniFileStream(&iniFile);
+ TQString line;
+ TQString currentSectionName = "";
+ TQString keyName = "";
+ TQString valueAsString = "";
+
+ while (!iniFileStream.atEnd())
+ {
+ line = iniFileStream.readLine().trimmed();
+
+ // Test if the read line is a section name and if so remeber it.
+ if (line.startsWith("[") && line.endsWith("]"))
+ {
+ currentSectionName = line.remove(0, 1);
+ currentSectionName.chop(1);
+
+ // Store the section name.
+ _sections.push_back(currentSectionName);
+ }
+ // Otherwise test whether the line has a assign char
+ else if (line.contains("="))
+ {
+ int indexOfFirstAssign = line.indexOf("=");
+ keyName = line.left(indexOfFirstAssign);
+
+ if (!keyName.isEmpty())
+ {
+ valueAsString = line.remove(0, indexOfFirstAssign + 1);
+ // Remove any existing double quotes from the value.
+ if (valueAsString.startsWith("\"") && valueAsString.endsWith("\""))
+ {
+ valueAsString = valueAsString.remove(0, 1);
+ valueAsString.chop(1);
+ }
+
+ // Prepend an eventually section name to the key name.
+ if (!currentSectionName.isEmpty())
+ {
+ keyName = currentSectionName + "/" + keyName;
+ }
+
+ // Store the key and value in the map.
+ _keyValueMap.insert(keyName, valueAsString);
+ }
+ }
+ }
+ }
}