11#include " cppjson/object.hpp"
2+ #include < cstring>
23#include < new>
34#include < stdexcept>
4- #include < cstring>
55#include < utility>
66
77constexpr std::size_t DataStorageSize = std::max({sizeof (std::string), sizeof (cppjson::Object), sizeof (double ), sizeof (bool )});
@@ -11,34 +11,34 @@ cppjson::JsonObject::JsonObject() : _dataStorage(static_cast<std::byte*>(::opera
1111cppjson::JsonObject::JsonObject (const cppjson::JsonObject& other)
1212{
1313 if (other._dataStorage == nullptr ) return ;
14-
14+
1515 this ->_dataType = other._dataType ;
1616 this ->_dataStorage = static_cast <std::byte*>(::operator new (DataStorageSize));
1717 std::memcpy (this ->_dataStorage , other._dataStorage , DataStorageSize);
1818}
1919cppjson::JsonObject::JsonObject (JsonObject&& other) noexcept
2020{
21- this ->_dataType = std::exchange (other._dataType , cppjson::JsonType::Null);
22- this ->_dataStorage = std::exchange (other._dataStorage , static_cast <std::byte*>(::operator new (DataStorageSize)));
21+ this ->_dataType = std::exchange (other._dataType , cppjson::JsonType::Null);
22+ this ->_dataStorage = std::exchange (other._dataStorage , static_cast <std::byte*>(::operator new (DataStorageSize)));
2323}
2424cppjson::JsonObject& cppjson::JsonObject::operator =(const cppjson::JsonObject& other)
2525{
26- if (&other != this )
27- {
26+ if (&other != this )
27+ {
2828 this ->_dataType = other._dataType ;
2929 this ->_dataStorage = static_cast <std::byte*>(::operator new (DataStorageSize));
30- std::memcpy (this ->_dataStorage , other._dataStorage , DataStorageSize);
30+ std::memcpy (this ->_dataStorage , other._dataStorage , DataStorageSize);
3131 }
32- return *this ;
32+ return *this ;
3333}
3434cppjson::JsonObject& cppjson::JsonObject::operator =(cppjson::JsonObject&& other) noexcept
3535{
36- if (&other != this )
37- {
36+ if (&other != this )
37+ {
3838 this ->_dataType = std::exchange (other._dataType , cppjson::JsonType::Null);
3939 this ->_dataStorage = std::exchange (other._dataStorage , static_cast <std::byte*>(::operator new (DataStorageSize)));
4040 }
41- return *this ;
41+ return *this ;
4242}
4343cppjson::JsonObject::~JsonObject ()
4444{
@@ -48,9 +48,9 @@ cppjson::JsonObject::~JsonObject()
4848
4949void cppjson::JsonObject::Destroy (void )
5050{
51- using std::string;
52- using cppjson::Object;
5351 using cppjson::Array;
52+ using cppjson::Object;
53+ using std::string;
5454
5555 switch (std::exchange (this ->_dataType , JsonType::Null))
5656 {
@@ -179,13 +179,9 @@ const std::nullptr_t& cppjson::JsonObject::As<std::nullptr_t>() const noexcept(f
179179 return DangerousAs<std::nullptr_t >();
180180}
181181
182- cppjson::Object::ObjectProxy cppjson::Object::ObjectProxy::operator [](const std::string& key)
183- {
184- return ObjectProxy{ this ->_object .get ().As <Object>()[key] };
185- }
186-
182+ cppjson::Object::ObjectProxy cppjson::Object::ObjectProxy::operator [](const std::string& key) { return ObjectProxy{this ->_object .get ().As <Object>()[key]}; }
187183
188184cppjson::Object::ConstObjectProxy cppjson::Object::ConstObjectProxy::operator [](const std::string& key) const
189185{
190- return ConstObjectProxy{ this ->_object .get ().As <Object>()[key] };
186+ return ConstObjectProxy{this ->_object .get ().As <Object>()[key]};
191187}
0 commit comments