Initial work on RsFiles links support in libretroshare

This commit is contained in:
Gioacchino Mazzurco 2020-03-11 23:11:59 +01:00
parent b6c5e2f188
commit 55d466f79b
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
16 changed files with 438 additions and 179 deletions

View file

@ -62,7 +62,6 @@ bool myFunnyFunction(
*/
#define RS_DEFAULT_STORAGE_PARAM(Type,...) *std::unique_ptr<Type>(new Type(__VA_ARGS__))
/** @brief Safely dynamic cast between std::unique_ptr of different types
* std::unique_ptr semantic rely on the invariant that only one instance own
* the object, when casting between differents types one would be tempted to do
@ -90,6 +89,16 @@ bool rs_unique_cast(
return false;
}
/** Mark a pointer as non-owned aka you are not in charge of deleting it and
* must not delete it.
* @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1408r0.pdf */
template<typename T> using rs_view_ptr = T*;
/** Mark a pointer as owned aka you are in charge of deletingonce finished
* dealing with it.
* @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1408r0.pdf */
template<typename T> using rs_owner_ptr = T*;
void *rs_malloc(size_t size) ;

View file

@ -224,7 +224,7 @@ RsUrl& RsUrl::delQueryK(const std::string& key)
}
bool RsUrl::hasQueryK(const std::string& key)
{ return (mQuery.find(key) != mQuery.end()); }
const std::string* RsUrl::getQueryV(const std::string& key)
rs_view_ptr<const std::string> RsUrl::getQueryV(const std::string& key)
{
if(hasQueryK(key)) return &(mQuery.find(key)->second);
return nullptr;

View file

@ -20,6 +20,7 @@
#include <string>
#include <map>
#include "util/rsmemory.h"
#include "serialiser/rsserializable.h"
struct sockaddr_storage;
@ -63,7 +64,7 @@ struct RsUrl : RsSerializable
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);
rs_view_ptr<const std::string> getQueryV(const std::string& key);
const std::string& fragment() const;
RsUrl& setFragment(const std::string& fragment);