summaryrefslogtreecommitdiffstats
path: root/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'libutil')
-rw-r--r--libutil/CMakeLists.txt16
-rw-r--r--libutil/include/cmdutils.h10
-rw-r--r--libutil/include/inifile.h38
-rw-r--r--libutil/include/libutil_config.h6
-rw-r--r--libutil/include/pathutils.h6
-rw-r--r--libutil/include/userutils.h4
-rw-r--r--libutil/src/inifile.cpp86
7 files changed, 19 insertions, 147 deletions
diff --git a/libutil/CMakeLists.txt b/libutil/CMakeLists.txt
index b934d4c0..5b2c3837 100644
--- a/libutil/CMakeLists.txt
+++ b/libutil/CMakeLists.txt
@@ -1,4 +1,4 @@
-project(libmmcutil)
+project(libUtil)
######## Set compiler flags ########
IF(APPLE)
@@ -32,8 +32,6 @@ include/osutils.h
include/userutils.h
include/cmdutils.h
-include/inifile.h
-
include/siglist.h
include/siglist_impl.h
)
@@ -43,15 +41,13 @@ src/pathutils.cpp
src/osutils.cpp
src/userutils.cpp
src/cmdutils.cpp
-
-src/inifile.cpp
)
# Set the include dir path.
-SET(LIBMMCUTIL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
+SET(LIBUTIL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
-add_definitions(-DLIBMMCUTIL_LIBRARY)
+add_definitions(-DLIBUTIL_LIBRARY)
-add_library(libmmcutil SHARED ${LIBUTIL_SOURCES} ${LIBUTIL_HEADERS})
-qt5_use_modules(libmmcutil Core)
-target_link_libraries(libmmcutil)
+add_library(libUtil SHARED ${LIBUTIL_SOURCES} ${LIBUTIL_HEADERS})
+qt5_use_modules(libUtil Core)
+target_link_libraries(libUtil)
diff --git a/libutil/include/cmdutils.h b/libutil/include/cmdutils.h
index 984826d6..32261dd7 100644
--- a/libutil/include/cmdutils.h
+++ b/libutil/include/cmdutils.h
@@ -42,7 +42,7 @@ namespace Commandline {
namespace FlagStyle
{
-enum LIBMMCUTIL_EXPORT Enum
+enum LIBUTIL_EXPORT Enum
{
GNU, /**< --option and -o (GNU Style) */
Unix, /**< -option and -o (Unix Style) */
@@ -60,7 +60,7 @@ enum LIBMMCUTIL_EXPORT Enum
*/
namespace ArgumentStyle
{
-enum LIBMMCUTIL_EXPORT Enum
+enum LIBUTIL_EXPORT Enum
{
Space, /**< --option=value */
Equals, /**< --option value */
@@ -75,7 +75,7 @@ enum LIBMMCUTIL_EXPORT Enum
namespace OptionType
{
-enum LIBMMCUTIL_EXPORT Enum
+enum LIBUTIL_EXPORT Enum
{
Switch,
Option
@@ -85,7 +85,7 @@ enum LIBMMCUTIL_EXPORT Enum
/**
* @brief The ParsingError class
*/
-class LIBMMCUTIL_EXPORT ParsingError : public std::exception
+class LIBUTIL_EXPORT ParsingError : public std::exception
{
public:
ParsingError(const QString &what);
@@ -100,7 +100,7 @@ private:
/**
* @brief The Parser class
*/
-class LIBMMCUTIL_EXPORT Parser
+class LIBUTIL_EXPORT Parser
{
public:
/**
diff --git a/libutil/include/inifile.h b/libutil/include/inifile.h
deleted file mode 100644
index 1280c7e3..00000000
--- a/libutil/include/inifile.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef INIFILE_H
-#define INIFILE_H
-
-#include <QMap>
-#include <QString>
-#include <QVariant>
-
-#include "libutil_config.h"
-
-// Sectionless INI parser (for instance config files)
-class LIBMMCUTIL_EXPORT INIFile : public QMap<QString, QVariant>
-{
-public:
- explicit INIFile();
-
- bool loadFile(QString fileName);
- bool saveFile(QString fileName);
-
- QVariant get(QString key, QVariant def) const;
- void set(QString key, QVariant val);
-};
-
-#endif // INIFILE_H
diff --git a/libutil/include/libutil_config.h b/libutil/include/libutil_config.h
index 41766184..4bf111e6 100644
--- a/libutil/include/libutil_config.h
+++ b/libutil/include/libutil_config.h
@@ -18,10 +18,10 @@
#include <QtCore/QtGlobal>
-#ifdef LIBMMCUTIL_LIBRARY
-# define LIBMMCUTIL_EXPORT Q_DECL_EXPORT
+#ifdef LIBUTIL_LIBRARY
+# define LIBUTIL_EXPORT Q_DECL_EXPORT
#else
-# define LIBMMCUTIL_EXPORT Q_DECL_IMPORT
+# define LIBUTIL_EXPORT Q_DECL_IMPORT
#endif
#endif // LIBUTIL_CONFIG_H
diff --git a/libutil/include/pathutils.h b/libutil/include/pathutils.h
index d5f106ef..be6c8917 100644
--- a/libutil/include/pathutils.h
+++ b/libutil/include/pathutils.h
@@ -20,9 +20,9 @@
#include "libutil_config.h"
-LIBMMCUTIL_EXPORT QString PathCombine(QString path1, QString path2);
-LIBMMCUTIL_EXPORT QString PathCombine(QString path1, QString path2, QString path3);
+LIBUTIL_EXPORT QString PathCombine(QString path1, QString path2);
+LIBUTIL_EXPORT QString PathCombine(QString path1, QString path2, QString path3);
-LIBMMCUTIL_EXPORT QString AbsolutePath(QString path);
+LIBUTIL_EXPORT QString AbsolutePath(QString path);
#endif // PATHUTILS_H
diff --git a/libutil/include/userutils.h b/libutil/include/userutils.h
index 06a8ca16..4f2760b1 100644
--- a/libutil/include/userutils.h
+++ b/libutil/include/userutils.h
@@ -8,12 +8,12 @@
namespace Util
{
// Get the Directory representing the User's Desktop
-LIBMMCUTIL_EXPORT QString getDesktopDir();
+LIBUTIL_EXPORT QString getDesktopDir();
// Create a shortcut at *location*, pointing to *dest* called with the arguments *args*
// call it *name* and assign it the icon *icon*
// return true if operation succeeded
-LIBMMCUTIL_EXPORT bool createShortCut(QString location, QString dest, QStringList args, QString name, QString iconLocation);
+LIBUTIL_EXPORT bool createShortCut(QString location, QString dest, QStringList args, QString name, QString iconLocation);
}
#endif // USERUTILS_H
diff --git a/libutil/src/inifile.cpp b/libutil/src/inifile.cpp
deleted file mode 100644
index 43545a4a..00000000
--- a/libutil/src/inifile.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "include/inifile.h"
-
-#include <QFile>
-#include <QTextStream>
-#include <QStringList>
-
-INIFile::INIFile()
-{
-
-}
-
-bool INIFile::saveFile(QString fileName)
-{
- // TODO Handle errors.
- QFile file(fileName);
- file.open(QIODevice::WriteOnly);
- QTextStream out(&file);
-
- for (Iterator iter = begin(); iter != end(); iter++)
- {
- out << iter.key() << "=" << iter.value().toString() << "\n";
- }
-
- return true;
-}
-
-bool INIFile::loadFile(QString fileName)
-{
- // TODO Handle errors.
- QFile file(fileName);
- file.open(QIODevice::ReadOnly);
- QTextStream in(&file);
-
- QStringList lines = in.readAll().split('\n');
- for (int i = 0; i < lines.count(); i++)
- {
- QString & lineRaw = lines[i];
- // Ignore comments.
- QString line = lineRaw.left(lineRaw.indexOf('#')).trimmed();
-
- int eqPos = line.indexOf('=');
- if(eqPos == -1)
- continue;
- QString key = line.left(eqPos).trimmed();
- QString valueStr = line.right(line.length() - eqPos - 1).trimmed();
-
- QVariant value(valueStr);
- /*
- QString dbg = key;
- dbg += " = ";
- dbg += valueStr;
- qDebug(dbg.toLocal8Bit());
- */
- this->operator [](key) = value;
- }
-
- return true;
-}
-
-QVariant INIFile::get(QString key, QVariant def) const
-{
- if (!this->contains(key))
- return def;
- else
- return this->operator [](key);
-}
-
-void INIFile::set(QString key, QVariant val)
-{
- this->operator [](key) = val;
-}