Add ClArgs library
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
add_subdirectory(clargs)
|
||||||
add_subdirectory(fs)
|
add_subdirectory(fs)
|
||||||
add_subdirectory(std)
|
add_subdirectory(std)
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
add_library(
|
||||||
|
OxClArgs
|
||||||
|
clargs.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
clargs.hpp
|
||||||
|
DESTINATION
|
||||||
|
include/ox/clargs
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS
|
||||||
|
OxClArgs
|
||||||
|
LIBRARY DESTINATION lib/ox
|
||||||
|
ARCHIVE DESTINATION lib/ox
|
||||||
|
)
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 - 2017 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "clargs.hpp"
|
||||||
|
|
||||||
|
namespace ox {
|
||||||
|
namespace clargs {
|
||||||
|
|
||||||
|
ClArgs::ClArgs(int argc, const char **args) {
|
||||||
|
for (int i = 0; i < argc; i++) {
|
||||||
|
std::string arg = args[i];
|
||||||
|
if (arg[0] == '-') {
|
||||||
|
while (arg[0] == '-' && arg.size()) {
|
||||||
|
arg = arg.substr(1);
|
||||||
|
}
|
||||||
|
m_args[arg] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClArgs::operator[](std::string arg) {
|
||||||
|
return m_args[arg];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 - 2017 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace ox {
|
||||||
|
namespace clargs {
|
||||||
|
|
||||||
|
class ClArgs {
|
||||||
|
private:
|
||||||
|
std::map<std::string, bool> m_args;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ClArgs(int argc, const char **args);
|
||||||
|
|
||||||
|
bool operator[](std::string arg);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user