summaryrefslogtreecommitdiffstats
path: root/src/uscxml/Utilities.h
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-10-05 15:31:26 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-10-05 15:31:26 (GMT)
commit0ae6c27d9322208053033d9b19c0ffffed3d99eb (patch)
tree0794b4df38568e03fb01e7fa91e6d4a625db859e /src/uscxml/Utilities.h
parent64cc2ce105cf57fcba637b309664b4bc74ae7d82 (diff)
downloaduscxml-0ae6c27d9322208053033d9b19c0ffffed3d99eb.zip
uscxml-0ae6c27d9322208053033d9b19c0ffffed3d99eb.tar.gz
uscxml-0ae6c27d9322208053033d9b19c0ffffed3d99eb.tar.bz2
Implemented DOM
Diffstat (limited to 'src/uscxml/Utilities.h')
-rw-r--r--src/uscxml/Utilities.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/uscxml/Utilities.h b/src/uscxml/Utilities.h
new file mode 100644
index 0000000..d8fd0f8
--- /dev/null
+++ b/src/uscxml/Utilities.h
@@ -0,0 +1,52 @@
+#ifndef UTILITIES_H_A89E99LI
+#define UTILITIES_H_A89E99LI
+
+#include <string>
+#include <sstream>
+#include <curl/curl.h>
+
+// see http://stackoverflow.com/questions/228005/alternative-to-itoa-for-converting-integer-to-string-c
+template <typename T> std::string toStr(T tmp) {
+ std::ostringstream out;
+ out << tmp;
+ return out.str();
+}
+
+template <typename T> T strTo(std::string tmp) {
+ T output;
+ std::istringstream in(tmp);
+ in >> output;
+ return output;
+}
+
+
+enum fcurl_type_e {
+ CFTYPE_NONE=0,
+ CFTYPE_FILE=1,
+ CFTYPE_CURL=2
+};
+
+struct fcurl_data
+{
+ enum fcurl_type_e type; /* type of handle */
+ union {
+ CURL *curl;
+ FILE *file;
+ } handle; /* handle */
+
+ char *buffer; /* buffer to store cached data*/
+ size_t buffer_len; /* currently allocated buffers length */
+ size_t buffer_pos; /* end of data in buffer*/
+ int still_running; /* Is background url fetch still in progress */
+};
+
+typedef struct fcurl_data URL_FILE;
+
+URL_FILE *url_fopen(const char *url,const char *operation);
+int url_fclose(URL_FILE *file);
+int url_feof(URL_FILE *file);
+size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file);
+char * url_fgets(char *ptr, size_t size, URL_FILE *file);
+void url_rewind(URL_FILE *file);
+
+#endif /* end of include guard: UTILITIES_H_A89E99LI */