Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
ArgParser.h
Go to the documentation of this file.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
23#pragma once
24
25#include "sese/Config.h"
26
27#include <map>
28
29#ifdef _WIN32
30#pragma warning(disable : 4251)
31#endif
32
33namespace sese {
34
38class ArgParser {
39public:
40 typedef std::unique_ptr<ArgParser> Ptr;
41
42public:
43 ArgParser() = default;
44
51 bool parse(int32_t argc, const char *const *argv) noexcept;
52
56 [[nodiscard]] const std::map<std::string, std::string> &getKeyValSet() const noexcept;
57
64 [[nodiscard]] const std::string &getValueByKey(const std::string &key, const std::string &default_value) const noexcept;
65
72 [[nodiscard]] const std::string &getValueByKey(const std::string &key) const;
73
79 [[nodiscard]] bool exist(const std::string &key) const noexcept;
80
85 [[nodiscard]] const std::string &getCurrentPath() const { return currentPath; }
86
91 [[nodiscard]] const std::string &getFileName() const { return fileName; }
92
97 [[nodiscard]] const std::string &getFullPath() const { return fullPath; }
98
99private:
100 std::string fullPath;
101 std::string currentPath;
102 std::string fileName;
103 std::map<std::string, std::string> keyValSet;
104};
105
106} // namespace sese