Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Thread group#590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
deanberris merged 3 commits intocpp-netlib:masterfromglynos:thread_group
Jan 31, 2016
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
Removed depenency on boost program_options (replaced with cxxopts, wh…
…ich only depends on C++11).
  • Loading branch information
@glynos
glynos committedJan 30, 2016
commita7d48af2d972dfeeac9b57815764bcf3e3070069
3 changes: 3 additions & 0 deletions.gitmodules
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,3 +7,6 @@
[submodule "libs/network/doc/_ext/breathe"]
path=libs/network/doc/_ext/breathe
url=https://github.com/michaeljones/breathe.git
[submodule "deps/cxxopts"]
path=deps/cxxopts
url=https://github.com/jarro2783/cxxopts.git
3 changes: 1 addition & 2 deletionsCMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,8 +46,7 @@ add_definitions(-DBOOST_TEST_DYN_LINK)
# Always use multi-threaded Boost libraries.
set(Boost_USE_MULTI_THREADED ON)

find_package(Boost 1.57.0
REQUIRED system filesystem program_options)
find_package(Boost 1.57.0 REQUIRED system filesystem)

if (CPP-NETLIB_ENABLE_HTTPS)
find_package( OpenSSL )
Expand Down
1 change: 1 addition & 0 deletionsdeps/cxxopts
Open in desktop
Submodulecxxopts added at aec97a
1 change: 1 addition & 0 deletionslibs/network/example/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
# http://www.boost.org/LICENSE_1_0.txt)

include_directories(${CPP-NETLIB_SOURCE_DIR})
include_directories(${CPP-NETLIB_SOURCE_DIR}/deps/cxxopts/src)
if (OPENSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIR})
endif (OPENSSL_FOUND)
Expand Down
48 changes: 18 additions & 30 deletionslibs/network/example/http_client.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,48 +15,36 @@
#include <string>
#include <utility>
#include <iostream>

namespace po = boost::program_options;
#include "cxxopts.hpp"

int main(int argc, char* argv[]) {
using namespace boost::network;
po::options_description options("Allowed options");
std::string output_filename, source;
bool show_headers;
options.add_options()("help,h", "produce help message")(
"headers,H", "print headers")("status,S", "print status and message")(
"source,s", po::value<std::string>(&source), "source URL");

po::positional_options_description positional_options;
positional_options.add("source", 1);
po::variables_map vm;
try {
po::store(po::command_line_parser(argc, argv)
.options(options)
.positional(positional_options)
.run(),
vm);
po::notify(vm);
}
catch (std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
std::cout << options << std::endl;
return EXIT_FAILURE;
}
cxxopts::Options options(argv[0], "Allowed options");
options.add_options()
("h,help", "produce help message")
("H,headers", "print headers")
("S,status", "print status and message")
("s,source", "source URL", cxxopts::value<std::string>())
;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That looks really nice!


options.parse_positional(std::vector<std::string>{"source"});
options.parse(argc, argv);

if (vm.count("help")) {
std::cout << options << std::endl;
if (options.count("help")) {
std::cout << options.help({"", "Group"}) << std::endl;
return EXIT_SUCCESS;
}

if (vm.count("source") < 1) {
if (options.count("source") < 1) {
std::cout << "Error: Source URL required." << std::endl;
std::cout << options << std::endl;
std::cout << options.help({"", "Group"}) << std::endl;
return EXIT_FAILURE;
}

show_headers = vm.count("headers") ? true : false;
bool show_status = vm.count("status") ? true : false;
std::string source = options["source"].as<std::string>();
bool show_headers = options.count("headers") ? true : false;
bool show_status = options.count("status") ? true : false;

http::client::request request(source);
http::client::string_type destination_ = host(request);
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp