Pass pugi xml_mode by value; refine coding style.

This commit is contained in:
Adam Gu
2018-05-23 13:07:17 +08:00
parent b41dfcebd9
commit 79665c75ba
16 changed files with 51 additions and 61 deletions
+4 -4
View File
@@ -9,7 +9,7 @@
#include "webcc/http_response.h"
#include "webcc/rest_client.h"
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// Write a JSON object to string.
std::string JsonToString(const Json::Value& json) {
@@ -17,7 +17,7 @@ std::string JsonToString(const Json::Value& json) {
return Json::writeString(builder, json);
}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
class BookListClient {
public:
@@ -62,7 +62,7 @@ private:
webcc::RestClient rest_client_;
};
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
class BookDetailClient {
public:
@@ -118,7 +118,7 @@ private:
webcc::RestClient rest_client_;
};
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
void Help(const char* argv0) {
std::cout << "Usage: " << argv0 << " <host> <port>" << std::endl;
+8 -6
View File
@@ -2,10 +2,11 @@
#include <list>
#include <iostream>
#include "boost/lexical_cast.hpp"
#include "json/json.h" // jsoncpp
////////////////////////////////////////////////////////////////////////////////
#include "boost/lexical_cast.hpp"
#include "json/json.h"
// -----------------------------------------------------------------------------
// In-memory test data.
// There should be some database in a real product.
@@ -97,7 +98,7 @@ private:
static BookStore g_book_store;
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
static bool BookFromJson(const std::string& json, Book* book) {
Json::Value root;
@@ -142,7 +143,7 @@ bool BookListService::Post(const std::string& request_content,
return false;
}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
bool BookDetailService::Get(const std::vector<std::string>& url_sub_matches,
const webcc::UrlQuery& query,
@@ -182,7 +183,8 @@ bool BookDetailService::Put(const std::vector<std::string>& url_sub_matches,
return false;
}
bool BookDetailService::Delete(const std::vector<std::string>& url_sub_matches) {
bool BookDetailService::Delete(
const std::vector<std::string>& url_sub_matches) {
if (url_sub_matches.size() != 1) {
return false;
}
+2 -2
View File
@@ -3,7 +3,7 @@
#include "webcc/rest_service.h"
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// BookListService handles the HTTP GET and returns the book list based on
// query parameters specified in the URL.
@@ -25,7 +25,7 @@ class BookListService : public webcc::RestListService {
std::string* response_content) final;
};
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// The URL is like '/books/{BookID}', and the 'url_sub_matches' parameter
// contains the matched book ID.
+1 -1
View File
@@ -3,7 +3,7 @@
#include "calc_client.h"
int main() {
LOG_INIT(webcc::INFO, 0);
LOG_INIT(webcc::VERB, 0);
CalcClient calc;