summaryrefslogtreecommitdiffstats
path: root/src/uscxml/util
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2016-12-12 12:58:40 (GMT)
committerStefan Radomski <github@mintwerk.de>2016-12-12 12:58:40 (GMT)
commit7b55e48d57c061bd65e7718a41bfddd90084345e (patch)
treea371c34147528f5ed0a3a8e53bf6c2d52149dcc0 /src/uscxml/util
parent277ca19814890939d5d0e4551e3acb651b1c42e6 (diff)
downloaduscxml-7b55e48d57c061bd65e7718a41bfddd90084345e.zip
uscxml-7b55e48d57c061bd65e7718a41bfddd90084345e.tar.gz
uscxml-7b55e48d57c061bd65e7718a41bfddd90084345e.tar.bz2
Added test / example for pausable eventqueue
Diffstat (limited to 'src/uscxml/util')
-rw-r--r--src/uscxml/util/String.cpp2
-rw-r--r--src/uscxml/util/URL.cpp72
-rw-r--r--src/uscxml/util/URL.h30
3 files changed, 52 insertions, 52 deletions
diff --git a/src/uscxml/util/String.cpp b/src/uscxml/util/String.cpp
index 7334d73..f55b36b 100644
--- a/src/uscxml/util/String.cpp
+++ b/src/uscxml/util/String.cpp
@@ -91,7 +91,7 @@ std::list<std::string> tokenize(const std::string &line, const char sep, bool tr
}
start = i;
}
- if (i + 1 == line.size()) {
+ if (i + 1 == line.size()) {
tokens.push_back(line.substr(start, i + 1 - start));
}
}
diff --git a/src/uscxml/util/URL.cpp b/src/uscxml/util/URL.cpp
index 9329e7e..b9d7bc3 100644
--- a/src/uscxml/util/URL.cpp
+++ b/src/uscxml/util/URL.cpp
@@ -44,7 +44,7 @@
namespace uscxml {
- void URLImpl::prepareException(ErrorEvent& exception, int errorCode, const std::string& origUri, void* parser) {
+void URLImpl::prepareException(ErrorEvent& exception, int errorCode, const std::string& origUri, void* parser) {
exception.data.compound["uri"].atom = origUri;
if (parser != NULL && ((UriParserStateA*)parser)->errorPos != NULL) {
@@ -88,12 +88,12 @@ namespace uscxml {
}
URLImpl::URLImpl() : _handle(NULL), _requestType(GET), _isDownloaded(false), _hasFailed(false) {
- _uri = malloc(sizeof(UriUriA));
+ _uri = malloc(sizeof(UriUriA));
}
URLImpl::URLImpl(const std::string& url) : _orig(url), _handle(NULL), _requestType(GET), _isDownloaded(false), _hasFailed(false) {
UriParserStateA state;
- _uri = malloc(sizeof(UriUriA));
+ _uri = malloc(sizeof(UriUriA));
state.uri = (UriUriA*)_uri;
int err = uriParseUriA(&state, _orig.c_str());
@@ -130,14 +130,14 @@ URLImpl::~URLImpl() {
uriFreeUriMembersA((UriUriA*)_uri);
if (_handle != NULL)
curl_easy_cleanup(_handle);
- free(_uri);
+ free(_uri);
}
URL URLImpl::resolve(URLImpl* relative, URLImpl* absolute) {
std::shared_ptr<URLImpl> dest(new URLImpl());
int err = uriAddBaseUriExA(((UriUriA*)dest->_uri),
- ((UriUriA*)relative->_uri),
- ((UriUriA*)absolute->_uri), URI_RESOLVE_IDENTICAL_SCHEME_COMPAT);
+ ((UriUriA*)relative->_uri),
+ ((UriUriA*)absolute->_uri), URI_RESOLVE_IDENTICAL_SCHEME_COMPAT);
if (err != URI_SUCCESS) {
ErrorEvent exc("Cannot resolve " + (std::string)(*relative) + " with " + (std::string)(*absolute));
prepareException(exc, err, "", NULL);
@@ -168,8 +168,8 @@ URL URLImpl::resolveWithCWD(URLImpl* relative) {
URL URLImpl::refer(URLImpl* absoluteSource, URLImpl* absoluteBase) {
std::shared_ptr<URLImpl> dest(new URLImpl());
int err = uriRemoveBaseUriA(((UriUriA*)dest->_uri),
- ((UriUriA*)absoluteSource->_uri),
- ((UriUriA*)absoluteBase->_uri), URI_FALSE);
+ ((UriUriA*)absoluteSource->_uri),
+ ((UriUriA*)absoluteBase->_uri), URI_FALSE);
if (err != URI_SUCCESS) {
ErrorEvent exc("Cannot make a relative reference for " + (std::string)(*absoluteSource) + " with " + (std::string)(*absoluteBase));
prepareException(exc, err, "", NULL);
@@ -190,28 +190,28 @@ void URLImpl::normalize() {
}
bool URLImpl::isAbsolute() const {
- // see https://sourceforge.net/p/uriparser/bugs/3/
- return ((UriUriA*)_uri)->absolutePath || ((((UriUriA*)_uri)->hostText.first != nullptr) && (((UriUriA*)_uri)->pathHead != nullptr));
+ // see https://sourceforge.net/p/uriparser/bugs/3/
+ return ((UriUriA*)_uri)->absolutePath || ((((UriUriA*)_uri)->hostText.first != nullptr) && (((UriUriA*)_uri)->pathHead != nullptr));
}
std::string URLImpl::scheme() const {
- return USCXML_URI_STRING((*(UriUriA*)_uri), scheme);
+ return USCXML_URI_STRING((*(UriUriA*)_uri), scheme);
}
std::string URLImpl::userInfo() const {
- return USCXML_URI_STRING((*(UriUriA*)_uri), userInfo);
+ return USCXML_URI_STRING((*(UriUriA*)_uri), userInfo);
}
std::string URLImpl::host() const {
- return USCXML_URI_STRING((*(UriUriA*)_uri), hostText);
+ return USCXML_URI_STRING((*(UriUriA*)_uri), hostText);
}
std::string URLImpl::port() const {
- return USCXML_URI_STRING((*(UriUriA*)_uri), portText);
+ return USCXML_URI_STRING((*(UriUriA*)_uri), portText);
}
std::string URLImpl::fragment() const {
- return USCXML_URI_STRING((*(UriUriA*)_uri), fragment);
+ return USCXML_URI_STRING((*(UriUriA*)_uri), fragment);
}
std::string URLImpl::path() const {
@@ -380,47 +380,47 @@ void URLImpl::downloadFailed(int errorCode) {
}
}
-
+
void URLImpl::addOutHeader(const std::string& key, const std::string& value) {
- _outHeader[key] = value;
+ _outHeader[key] = value;
}
void URLImpl::setOutContent(const std::string& content) {
- _outContent = content;
- _requestType = URLRequestType::POST;
+ _outContent = content;
+ _requestType = URLRequestType::POST;
}
void URLImpl::setRequestType(URLRequestType requestType) {
- _requestType = requestType;
-
+ _requestType = requestType;
+
}
const std::map<std::string, std::string> URLImpl::getInHeaderFields() {
- DOWNLOAD_IF_NECESSARY
- return _inHeaders;
+ DOWNLOAD_IF_NECESSARY
+ return _inHeaders;
}
const std::string URLImpl::getInHeaderField(const std::string& key) {
- DOWNLOAD_IF_NECESSARY
- if (_inHeaders.find(key) != _inHeaders.end()) {
- return _inHeaders[key];
- }
- return "";
+ DOWNLOAD_IF_NECESSARY
+ if (_inHeaders.find(key) != _inHeaders.end()) {
+ return _inHeaders[key];
+ }
+ return "";
}
const std::string URLImpl::getStatusCode() const {
- // DOWNLOAD_IF_NECESSARY
- return _statusCode;
+ // DOWNLOAD_IF_NECESSARY
+ return _statusCode;
}
const std::string URLImpl::getStatusMessage() const {
- // DOWNLOAD_IF_NECESSARY
- return _statusMsg;
+ // DOWNLOAD_IF_NECESSARY
+ return _statusMsg;
}
const std::string URLImpl::getInContent(bool forceReload) {
- if (forceReload)
- _isDownloaded = false;
- DOWNLOAD_IF_NECESSARY
- return _rawInContent.str();
+ if (forceReload)
+ _isDownloaded = false;
+ DOWNLOAD_IF_NECESSARY
+ return _rawInContent.str();
}
const void URLImpl::download(bool blocking) {
diff --git a/src/uscxml/util/URL.h b/src/uscxml/util/URL.h
index a603c63..b3f486a 100644
--- a/src/uscxml/util/URL.h
+++ b/src/uscxml/util/URL.h
@@ -54,12 +54,12 @@ public:
URLImpl(const std::string& url);
~URLImpl();
- bool isAbsolute() const;
- std::string scheme() const;
- std::string userInfo() const;
- std::string host() const;
- std::string port() const;
- std::string fragment() const;
+ bool isAbsolute() const;
+ std::string scheme() const;
+ std::string userInfo() const;
+ std::string host() const;
+ std::string port() const;
+ std::string fragment() const;
std::map<std::string, std::string> query() const;
std::string path() const;
std::list<std::string> pathComponents() const;
@@ -78,15 +78,15 @@ public:
}
// downloading / uploading
- void addOutHeader(const std::string& key, const std::string& value);
- void setOutContent(const std::string& content);
- void setRequestType(URLRequestType requestType);
- const std::map<std::string, std::string> getInHeaderFields();
- const std::string getInHeaderField(const std::string& key);
-
- const std::string getStatusCode() const;
- const std::string getStatusMessage() const;
- const std::string getInContent(bool forceReload = false);
+ void addOutHeader(const std::string& key, const std::string& value);
+ void setOutContent(const std::string& content);
+ void setRequestType(URLRequestType requestType);
+ const std::map<std::string, std::string> getInHeaderFields();
+ const std::string getInHeaderField(const std::string& key);
+
+ const std::string getStatusCode() const;
+ const std::string getStatusMessage() const;
+ const std::string getInContent(bool forceReload = false);
const void download(bool blocking = false);
operator Data() const;