|
|
|
@ -1,12 +1,17 @@
|
|
|
|
|
#include "webcc/utility.h"
|
|
|
|
|
|
|
|
|
|
#include <ctime>
|
|
|
|
|
#include <iomanip> // for put_time
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
#include "boost/algorithm/string.hpp"
|
|
|
|
|
#include "boost/uuid/random_generator.hpp"
|
|
|
|
|
#include "boost/uuid/uuid_io.hpp"
|
|
|
|
|
|
|
|
|
|
#include "webcc/version.h"
|
|
|
|
|
|
|
|
|
|
namespace webcc {
|
|
|
|
|
namespace utility {
|
|
|
|
|
|
|
|
|
|
std::string RandomUuid() {
|
|
|
|
|
boost::uuids::uuid u = boost::uuids::random_generator()();
|
|
|
|
@ -15,6 +20,18 @@ std::string RandomUuid() {
|
|
|
|
|
return ss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::string& UserAgent() {
|
|
|
|
|
static auto s_user_agent = std::string("Webcc/") + WEBCC_VERSION;
|
|
|
|
|
return s_user_agent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string GetTimestamp() {
|
|
|
|
|
std::time_t t = std::time(nullptr);
|
|
|
|
|
std::stringstream ss;
|
|
|
|
|
ss << std::put_time(std::gmtime(&t), "%a, %d %b %Y %H:%M:%S") << " GMT";
|
|
|
|
|
return ss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SplitKV(const std::string& str, char delimiter,
|
|
|
|
|
std::string* part1, std::string* part2) {
|
|
|
|
|
std::size_t pos = str.find(delimiter);
|
|
|
|
@ -31,4 +48,5 @@ bool SplitKV(const std::string& str, char delimiter,
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace utility
|
|
|
|
|
} // namespace webcc
|
|
|
|
|