#include <time.h>
#include <boost/foreach.hpp>
+#include <boost/algorithm/string.hpp>
+
+namespace ba = boost::algorithm;
using namespace std;
*/
list<string> DHS::separate_domain_and_host_part(const string& fqdn) const
{
- list<string> splitted = split(fqdn,".");
+ list<string> splitted;
+ ba::split(splitted,fqdn,boost::is_any_of("."));
if ( splitted.size() > 1 )
{
/**
- * Splitts a string into single tokens useing given delimiters
- * @param str String to split
- * @param delimiters Deliminters to use
- * @return A list with the single tokens
- */
-list<string> DHS::split(const string& str,const string& delimiters) const
-{
- list<string> tokens;
- // Skip delimiters at beginning.
- string::size_type lastPos = str.find_first_not_of(delimiters, 0);
- // Find first "non-delimiter".
- string::size_type pos = str.find_first_of(delimiters, lastPos);
-
- while (string::npos != pos || string::npos != lastPos)
- {
- // Found a token, add it to the list.
- tokens.push_back(str.substr(lastPos, pos - lastPos));
- // Skip delimiters. Note the "not_of"
- lastPos = str.find_first_not_of(delimiters, pos);
- // Find next "non-delimiter"
- pos = str.find_first_of(delimiters, lastPos);
- }
- return tokens;
-}
-
-
-/**
* Performs the Service update.
* @param ip IP Address to set.
* @return 0 if all is fine, -1 otherwise.
HTTPHelper::Ptr HTTPHelp;
- std::list<std::string> split(const std::string& str,const std::string& delimiters) const;
-
std::list<std::string> separate_domain_and_host_part(const std::string& str) const;
std::string assemble_base_url(const std::string& hostname, const std::string& domain_part) const;
#include <time.h>
#include <boost/foreach.hpp>
+#include <boost/algorithm/string.hpp>
+
+namespace ba = boost::algorithm;
using namespace std;
*/
string DYNS::parse_status_code(const string& data) const
{
- list<string> tokens = split(data," ");
- return tokens.front();
-}
-
-
-/**
- * Splitts a string into single tokens useing given delimiters
- * @param str String to split
- * @param delimiters Deliminters to use
- * @return A list with the single tokens
- */
-list<string> DYNS::split(const string& str,const string& delimiters) const
-{
list<string> tokens;
- // Skip delimiters at beginning.
- string::size_type lastPos = str.find_first_not_of(delimiters, 0);
- // Find first "non-delimiter".
- string::size_type pos = str.find_first_of(delimiters, lastPos);
-
- while (string::npos != pos || string::npos != lastPos)
- {
- // Found a token, add it to the list.
- tokens.push_back(str.substr(lastPos, pos - lastPos));
- // Skip delimiters. Note the "not_of"
- lastPos = str.find_first_not_of(delimiters, pos);
- // Find next "non-delimiter"
- pos = str.find_first_of(delimiters, lastPos);
- }
- return tokens;
+ ba::split(tokens,data,boost::is_any_of(" "));
+ return tokens.front();
}
std::string parse_status_code(const std::string& data) const;
- std::list<std::string> split(const std::string& str,const std::string& delimiters) const;
-
public:
typedef boost::shared_ptr<DYNS> Ptr;
#include <time.h>
#include <boost/foreach.hpp>
+#include <boost/algorithm/string.hpp>
+
+namespace ba = boost::algorithm;
using namespace std;
// TODO: There is a list with all two level TLD's, use it
// split the domain_part
- list<string> domain_tokens = split(domain_part,".");
+ list<string> domain_tokens;
+ ba::split(domain_tokens,domain_part,boost::is_any_of("."));
domain_tokens.pop_front();
*/
list<string> EASYDNS::separate_domain_and_host_part(const string& fqdn) const
{
- list<string> splitted = split(fqdn,".");
+ list<string> splitted;
+ ba::split(splitted,fqdn,boost::is_any_of("."));
if ( splitted.size() > 1 )
{
/**
- * Splitts a string into single tokens useing given delimiters
- * @param str String to split
- * @param delimiters Deliminters to use
- * @return A list with the single tokens
- */
-list<string> EASYDNS::split(const string& str,const string& delimiters) const
-{
- list<string> tokens;
- // Skip delimiters at beginning.
- string::size_type lastPos = str.find_first_not_of(delimiters, 0);
- // Find first "non-delimiter".
- string::size_type pos = str.find_first_of(delimiters, lastPos);
-
- while (string::npos != pos || string::npos != lastPos)
- {
- // Found a token, add it to the list.
- tokens.push_back(str.substr(lastPos, pos - lastPos));
- // Skip delimiters. Note the "not_of"
- lastPos = str.find_first_not_of(delimiters, pos);
- // Find next "non-delimiter"
- pos = str.find_first_of(delimiters, lastPos);
- }
- return tokens;
-}
-
-
-/**
* Performs the Service update.
* @param ip IP Address to set.
* @return 0 if all is fine, -1 otherwise.
HTTPHelper::Ptr HTTPHelp;
- std::list<std::string> split(const std::string& str,const std::string& delimiters) const;
-
std::list<std::string> separate_domain_and_host_part(const std::string& str) const;
std::string assemble_base_url(const std::string& hostname, const std::string& two_level_tld) const;