mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-26 02:25:03 +00:00
Massive renaming in the backend folder, all around restructure in the same.
This commit is contained in:
@@ -51,5 +51,5 @@ SET(LIBUTIL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
|
||||
add_definitions(-DLIBUTIL_LIBRARY)
|
||||
|
||||
add_library(libUtil SHARED ${LIBUTIL_SOURCES} ${LIBUTIL_HEADERS})
|
||||
qt5_use_modules(libUtil Core)
|
||||
qt5_use_modules(libUtil Core Network)
|
||||
target_link_libraries(libUtil)
|
||||
|
||||
@@ -29,12 +29,19 @@
|
||||
|
||||
/**
|
||||
* @file libutil/include/cmdutils.h
|
||||
* @brief commandline parsing utilities
|
||||
* @brief commandline parsing and processing utilities
|
||||
*/
|
||||
|
||||
namespace Util {
|
||||
namespace Commandline {
|
||||
|
||||
/**
|
||||
* @brief split a string into argv items like a shell would do
|
||||
* @param args the argument string
|
||||
* @return a QStringList containing all arguments
|
||||
*/
|
||||
LIBUTIL_EXPORT QStringList splitArgs(QString args);
|
||||
|
||||
/**
|
||||
* @brief The FlagStyle enum
|
||||
* Specifies how flags are decorated
|
||||
|
||||
@@ -24,6 +24,56 @@
|
||||
namespace Util {
|
||||
namespace Commandline {
|
||||
|
||||
// commandline splitter
|
||||
QStringList splitArgs(QString args)
|
||||
{
|
||||
QStringList argv;
|
||||
QString current;
|
||||
bool escape = false;
|
||||
QChar inquotes;
|
||||
for (int i=0; i<args.length(); i++)
|
||||
{
|
||||
QChar cchar = args.at(i);
|
||||
|
||||
// \ escaped
|
||||
if (escape)
|
||||
{
|
||||
current += cchar;
|
||||
escape = false;
|
||||
// in "quotes"
|
||||
}
|
||||
else if (!inquotes.isNull())
|
||||
{
|
||||
if (cchar == 0x5C)
|
||||
escape = true;
|
||||
else if (cchar == inquotes)
|
||||
inquotes = 0;
|
||||
else
|
||||
current += cchar;
|
||||
// otherwise
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cchar == 0x20)
|
||||
{
|
||||
if (!current.isEmpty())
|
||||
{
|
||||
argv << current;
|
||||
current.clear();
|
||||
}
|
||||
}
|
||||
else if (cchar == 0x22 || cchar == 0x27)
|
||||
inquotes = cchar;
|
||||
else
|
||||
current += cchar;
|
||||
}
|
||||
}
|
||||
if (!current.isEmpty())
|
||||
argv << current;
|
||||
return argv;
|
||||
}
|
||||
|
||||
|
||||
Parser::Parser(FlagStyle::Enum flagStyle, ArgumentStyle::Enum argStyle)
|
||||
{
|
||||
m_flagStyle = flagStyle;
|
||||
|
||||
Reference in New Issue
Block a user