Program Listing for File Object.h
↰ Return to documentation for file (axr.sdk/Object.h
)
// Copyright (C) AcceleratXR, Inc. All rights reserved.
#pragma once
#include "Variant.h"
#include <any>
#include <cpprest/details/basic_types.h>
#include <map>
#include <variant>
#include <vector>
namespace axr {
namespace sdk {
class Object
{
public:
Object();
Object(const Object& value) noexcept;
Object(Object&& value) noexcept;
Object(const std::map<utility::string_t, Variant>& map);
Object(std::map<utility::string_t, Variant>&& map);
Object(const Variant& obj);
Object& operator=(const Object& other) noexcept;
Object& operator=(Object&& other) noexcept;
Object& operator=(const Variant& obj);
bool operator==(const Object& other) noexcept;
bool operator!=(const Object& other) noexcept;
inline Variant& operator[](const utility::char_t* name)
{
return m_properties.find(name)->second;
}
inline Variant& operator[](const utility::string_t& name)
{
return m_properties.find(name)->second;
}
virtual ~Object();
static const utility::char_t* ClassName()
{
return _XPLATSTR("axr::sdk::Object");
}
static Object Parse(json::Value& value);
static Object Parse(const utility::string_t& json);
utility::string_t GetRemoteUrl() const;
virtual Object& SetRemoteUrl(const utility::string_t& url);
std::map<utility::string_t, Variant>& GetProperties();
virtual Object& SetProperties(const std::map<utility::string_t, Variant>& value);
virtual Object& SetProperties(std::map<utility::string_t, Variant>&& value);
inline bool HasProperty(const utility::char_t* name) const { return m_properties.find(name) != m_properties.cend(); }
inline bool HasProperty(const utility::string_t& name) const { return m_properties.find(name) != m_properties.cend(); }
inline Variant GetProperty(const utility::char_t* name) const
{
return HasProperty(name) ? m_properties.find(name)->second : Variant();
}
template<class T>
T GetProperty(const utility::char_t* name) const;
inline Variant GetProperty(const utility::string_t& name) const
{
return HasProperty(name) ? m_properties.find(name)->second : Variant();
}
template<class T>
T GetProperty(const utility::string_t& name) const;
void RemoveProperty(const utility::char_t* name);
void RemoveProperty(const utility::string_t& name);
virtual Object& SetProperty(const utility::char_t* name, const Variant& value);
virtual Object& SetProperty(const utility::string_t& name, const Variant& value);
void CopyFrom(const Object& other);
void CopyFrom(std::shared_ptr<Object> other);
void MoveFrom(Object&& other);
void MoveFrom(std::shared_ptr<Object> other);
void ToString(json::StringWriter& writer) const;
utility::string_t ToString() const;
protected:
std::map<utility::string_t,Variant> m_properties;
utility::string_t m_remoteUrl;
};
} // namespace axr
} // namespace sdk