mirror of
https://github.com/modelec/cpp-lib.git
synced 2026-01-18 16:17:22 +01:00
change conversion from string to arithmetic
This commit is contained in:
@@ -10,11 +10,19 @@ find_package(Modelec COMPONENTS
|
||||
REQUIRED)
|
||||
|
||||
# Define the executable
|
||||
add_executable(client main.cpp)
|
||||
add_executable(client client.example.cpp)
|
||||
|
||||
add_executable(parser parser.example.cpp)
|
||||
|
||||
# Link the shared library to the executable
|
||||
target_link_libraries(client
|
||||
Modelec::CLParser
|
||||
Modelec::TCPClient
|
||||
Modelec::Utils
|
||||
)
|
||||
|
||||
target_link_libraries(parser
|
||||
Modelec::CLParser
|
||||
Modelec::TCPClient
|
||||
Modelec::Utils
|
||||
)
|
||||
26
example/parser.example.cpp
Normal file
26
example/parser.example.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <Modelec/CLParser.h>
|
||||
#include <iostream>
|
||||
|
||||
struct B {
|
||||
std::string a;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
CLParser parser(argc, argv);
|
||||
|
||||
int port = parser.getOption("port", 12);
|
||||
|
||||
std::cout << "Port : " << port << std::endl;
|
||||
|
||||
auto test = parser.getOption<unsigned long long>("long");
|
||||
|
||||
if (test.has_value()) {
|
||||
std::cout << test.value() << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "missing long argument" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user