From d113f60ca153c698476a235ba4b1a5c345a03f07 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sat, 27 Apr 2019 23:48:15 +0200 Subject: [PATCH] RsUrl add method to test presence and get fields from query --- libretroshare/src/util/rsurl.cc | 7 +++++++ libretroshare/src/util/rsurl.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/libretroshare/src/util/rsurl.cc b/libretroshare/src/util/rsurl.cc index 563f151cc..e625815e4 100644 --- a/libretroshare/src/util/rsurl.cc +++ b/libretroshare/src/util/rsurl.cc @@ -201,6 +201,13 @@ RsUrl& RsUrl::delQueryK(const std::string& key) mQuery.erase(key); return *this; } +bool RsUrl::hasQueryK(const std::string& key) +{ return (mQuery.find(key) != mQuery.end()); } +const std::string* RsUrl::getQueryV(const std::string& key) +{ + if(hasQueryK(key)) return &(mQuery.find(key)->second); + return nullptr; +} const std::string& RsUrl::fragment() const { return mFragment; } RsUrl& RsUrl::setFragment(const std::string& fragment) diff --git a/libretroshare/src/util/rsurl.h b/libretroshare/src/util/rsurl.h index b1975d574..f02c7f636 100644 --- a/libretroshare/src/util/rsurl.h +++ b/libretroshare/src/util/rsurl.h @@ -59,6 +59,8 @@ struct RsUrl : RsSerializable RsUrl& setQuery(const std::map& query); RsUrl& setQueryKV(const std::string& key, const std::string& value); RsUrl& delQueryK(const std::string& key); + bool hasQueryK(const std::string& key); + const std::string* getQueryV(const std::string& key); const std::string& fragment() const; RsUrl& setFragment(const std::string& fragment);