Put everything into args namespace
Diffstat:
7 files changed, 24 insertions(+), 0 deletions(-)
@@ -4,6 +4,8 @@
#include <iostream>
#include <vector>
using namespace args;
void error(const std::string &message) { std::cerr << message << std::endl; }
struct arguments_t {
const char *output_file = "";
@@ -3,6 +3,7 @@
#ifdef __cplusplus
extern "C" {
namespace args {
struct Parser;
typedef Parser args_parser;
#else
@@ -48,6 +49,7 @@
int args_parse(args_argp_t *argp, int argc, char *argv[], void *input);
void *args_parser_input(args_parser *parser);
#ifdef __cplusplus
} // namespace args
} // extern "C"
#endif
@@ -7,6 +7,8 @@
#include <unordered_map>
#include <vector>
namespace args {
class Parser {
public:
using option_t = args_option_t;
@@ -83,4 +85,6 @@
class Parser {
trie_t trie;
};
} // namespace args
#endif
@@ -7,6 +7,8 @@
#include <iostream>
#include <sstream>
namespace args {
Parser::Parser(void *input, argp_t *argp) : input(input), argp(argp) {
int group = 0, key_last = 0;
bool hidden = false;
@@ -197,3 +199,5 @@
excess:
argp->parse(Key::ERROR, 0, this);
return 3;
}
} // namespace args
@@ -1,8 +1,12 @@
#include "args.h"
#include "args.hpp"
namespace args {
int args_parse(args_argp_t *argp, int argc, char *argv[], void *input) {
return Parser::parse(argp, argc, argv, input);
}
void *args_parser_input(args_parser *parser) { return parser->input; }
} // namespace args
@@ -5,6 +5,8 @@
#include <iostream>
#include <sstream>
namespace args {
bool Parser::help_entry_t::operator<(const help_entry_t &rhs) const {
if (group != rhs.group) {
if (group && rhs.group) {
@@ -180,3 +182,5 @@
void Parser::usage(const char *name) const {
exit(0);
}
} // namespace args
@@ -2,6 +2,8 @@
#include <cstdint>
namespace args {
Parser::trie_t::~trie_t() noexcept {
for (uint8_t i = 0; i < 26; i++) {
delete children[i];
@@ -36,3 +38,5 @@
int Parser::trie_t::get(const std::string &option) const {
if (!crnt->terminal && crnt->count > 1) return 0;
return crnt->key;
}
} // namespace args