commit b99e816f7f3c3a58c1730e98a980ec5b40826c42 Author: Maximilian Stiefel Date: Fri Apr 20 18:13:09 2018 +0200 Initial commit. diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7d3b970 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "dictcc"] + path = dictcc + url = https://github.com/m3x1m0m/dictcc diff --git a/dictcc b/dictcc new file mode 160000 index 0000000..78d4508 --- /dev/null +++ b/dictcc @@ -0,0 +1 @@ +Subproject commit 78d450818192bf700f20422427aca3a81a78bf92 diff --git a/harbour-wordbook.desktop b/harbour-wordbook.desktop new file mode 100644 index 0000000..93aaf8d --- /dev/null +++ b/harbour-wordbook.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=Application +X-Nemo-Application-Type=silica-qt5 +Icon=harbour-wordbook +Exec=harbour-wordbook +Name=harbour-wordbook +# translation example: +# your app name in German locale (de) +# +# Remember to comment out the following line, if you do not want to use +# a different app name in German locale (de). +# Name[de]=harbour-wordbook diff --git a/harbour-wordbook.pro b/harbour-wordbook.pro new file mode 100644 index 0000000..80e8f31 --- /dev/null +++ b/harbour-wordbook.pro @@ -0,0 +1,74 @@ +# NOTICE: +# +# Application name defined in TARGET has a corresponding QML filename. +# If name defined in TARGET is changed, the following needs to be done +# to match new name: +# - corresponding QML filename must be changed +# - desktop icon filename must be changed +# - desktop filename must be changed +# - icon definition filename in desktop file must be changed +# - translation filenames have to be changed + +# The name of your application +TARGET = harbour-wordbook + +CONFIG += sailfishapp + +# Path to installation of CURLPP +CONFIG(debug,debug|release){ CURLPP_PATH = lib/curlpp-inst-arm } +CONFIG(release,debug|release){ CURLPP_PATH = lib/curlpp-inst-i486 } + +# Add curlpp include files +INCLUDEPATH += $$CURLPP_PATH/include + +# Tell linker to link libcurl first, then libcurlpp +LIBS += -lcurl\ +-L$$PWD/$$CURLPP_PATH/lib\ +-lcurlpp + +# Install file on system +lib.files += $$CURLPP_PATH/lib/libcurlpp.so\ +$$CURLPP_PATH/lib/libcurlpp.so.1\ +$$CURLPP_PATH/lib/libcurlpp.so.1.0.0 + +lib.path = /usr/share/$$TARGET/lib +INSTALLS += lib + +SOURCES += src/harbour-wordbook.cpp \ + src/dict_model.cpp \ + dictcc/dict/dict_imp.cc \ + dictcc/dict/desv.cc \ + dictcc/dict/deen.cc + +DISTFILES += qml/harbour-wordbook.qml \ + qml/cover/CoverPage.qml \ + rpm/harbour-wordbook.changes.in \ + rpm/harbour-wordbook.changes.run.in \ + rpm/harbour-wordbook.spec \ + rpm/harbour-wordbook.yaml \ + translations/*.ts \ + harbour-wordbook.desktop \ + qml/pages/About.qml \ + qml/pages/FirstPage.qml + +SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172 + +# to disable building translations every time, comment out the +# following CONFIG line +# CONFIG += sailfishapp_i18n + +# German translation is enabled as an example. If you aren't +# planning to localize your app, remember to comment out the +# following TRANSLATIONS line. And also do not forget to +# modify the localized app name in the the .desktop file. +# TRANSLATIONS += translations/harbour-wordbook-de.ts + +HEADERS += \ + src/dict_model.h \ + dictcc/dict.h \ + dictcc/dict/types.h \ + dictcc/dict/exceptions.h \ + dictcc/dict/dict_int.h \ + dictcc/dict/desv.h \ + dictcc/dict/deen.h \ + dictcc/dict/creator.h diff --git a/harbour-wordbook.pro.user b/harbour-wordbook.pro.user new file mode 100644 index 0000000..ae31ae6 --- /dev/null +++ b/harbour-wordbook.pro.user @@ -0,0 +1,671 @@ + + + + + + EnvironmentId + {80bcf696-971a-458e-b870-5250a3256889} + + + ProjectExplorer.Project.ActiveTarget + 1 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {a1ccde5b-c399-4de9-847c-fecf9ec99eb2} + 0 + 0 + 0 + + /home/maximilian/build-harbour-wordbook-Desktop-Debug + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 3 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 2 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/maximilian/build-harbour-wordbook-Desktop-Release + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 3 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 2 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + /home/maximilian/harbour-wordbook + false + 10234 + 3 + + 2 + + harbour-wordbook + + Qt4ProjectManager.Qt4RunConfiguration:/home/maximilian/harbour-wordbook/harbour-wordbook.pro + true + + harbour-wordbook.pro + false + + /home/maximilian/build-harbour-wordbook-SailfishOS_2_1_4_13_armv7hl_in_Sailfish_OS_Build_Engine-Debug + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.Target.1 + + SailfishOS-2.1.4.13-armv7hl (in Sailfish OS Build Engine) + SailfishOS-2.1.4.13-armv7hl (in Sailfish OS Build Engine) + {78ef6d63-a499-4e0c-a2c9-319195055963} + 0 + 2 + 0 + + /home/maximilian/build-harbour-wordbook-SailfishOS_2_1_4_13_armv7hl_in_Sailfish_OS_Build_Engine-Debug + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 3 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 2 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/maximilian/build-harbour-wordbook-SailfishOS_2_1_4_13_armv7hl_in_Sailfish_OS_Build_Engine-Release + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 3 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 2 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /home/maximilian/build-harbour-wordbook-SailfishOS_2_1_4_13_armv7hl_in_Sailfish_OS_Build_Engine-Profile + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 3 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 2 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + + true + RPM + + QmakeProjectManager.MerRpmBuildStep + + + true + RPM Validation + + QmakeProjectManager.MerRpmValidationStep + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy By Building An RPM Package + + QmakeProjectManager.MerMb2RpmBuildConfiguration + + + + + true + Prepare Target + + QmakeProjectManager.MerPrepareTargetStep + + + true + Rsync + + QmakeProjectManager.MerRsyncDeployStep + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy By Copying Binaries + + QmakeProjectManager.MerRSyncDeployConfiguration + + + + + true + Prepare Target + + QmakeProjectManager.MerPrepareTargetStep + + + true + RPM + + QmakeProjectManager.MerRpmDeployStep + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy As RPM Package + + QmakeProjectManager.MerRpmDeployConfiguration + + 3 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + /home/maximilian/harbour-wordbook + false + 10234 + 3 + + 1 + + harbour-wordbook (on Remote Device) + + QmakeProjectManager.MerRunConfiguration:harbour-wordbook + + harbour-wordbook + 1 + + false + + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/icons/108x108/harbour-wordbook.png b/icons/108x108/harbour-wordbook.png new file mode 100644 index 0000000..ab10628 Binary files /dev/null and b/icons/108x108/harbour-wordbook.png differ diff --git a/icons/128x128/harbour-wordbook.png b/icons/128x128/harbour-wordbook.png new file mode 100644 index 0000000..54375c5 Binary files /dev/null and b/icons/128x128/harbour-wordbook.png differ diff --git a/icons/172x172/harbour-wordbook.png b/icons/172x172/harbour-wordbook.png new file mode 100644 index 0000000..36eee58 Binary files /dev/null and b/icons/172x172/harbour-wordbook.png differ diff --git a/icons/86x86/harbour-wordbook.png b/icons/86x86/harbour-wordbook.png new file mode 100644 index 0000000..ad316d6 Binary files /dev/null and b/icons/86x86/harbour-wordbook.png differ diff --git a/lib/curlpp-inst-arm/bin/curlpp-config b/lib/curlpp-inst-arm/bin/curlpp-config new file mode 100755 index 0000000..10e4d89 --- /dev/null +++ b/lib/curlpp-inst-arm/bin/curlpp-config @@ -0,0 +1,91 @@ +#! /bin/sh +# +# The idea to this kind of setup info script was stolen from numerous +# other packages, such as neon, libxml and gnome. +# +# $Id: curlpp-config.in,v 1.4 2004/10/05 01:48:40 jpbl Exp $ +# +prefix=/home/mersdk/curlpp/curlpp-inst-arm +includedir=include + +usage() +{ + cat < + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (curlpp), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef CURLPP_EASY_HPP +#define CURLPP_EASY_HPP + + +#include "internal/CurlHandle.hpp" +#include "internal/OptionList.hpp" + +#include "Option.hpp" + +#include + + +namespace curlpp +{ + + + /** + * Easy class. + * Detailed description. + */ + + class Easy + { + + public: + + friend struct InfoGetter; + + Easy(); + + /** + * This allow to have a handle, which might have + * some option set, but we don't care about them. + */ + Easy(std::unique_ptr handle); + virtual ~Easy(); + + /** + * it will call the curl_easy_perform function will all the options + * previously set for this handle. + */ + void perform(); + + /** + * This function will set the option value of the OptionBase + * to the handle. + */ + virtual void setOpt(const OptionBase & option); + + /** + * This function will set the option value of the OptionBase to the + * handle. + */ + virtual void setOpt(std::unique_ptr option); + + /** + * This function will set the option value of the OptionBase to the + * handle. + * + * Note: be carefull when using this function, see + * curlpp::OptionList::setOpt(OptionBase * option) function for more + * details. + */ + virtual void setOpt(OptionBase * option); + + /** + * This function will create OptionTrait class with the value given and call + * virtual void setOpt(const OptionBase & option) with it. + */ + template + void setOpt(typename OptionTrait::ParamType); + + /** + * Setting options from custom container with curlpp options. + */ + template + void setOpt(InputIterator first, InputIterator last); + + /** + * This function will get the current option value of the corresponding + * OptionBase. Note that if the option is not set, the option passed in + * parameter will be cleared. (See Option::getOpt for more details) + */ + void getOpt(OptionBase * option) const; + + /** + * This function will get the current option value of the corresponding + * OptionBase. Note that if the option is not set, the option passed in + * parameter will be cleared. (See Option::getOpt for more details) + */ + void getOpt(OptionBase & option) const; + + /** + * Get all options. + */ + //template + //void getOptions(OutputIterator out); + + /* + * This function empties the option collection and reset all options + * to their default value + */ + virtual void reset (); + + /** + * This function will return the cURL * handle. + * DO NOT use this, unless you REALLY know what you + * are doing. + */ + CURL * getHandle() const; + + internal::CurlHandle & getCurlHandle() { return *mCurl; } + const internal::CurlHandle & getCurlHandle() const { return *mCurl; } + + private: + + /** + * This function will call the setOpt on each options + * contained by * the option list passed in argument. + */ + virtual void setOpt(const internal::OptionList & options); + + /** + * This is the function that curlpp::InfoGetter will call + * to retreive option. + */ + template + void getInfo(CURLINFO info, T & value) const; + + std::unique_ptr mCurl; + + internal::OptionList mOptions; + + }; + + +} // namespace curlpp + +namespace cURLpp = curlpp; + +#include "Easy.inl" + +// Not quite sure if we shouldn't pass a const handle and clone it instead. +std::ostream & operator<<(std::ostream & stream, const curlpp::Easy & handle); + + +#endif // #ifndef CURLPP_EASY_HPP diff --git a/lib/curlpp-inst-arm/include/curlpp/Easy.inl b/lib/curlpp-inst-arm/include/curlpp/Easy.inl new file mode 100644 index 0000000..e06bc24 --- /dev/null +++ b/lib/curlpp-inst-arm/include/curlpp/Easy.inl @@ -0,0 +1,48 @@ +/* + * Copyright (c) <2002-2006> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (curlpp), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +template +void curlpp::Easy::getInfo(CURLINFO info, T & value) const +{ + mCurl->getInfo(info, value); +} + + +template +void +curlpp::Easy::setOpt(typename OptionTrait::ParamType value) +{ + setOpt(curlpp::OptionTrait(value)); +} + + +template +void +curlpp::Easy::setOpt(InputIterator first, InputIterator last) +{ + for(InputIterator it=first; it != last; ++it) + { + setOpt(*it); + } +} diff --git a/lib/curlpp-inst-arm/include/curlpp/Exception.hpp b/lib/curlpp-inst-arm/include/curlpp/Exception.hpp new file mode 100644 index 0000000..66b11d0 --- /dev/null +++ b/lib/curlpp-inst-arm/include/curlpp/Exception.hpp @@ -0,0 +1,306 @@ +/* +* Copyright (c) <2002-2009> +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files +* (curlpp), to deal in the Software without restriction, +* including without limitation the rights to use, copy, modify, merge, +* publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, +* subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef CURLPP_EXCEPTION_HPP +#define CURLPP_EXCEPTION_HPP + + + +#include + +#include +#include + + +namespace curlpp +{ + + + /** + * This class is a parent to all curlpp's RuntimeErrors. + * + * This class takes a const std::string & as argument for it's parent: std::runtime_errors. + * This class is thrown when curlpp is encountering an error, but for runtime + * considerations, "unpredictable" by the library user. + */ + + class RuntimeError : public std::runtime_error + { + + public: + + RuntimeError(const char * reason); + RuntimeError(const std::string & string); + virtual ~RuntimeError() throw(); + + }; + + + /** + * This class is a parent to all curlpp's RuntimeErrors. + * + * This class takes a const std::string & as argument for it's parent: std::runtime_errors. + * This class is thrown when curlpp is encountering an error, but for logic + * considerations, "predictable" by the library user. Predictable means + * that the library user is missusing the library. + */ + + class LogicError : public std::logic_error + { + + public: + + LogicError(const char * reason); + LogicError(const std::string & string); + virtual ~LogicError() throw(); + + }; + + + /** + * This is a class derived from curlpp::RuntimeError. + * + * It takes a const char * and a CURLcode as arguments. This class is thrown when libcurl is + * returning an error with a CURLcode, but for runtime considerations, + * "unpredictable" by the library user. + */ + + class LibcurlRuntimeError : public curlpp::RuntimeError + { + + public: + + LibcurlRuntimeError(const std::string & reason, CURLcode code); + LibcurlRuntimeError(const char * reason, CURLcode code); + + /** + * Returns the CURLcode that libcurl returned. + */ + CURLcode whatCode() const throw(); + + private: + + CURLcode mCode; + + }; + + + /* + * This is a class derived from curlpp::LogicError, that takes a const + * char * and a CURLcode as arguments. This class is thrown when libcurl is + * returning an error with a CURLcode, but for logic considerations, + * "predictable" by the library user. Predictable means that the library + * user is missusing the library. + */ + + class LibcurlLogicError : public curlpp::LogicError + { + + public: + + LibcurlLogicError(const std::string & reason, CURLcode code); + LibcurlLogicError(const char * reason, CURLcode code); + + /* + * return the CURLcode that libcurl returned + */ + CURLcode whatCode() const throw(); + + private: + + CURLcode mCode; + + }; + + + /** + * This exception is thrown when you try to retreive a value for an + * unset option. + */ + + class UnsetOption : public curlpp::RuntimeError + { + + public: + + UnsetOption(const std::string & reason); + UnsetOption(const char * reason); + + }; + + + /** + * This exception is thrown when you try to instantiate an option + * that isn't available for your current libcURL version. + */ + + class NotAvailable : public curlpp::LogicError + { + + public: + + NotAvailable(); + + }; + + + /** + * This exception is thrown when an exception is thrown within + * a callback without the curlpp::raiseException function. + */ + + class UnknowException : public curlpp::RuntimeError + { + + public: + + UnknowException(); + + }; + + + /** + * This exception is thrown by the curlpp::raiseException function. + * It's used to throw exceptions within callbacks + */ + + class CallbackExceptionBase : public curlpp::RuntimeError + { + + protected: + + CallbackExceptionBase(); + CallbackExceptionBase(const CallbackExceptionBase & other); + + public: + + virtual void throwMe() = 0; + virtual CallbackExceptionBase * clone() = 0; + + }; + + + /** + * This exception is thrown by the curlpp::raiseException function. + * It's used to throw exceptions within callbacks + */ + + template + class CallbackException : public CallbackExceptionBase + { + + public: + + typedef CallbackException _CE; + + CallbackException(const ExceptionType & e) + : mException(e) + {} + + virtual void throwMe() + { + throw mException; + } + + virtual _CE * clone() + { + return new _CE(*this); + } + + private: + + ExceptionType mException; + + }; + + + /** + * This function is the function to be called within callbacks + * if you want an exception to be thrown at the + * curlpp::Easy::perform function call level. + */ + + template + void raiseException(const T & e) + { + throw (CallbackExceptionBase *)(new CallbackException(e)); + } + + + template + CallbackException * createCallbackException(const T & e) + { + return CallbackException(e); + } + + + /** + * if CURLcode is not equal to CURLE_OK, it throws a + * curlpp::LibcurlRuntimeError with the reason and the code. It's used + * in inline function, because throwing an exception is heavy in binary + * code, something we don't want in inline functions. + */ + + void libcurlRuntimeAssert(const std::string & reason, CURLcode code); + void libcurlRuntimeAssert(const char * reason, CURLcode code); + + + /** + * if CURLcode is not equal to CURLE_OK, it throws a + * curlpp::LibcurlLogicError with the reason and the code. It's used + * in inline function, because throwing an exception is heavy in binary + * code, something we don't want in inline functions. + */ + + void libcurlLogicAssert(const std::string & reason, CURLcode code); + void libcurlLogicAssert(const char * reason, CURLcode code); + + + /** + * if isOkay is false, it throws a curlpp::RuntimeError + * with the reason. It's used in inline function, because throwing + * an exception is heavy in binary code, something we don't want in + * an inline function. + */ + + void runtimeAssert(const std::string & reason, bool isOkay); + void runtimeAssert(const char * reason, bool isOkay); + + + /** + * if is_true is false, it throws a curlpp::LogicError with + * the reason. It's used in inline function, because throwing + * an exception is heavy in binary code, something we don't + * want in an inline function. + */ + + void logicAssert(const std::string & reason, bool isOkay); + void logicAssert(const char * reason, bool isOkay); + + +} // namespace curlpp + +namespace cURLpp = curlpp; + + +#endif // #ifndef CURLPP_EXCEPTION_HPP diff --git a/lib/curlpp-inst-arm/include/curlpp/Form.hpp b/lib/curlpp-inst-arm/include/curlpp/Form.hpp new file mode 100644 index 0000000..c499aee --- /dev/null +++ b/lib/curlpp-inst-arm/include/curlpp/Form.hpp @@ -0,0 +1,272 @@ +/* + * Copyright (c) <2002-2009> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (curlpp), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef CURLPP_FORM_HPP +#define CURLPP_FORM_HPP + + +#include + +#include + +#include +#include + + +namespace curlpp +{ + + + class FormPart; + + + typedef std::list > Forms; + + + /** + * This class is used internally to wrap over curl_httppost + * class. + */ + + class HttpPost + { + + public: + + HttpPost(const Forms & posts); + HttpPost(); + ~HttpPost(); + + /** + * initialize the HTTP post with the list of forms. The Forms + * will be cloned. + */ + HttpPost & operator=(const Forms & posts); + + operator Forms() { return getList(); } + + + /** + * return the curl_httppost representation of this HTTP Post. + * Be aware that the memory return is owned by the current + * instance, so don't try to delete it. + */ + ::curl_httppost * cHttpPost() const; + + /** + * Free all HTTP posts. + */ + void clear(); + + /** + * Get the list. + */ + Forms getList(); + + private: + + ::curl_httppost * mFirst; + ::curl_httppost * mLast; + Forms mForms; + + }; + + + /** + * This class is the base representation of a post. You need + * to inherit from it to define a type of post. + */ + + class FormPart + { + friend class HttpPost; + + public: + + /** + * initialize the FormPart. "name" is the name of the field. + */ + FormPart(const char * name); + + /** + * initialize the FormPart. "name" is the name of the field. + */ + FormPart(const std::string & name); + + virtual ~FormPart(); + + virtual FormPart * clone() const = 0; + + protected: + + /** + * it will add himself to the curl_httppost * first. + */ + virtual void add(::curl_httppost ** first, + ::curl_httppost ** last) = 0; + + /** + * Contain the name of the field. + */ + const std::string mName; + + }; + + +namespace FormParts +{ + + + /** + * This class is a file post. It will send a file in the + * HTTP post. + */ + + class File : public FormPart + { + + public: + + /** + * initialize a File part. "name" is the name of the field. + * "filename" is the string that holds the filename. + */ + File(const char * name, + const char * filename); + + /** + * initialize a File part. "name" is the name of the field. + * "filename" is the string that holds the filename. + * "contentType" is the MIME type of the file. + */ + File(const char * name, + const char * filename, + const char * contentType); + + /** + * initialize a File part. "name" is the name of the field. + * "filename" is the string that holds the filename. + */ + File(const std::string & name, + const std::string & filename); + + /** + * initialize a File part. "name" is the name of the field. + * "filename" is the string that holds the filename. + * "contentType" is the MIME type of the file. + */ + File(const std::string & name, + const std::string & filename, + const std::string & contentType); + + virtual ~File(); + + /** + * This function will return a copy of the instance. + */ + virtual File * clone() const; + + private: + + void add(::curl_httppost ** first, + ::curl_httppost ** last); + + private: + + const std::string mFilename; + const std::string mContentType; + + }; + + + /** + * This class is a file post. It will send a file in the + * HTTP post. + */ + + class Content : public FormPart + { + + public: + + /** + * initialize a Content part. "name" is the name of the field. + * "content" is the string that holds the filename. + */ + Content(const char * name, + const char * content); + + /** + * initialize a Content part. "name" is the name of the field. + * "content" is the string that holds the filename. + * "contentType" is the MIME type of the file. + */ + Content(const char * name, + const char * content, + const char * contentType); + + /** + * initialize a Content part. "name" is the name of the field. + * "content" is the string that holds the content. + */ + Content(const std::string & name, + const std::string & content); + + /** + * initialize a Content part. "name" is the name of the field. + * "content" is the string that holds the content. + * "content_type" is the MIME type of the file. + */ + Content(const std::string & name, + const std::string & content, + const std::string & content_type); + + virtual ~Content(); + + /** + * This function will return a copy of the instance. + */ + virtual Content * clone() const; + + private: + + void add(::curl_httppost ** first, + ::curl_httppost ** last); + + private: + + const std::string mContent; + const std::string mContentType; + + }; + + +} // namespace FormParts + + +} // namespace curlpp + +namespace cURLpp = curlpp; + + +#endif //CURLPP_FORM_HPP diff --git a/lib/curlpp-inst-arm/include/curlpp/Info.hpp b/lib/curlpp-inst-arm/include/curlpp/Info.hpp new file mode 100644 index 0000000..5132218 --- /dev/null +++ b/lib/curlpp-inst-arm/include/curlpp/Info.hpp @@ -0,0 +1,121 @@ +/* + * Copyright (c) <2002-2009> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (curlpp), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef CURLPP_INFO_HPP +#define CURLPP_INFO_HPP + + + +#include "Easy.hpp" + + +namespace curlpp +{ + + + /** + * This class is responsible of retreiving the Info from + * a handle. This is the class you use when you want to do + * so. + */ + + template + struct Info + { + static void get(const curlpp::Easy & handle, T & value); + static T get(const curlpp::Easy & handle); + }; + + + /** + * This class is used when an info is not available for the + * current libcURL version. + */ + + template + struct NotAvailableInfo : Info + { + static void get(const curlpp::Easy & handle, T & value); + static T get(const curlpp::Easy & handle); + }; + + + /** + * This is the class you need to specialize if you use + * a special type that libcURL is not aware of. This class + * need to call curlpp::InfoGetter::get function. See + * curlpp::InfoGetter for more information. + */ + + template + struct InfoTypeConverter + { + static void get(const curlpp::Easy & handle, CURLINFO info, T & value); + }; + + + template<> + void InfoTypeConverter + ::get(const curlpp::Easy & handle, CURLINFO info, std::string & value); + + + template<> + void InfoTypeConverter > + ::get(const curlpp::Easy & handle, CURLINFO info, std::list & value); + + + template<> + void InfoTypeConverter + ::get(const curlpp::Easy & handle, CURLINFO info, long & value); + + + template<> + void InfoTypeConverter + ::get(const curlpp::Easy & handle, CURLINFO info, double & value); + + + /** + * This is the only class that is authorized to retreive + * info from a curlpp::Easy class. So, this is the class + * you need to use when you specialize the class + * curlpp::InfoTypeConverter. This class is in fact used + * as a proxy, just to be sure that nobody access curlpp::Easy's + * private data. + */ + + struct InfoGetter + { + template + static void get(const curlpp::Easy & handle, CURLINFO info, T & value); + }; + + +} // namespace curlpp + +namespace cURLpp = curlpp; + + +#include "Info.inl" + +#endif // #ifndef CURLPP_INFO_HPP diff --git a/lib/curlpp-inst-arm/include/curlpp/Info.inl b/lib/curlpp-inst-arm/include/curlpp/Info.inl new file mode 100644 index 0000000..d15d090 --- /dev/null +++ b/lib/curlpp-inst-arm/include/curlpp/Info.inl @@ -0,0 +1,79 @@ +/* + * Copyright (c) <2002-2006> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (curlpp), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef CURLPP_INFO_INL +#define CURLPP_INFO_INL + +template +void +curlpp::Info::get(const curlpp::Easy & handle, T & value) +{ + curlpp::InfoTypeConverter::get(handle, info, value); +} + +template +T +curlpp::Info::get(const curlpp::Easy & handle) +{ + T value; + curlpp::InfoTypeConverter::get(handle, info, value); + return value; +} + +template +void +curlpp::NotAvailableInfo::get(const curlpp::Easy &, T &) +{ + throw curlpp::NotAvailable(); +} + +template +T +curlpp::NotAvailableInfo::get(const curlpp::Easy &) +{ + throw curlpp::NotAvailable(); +} + + + +template +void +curlpp::InfoGetter::get(const curlpp::Easy & handle, + CURLINFO info, + T & value) +{ + handle.getInfo(info, value); +} + + +template +void +curlpp::InfoTypeConverter::get(const curlpp::Easy & handle, + CURLINFO info, + T & value) +{ + InfoGetter::get(handle, info, value); +} + + +#endif diff --git a/lib/curlpp-inst-arm/include/curlpp/Infos.hpp b/lib/curlpp-inst-arm/include/curlpp/Infos.hpp new file mode 100644 index 0000000..515dfda --- /dev/null +++ b/lib/curlpp-inst-arm/include/curlpp/Infos.hpp @@ -0,0 +1,99 @@ +/* + * Copyright (c) <2002-2009> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (curlpp), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef CURLPP_INFOS_HPP +#define CURLPP_INFOS_HPP + + +#include "Info.hpp" + +#include + +#include + + +namespace curlpp +{ + + +namespace infos +{ + + + typedef curlpp::Info EffectiveUrl; + typedef curlpp::Info ResponseCode; + typedef curlpp::Info HttpConnectCode; + typedef curlpp::Info FileTime; + typedef curlpp::Info TotalTime; + typedef curlpp::Info NameLookupTime; + typedef curlpp::Info ConnectTime; + typedef curlpp::Info PreTransferTime; + typedef curlpp::Info StartTransferTime; + typedef curlpp::Info RedirectTime; + typedef curlpp::Info RedirectCount; + typedef curlpp::Info SizeUpload; + typedef curlpp::Info SizeDownload; + typedef curlpp::Info SpeedDownload; + typedef curlpp::Info SpeedUpload; + typedef curlpp::Info HeaderSize; + typedef curlpp::Info RequestSize; + typedef curlpp::Info SslVerifyResult; +#if LIBCURL_VERSION_NUM >= 0x070c03 + typedef curlpp::Info > SslEngines; +#endif + typedef curlpp::Info ContentLengthDownload; + typedef curlpp::Info ContentLengthUpload; + typedef curlpp::Info ContentType; + typedef curlpp::Info HttpAuthAvail; + typedef curlpp::Info ProxyAuthAvail; +#if LIBCURL_VERSION_NUM >= 0x070c02 + typedef curlpp::Info OsErrno; +#endif +#if LIBCURL_VERSION_NUM >= 0x070c03 + typedef curlpp::Info NumConnects; +#endif + +#if LIBCURL_VERSION_NUM >= 0x070e01 + typedef curlpp::Info > CookieList; +#else +#ifdef CURLPP_ALLOW_NOT_AVAILABLE + // This curlinfo text must be specified, so we specify something + // that we know will be there. + typedef curlpp::NotAvailableInfo > CookieList; +#endif +#endif + + +} // namespace infos + +namespace Infos = infos; + + +} // namespace curlpp + +namespace cURLpp = curlpp; + + +#endif // #ifndef CURLPP_INFOS_HPP diff --git a/lib/curlpp-inst-arm/include/curlpp/Multi.hpp b/lib/curlpp-inst-arm/include/curlpp/Multi.hpp new file mode 100644 index 0000000..c29102e --- /dev/null +++ b/lib/curlpp-inst-arm/include/curlpp/Multi.hpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) <2002-2009> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (curlpp), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef CURLPP_MULTI_HPP +#define CURLPP_MULTI_HPP + + +#include + +#include +#include + + +namespace curlpp +{ + + + class Easy; + + class Multi + { + + public: + + struct Info + { + CURLcode code; + CURLMSG msg; + }; + + public: + + Multi(); + ~Multi(); + + void add(const curlpp::Easy * handle); + void remove(const curlpp::Easy * handle); + + bool perform(int * nbHandles); + void fdset(fd_set * read_fd_set, + fd_set * write_fd_set, + fd_set * exc_fd_set, + int * max_fd); + + typedef std::list > + Msgs; + + Msgs info(); + + private: + + CURLM * mMultiHandle; + std::map mHandles; + }; + + +} // namespace curlpp + +namespace cURLpp = curlpp; + + +#endif // #ifndef CURLPP_MULTI_HPP diff --git a/lib/curlpp-inst-arm/include/curlpp/Option.hpp b/lib/curlpp-inst-arm/include/curlpp/Option.hpp new file mode 100644 index 0000000..5781820 --- /dev/null +++ b/lib/curlpp-inst-arm/include/curlpp/Option.hpp @@ -0,0 +1,253 @@ +/* + * Copyright (c) <2002-2009> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (curlpp), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef CURLPP_OPTION_HPP +#define CURLPP_OPTION_HPP + + +#include "internal/OptionContainer.hpp" + +#include "OptionBase.hpp" + + +namespace curlpp +{ + + + class Easy; + + /** + * This class is representing an option that you set on a class. + * + * We use utilspp::pointer_on_member_function and utilspp::type_trait to simplify + * the declaration of an option object. + */ + + template + class Option : public curlpp::OptionBase + { + + public: + + typedef OT OptionType; + + typedef typename internal::OptionContainer::ParamType ParamType; + typedef typename internal::OptionContainer::ValueType ValueType; + typedef typename internal::OptionContainer::ReturnType ReturnType; + typedef typename internal::OptionContainer::HandleOptionType HandleOptionType; + + protected: + + /** + * The constructor takes the a value to set a handle. + */ + Option(CURLoption option, typename Option::ParamType value); + + /** + * The construction will copy the value of the Option passed in argument. + */ + Option(const Option & other); + + /** + * The constructor will contain an unset option value. + * Note that if you try to retreive the value of this option + * before calling the curlpp::Option::setValue function it will + * throw a UnsetOption exception. + */ + Option(CURLoption option); + + public: + + /** + * What can I say? Everyone is dying one time or another... + */ + virtual ~Option(); + + + /** + * This function will set the value that will be set on handle when we + * will call the "update" function on a handle. + */ + void setValue(typename Option::ParamType value); + + /** + * This function will return the value that this option was set to. + * + * Note: if you didn't set any value by the curlpp::Option::setValue function, + * or the handle option value, retreived by the curlpp::Option::updateMeToHandle + * function, is a unset value, it will throw a UnsetOption exception. + */ + typename Option::ReturnType getValue() const; + + /** + * This function will reset the option value. That means that if you try to + * retreive the value of this option, or if you try to set this option to a + * handle, it will throw an UnsetOption exception. + */ + virtual void clear(); + + /** + * Will update the value of the option with the value of the + * option passed is argument. + */ + virtual void updateMeToOption(const OptionBase & other); + + private: + + /** + * This function will update the given handle to the value previously set, + * by the curlpp::Option::setValue function. + */ + void setOpt(curlpp::Easy * handle) const; + + /** + * This function will update the current value of the option to the handle + * option value. + */ + void getOpt(curlpp::Easy * handle); + + protected: + + /** + * the class that actually have the value. + */ + typename curlpp::internal::OptionContainer * mContainer; + + }; + + + /** + * This class is just a wrapper around curlpp::Option, in order to + * be able to typedef Options. + */ + + template + class OptionTrait : public Option + { + + friend class Easy; + + public: + + static const CURLoption option = opt; + + /** + * The constructor takes the a value to set a handle. + */ + OptionTrait(typename Option::ParamType value); + + /** + * The constructor will contain an unset option value. + * Note that if you try to retreive the value of this option + * before calling the curlpp::Option::setValue function it will + * throw a UnsetOption exception. + */ + OptionTrait(); + + /** + * Return a copy of the current option. + * Note that the option value is copied too. + */ + virtual OptionTrait * clone() const; + + private: + + /** + * will call the actual libcurl option function with the value we got + * on the handle. + */ + virtual void updateHandleToMe(internal::CurlHandle * handle) const; + + }; + + + /** + * This class is just a wrapper around curlpp::OptionTrait, in order to + * be able to have "No value" option, like SslDefaultEngine. + */ + + template + class NoValueOptionTrait : public OptionTrait + { + + public: + + NoValueOptionTrait(); + + /** + * Return a copy of the current option. + * Note that the option value is copied too. + */ + virtual NoValueOptionTrait * clone() const; + + }; + + + /** + * This class is used when the option is not implemented. + */ + + template + class NotAvailableOptionTrait : public Option + { + + public: + + /** + * The constructor takes the a value to set a handle. + */ + NotAvailableOptionTrait(typename Option::ParamType value); + + /** + * The constructor will contain an unset option value. + * Note that if you try to retreive the value of this option + * before calling the curlpp::Option::setValue function it will + * throw a UnsetOption exception. + */ + NotAvailableOptionTrait(); + + /** + * Return a copy of the current option. + * Note that the option value is copied too. + */ + virtual NotAvailableOptionTrait * clone() const; + + private: + + /** + * will call the actual libcurl option function with the value we got + * on the handle. + */ + virtual void updateHandleToMe(internal::CurlHandle * handle) const; + + }; + + +} // namespace curlpp + +namespace cURLpp = curlpp; + + +#include "Option.inl" + +#endif // #ifndef CURLPP_OPTION_HPP diff --git a/lib/curlpp-inst-arm/include/curlpp/Option.inl b/lib/curlpp-inst-arm/include/curlpp/Option.inl new file mode 100644 index 0000000..a7cc5ad --- /dev/null +++ b/lib/curlpp-inst-arm/include/curlpp/Option.inl @@ -0,0 +1,206 @@ +/* + * Copyright (c) <2002-2006> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (curlpp), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef CURLPP_OPTION_INL +#define CURLPP_OPTION_INL + +#include "internal/OptionSetter.hpp" +#include "Exception.hpp" + +#include + + +namespace curlpp +{ + + +// Option + +template +Option::Option(CURLoption option, typename Option::ParamType value) +: OptionBase(option), +mContainer(NULL) +{ + setValue(value); +} + + +template +Option::Option(CURLoption option) +: OptionBase(option), +mContainer(NULL) +{} + +template +Option::Option(const Option & other) + : OptionBase(other) + , mContainer(NULL) +{ + if(other.mContainer != NULL) + { + setValue(other.getValue()); + } +} + + +template +Option::~Option() +{ + delete mContainer; + mContainer = NULL; +} + + +template +void +Option::setValue(typename Option::ParamType value) +{ + if(mContainer == NULL) + { + mContainer = new internal::OptionContainer(value); + } + else + { + mContainer->setValue(value); + } +} + + +template +void +Option::updateMeToOption(const OptionBase & other) +{ + const Option * option = dynamic_cast *>(&other); + if(option == NULL) + { + throw UnsetOption("You are trying to update an option to an incompatible option"); + } + setValue(option->getValue()); +} + +template +void +Option::clear() +{ + delete mContainer; + mContainer = NULL; +} + +template +typename Option::ReturnType +Option::getValue() const +{ + if(mContainer == NULL) + throw UnsetOption("You are trying to retreive the value of an unset option"); + + return mContainer->getValue(); +} + + +// OptionTrait + +template +OptionTrait::OptionTrait(typename Option::ParamType value) +: Option(option, value) +{} + + +template +OptionTrait::OptionTrait() +: Option(option) +{} + + +template +OptionTrait * +OptionTrait::clone() const +{ + return new OptionTrait(this->getValue()); +} + + +template +void +OptionTrait::updateHandleToMe(internal::CurlHandle * handle) const +{ + if(this->mContainer == NULL) + { + throw UnsetOption("You are trying to set an unset option to a handle"); + } + + internal::OptionSetter::setOpt(handle, this->mContainer->getHandleOptionValue()); +} + + +// NoValueOptionTrait + +template +NoValueOptionTrait