fson  1.0.2
A comment-preserving C++ library for FSON — a human-friendly superset of JSON / JSON5
fedem::fson::Object Class Referencefinal

#include <Object.hh>

+ Inheritance diagram for fedem::fson::Object:
+ Collaboration diagram for fedem::fson::Object:

Classes

struct  Entry
 
struct  Provenance
 

Public Types

enum class  EntryKind { Member , Include }
 
- Public Types inherited from fedem::fson::Value
enum class  Type {
  Null , Boolean , Number , String ,
  Array , Object
}
 

Public Member Functions

 Object ()=default
 
Type getType () const noexcept override
 
std::unique_ptr< Valueclone () const override
 
ObjectasObject () noexcept override
 
Object const * asObject () const noexcept override
 
std::size_t size () const noexcept
 
bool empty () const noexcept
 
bool contains (std::string const &name) const noexcept
 
Valuefind (std::string const &name) noexcept
 
Value const * find (std::string const &name) const noexcept
 
Valueat (std::string const &name)
 
Value const & at (std::string const &name) const
 
Valueset (Key key, std::unique_ptr< Value > value)
 
Valueset (std::string const &name, std::unique_ptr< Value > value)
 
bool remove (std::string const &name) noexcept
 
bool disable (std::string const &name) noexcept
 
bool enable (std::string const &name) noexcept
 
ValuefindPath (std::string const &path) noexcept
 
Value const * findPath (std::string const &path) const noexcept
 
bool containsPath (std::string const &path) const noexcept
 
ValueatPath (std::string const &path)
 
Value const & atPath (std::string const &path) const
 
ValuesetPath (std::string const &path, std::unique_ptr< Value > value)
 
bool removePath (std::string const &path) noexcept
 
bool isLocal (std::string const &path) const noexcept
 
std::optional< ProvenanceprovenanceOf (std::string const &path) const
 
std::vector< ProvenanceprovenanceMap () const
 
std::string getString (std::string const &path, std::string const &fallback=std::string()) const
 
long long getInteger (std::string const &path, long long fallback=0LL) const noexcept
 
double getDouble (std::string const &path, double fallback=0.0) const noexcept
 
bool getBoolean (std::string const &path, bool fallback=false) const noexcept
 
std::size_t memberCount () const noexcept
 
MembergetMember (std::size_t index)
 
Member const & getMember (std::size_t index) const
 
MemberappendMember (Member member)
 
void eraseMember (std::size_t index)
 
std::size_t includeCount () const noexcept
 
IncludegetInclude (std::size_t index)
 
Include const & getInclude (std::size_t index) const
 
IncludeappendInclude (Include include)
 
void eraseInclude (std::size_t index)
 
std::size_t entryCount () const noexcept
 
Entry const & getEntry (std::size_t position) const
 
CommentListgetDanglingComments () noexcept
 
CommentList const & getDanglingComments () const noexcept
 
- Public Member Functions inherited from fedem::fson::Value
virtual ~Value ()
 
bool isNull () const noexcept
 
bool isBoolean () const noexcept
 
bool isNumber () const noexcept
 
bool isString () const noexcept
 
bool isArray () const noexcept
 
bool isObject () const noexcept
 
virtual NullasNull () noexcept
 
virtual Null const * asNull () const noexcept
 
virtual BooleanasBoolean () noexcept
 
virtual Boolean const * asBoolean () const noexcept
 
virtual NumberasNumber () noexcept
 
virtual Number const * asNumber () const noexcept
 
virtual StringasString () noexcept
 
virtual String const * asString () const noexcept
 
virtual ArrayasArray () noexcept
 
virtual Array const * asArray () const noexcept
 

Private Member Functions

std::size_t findActiveIndex (std::string const &name) const noexcept
 
void rebuildEntryIndices (EntryKind kind, std::size_t removedIndex) noexcept
 
Member const * findOwningMember (std::string const &path) const noexcept
 

Private Attributes

std::vector< Membermembers
 
std::vector< Includeincludes
 
std::vector< Entryentries
 
CommentList dangling
 

Static Private Attributes

static constexpr std::size_t const NPOS = static_cast< std::size_t >( -1 )
 

Additional Inherited Members

- Protected Member Functions inherited from fedem::fson::Value
 Value ()=default
 

Member Enumeration Documentation

◆ EntryKind

Enumerator
Member 
Include 

Constructor & Destructor Documentation

◆ Object()

fedem::fson::Object::Object ( )
default

Member Function Documentation

◆ getType()

Value::Type fedem::fson::Object::getType ( ) const
inlineoverridevirtualnoexcept

Implements fedem::fson::Value.

◆ clone()

unique_ptr< Value > fedem::fson::Object::clone ( ) const
overridevirtual

Implements fedem::fson::Value.

References dangling, entries, includes, and members.

◆ asObject() [1/2]

Object * fedem::fson::Object::asObject ( )
inlineoverridevirtualnoexcept

Reimplemented from fedem::fson::Value.

◆ asObject() [2/2]

Object const * fedem::fson::Object::asObject ( ) const
inlineoverridevirtualnoexcept

Reimplemented from fedem::fson::Value.

◆ size()

size_t fedem::fson::Object::size ( ) const
noexcept

References members.

◆ empty()

bool fedem::fson::Object::empty ( ) const
inlinenoexcept

◆ contains()

bool fedem::fson::Object::contains ( std::string const &  name) const
inlinenoexcept

◆ find() [1/2]

Value * fedem::fson::Object::find ( std::string const &  name)
noexcept

References index.

Referenced by at(), findOwningMember(), findPath(), removePath(), and setPath().

+ Here is the caller graph for this function:

◆ find() [2/2]

Value const * fedem::fson::Object::find ( std::string const &  name) const
noexcept

References index.

◆ at() [1/2]

Value & fedem::fson::Object::at ( std::string const &  name)

References find().

+ Here is the call graph for this function:

◆ at() [2/2]

Value const & fedem::fson::Object::at ( std::string const &  name) const

References find().

+ Here is the call graph for this function:

◆ set() [1/2]

Value & fedem::fson::Object::set ( Key  key,
std::unique_ptr< Value value 
)

References entries, findActiveIndex(), index, key, Member, members, and NPOS.

Referenced by set(), and setPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set() [2/2]

Value & fedem::fson::Object::set ( std::string const &  name,
std::unique_ptr< Value value 
)

References fedem::fson::Key::bare(), fedem::fson::Key::isValidName(), key, fedem::fson::Key::quoted(), and set().

+ Here is the call graph for this function:

◆ remove()

bool fedem::fson::Object::remove ( std::string const &  name)
noexcept

References index.

Referenced by removePath(), and setPath().

+ Here is the caller graph for this function:

◆ disable()

bool fedem::fson::Object::disable ( std::string const &  name)
noexcept

References index.

◆ enable()

bool fedem::fson::Object::enable ( std::string const &  name)
noexcept

◆ findPath() [1/2]

Value * fedem::fson::Object::findPath ( std::string const &  path)
noexcept

References fedem::fson::Value::asArray(), fedem::fson::Value::asObject(), fedem::fson::Array::at(), find(), and fedem::fson::Array::size().

Referenced by atPath(), getString(), and provenanceOf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findPath() [2/2]

Value const * fedem::fson::Object::findPath ( std::string const &  path) const
noexcept

◆ containsPath()

bool fedem::fson::Object::containsPath ( std::string const &  path) const
noexcept

◆ atPath() [1/2]

Value & fedem::fson::Object::atPath ( std::string const &  path)

References findPath().

+ Here is the call graph for this function:

◆ atPath() [2/2]

Value const & fedem::fson::Object::atPath ( std::string const &  path) const

References findPath().

+ Here is the call graph for this function:

◆ setPath()

Value * fedem::fson::Object::setPath ( std::string const &  path,
std::unique_ptr< Value value 
)

References fedem::fson::Value::asArray(), fedem::fson::Value::asObject(), fedem::fson::Array::at(), find(), fedem::fson::Array::getElement(), remove(), set(), fedem::fson::Element::setValue(), and fedem::fson::Array::size().

+ Here is the call graph for this function:

◆ removePath()

bool fedem::fson::Object::removePath ( std::string const &  path)
noexcept

References fedem::fson::Value::asArray(), fedem::fson::Value::asObject(), fedem::fson::Array::at(), fedem::fson::Array::erase(), find(), remove(), and fedem::fson::Array::size().

+ Here is the call graph for this function:

◆ isLocal()

bool fedem::fson::Object::isLocal ( std::string const &  path) const
noexcept

References fedem::fson::Member::isMerged().

+ Here is the call graph for this function:

◆ provenanceOf()

optional< Object::Provenance > fedem::fson::Object::provenanceOf ( std::string const &  path) const

References findOwningMember(), findPath(), fedem::fson::Member::getOriginFile(), fedem::fson::Member::getOriginLocalPath(), and fedem::fson::Member::isMerged().

+ Here is the call graph for this function:

◆ provenanceMap()

std::vector< Object::Provenance > fedem::fson::Object::provenanceMap ( ) const

References fedem::fson::Member::getKey(), fedem::fson::Key::getName(), fedem::fson::Member::getOriginFile(), fedem::fson::Member::getOriginLocalPath(), index, fedem::fson::Member::isDisabled(), fedem::fson::Member::isMerged(), and members.

+ Here is the call graph for this function:

◆ getString()

string fedem::fson::Object::getString ( std::string const &  path,
std::string const &  fallback = std::string( ) 
) const

References fedem::fson::Value::asString(), findPath(), fedem::fson::String::getValue(), and fedem::fson::Value::isString().

+ Here is the call graph for this function:

◆ getInteger()

long long fedem::fson::Object::getInteger ( std::string const &  path,
long long  fallback = 0LL 
) const
noexcept

References fedem::fson::Number::asInteger(), fedem::fson::Value::asNumber(), and fedem::fson::Value::isNumber().

+ Here is the call graph for this function:

◆ getDouble()

double fedem::fson::Object::getDouble ( std::string const &  path,
double  fallback = 0.0 
) const
noexcept

References fedem::fson::Number::asDouble(), fedem::fson::Value::asNumber(), and fedem::fson::Value::isNumber().

+ Here is the call graph for this function:

◆ getBoolean()

bool fedem::fson::Object::getBoolean ( std::string const &  path,
bool  fallback = false 
) const
noexcept

References fedem::fson::Value::asBoolean(), fedem::fson::Boolean::getValue(), and fedem::fson::Value::isBoolean().

+ Here is the call graph for this function:

◆ memberCount()

std::size_t fedem::fson::Object::memberCount ( ) const
inlinenoexcept

Referenced by fedem::fson::IncludeResolver::resolveObject().

+ Here is the caller graph for this function:

◆ getMember() [1/2]

Member& fedem::fson::Object::getMember ( std::size_t  index)

Referenced by fedem::fson::IncludeResolver::resolveObject().

+ Here is the caller graph for this function:

◆ getMember() [2/2]

Member const& fedem::fson::Object::getMember ( std::size_t  index) const

◆ appendMember()

Member & fedem::fson::Object::appendMember ( Member  member)

References entries, Member, and members.

◆ eraseMember()

void fedem::fson::Object::eraseMember ( std::size_t  index)

References index, Member, members, and rebuildEntryIndices().

+ Here is the call graph for this function:

◆ includeCount()

std::size_t fedem::fson::Object::includeCount ( ) const
inlinenoexcept

◆ getInclude() [1/2]

Include& fedem::fson::Object::getInclude ( std::size_t  index)

◆ getInclude() [2/2]

Include const& fedem::fson::Object::getInclude ( std::size_t  index) const

◆ appendInclude()

Include & fedem::fson::Object::appendInclude ( Include  include)

References entries, Include, and includes.

◆ eraseInclude()

void fedem::fson::Object::eraseInclude ( std::size_t  index)

References Include, includes, index, and rebuildEntryIndices().

+ Here is the call graph for this function:

◆ entryCount()

std::size_t fedem::fson::Object::entryCount ( ) const
inlinenoexcept

◆ getEntry()

Object::Entry const & fedem::fson::Object::getEntry ( std::size_t  position) const

References entries.

◆ getDanglingComments() [1/2]

CommentList & fedem::fson::Object::getDanglingComments ( )
inlinenoexcept

◆ getDanglingComments() [2/2]

CommentList const & fedem::fson::Object::getDanglingComments ( ) const
inlinenoexcept

◆ findActiveIndex()

size_t fedem::fson::Object::findActiveIndex ( std::string const &  name) const
privatenoexcept

References index.

Referenced by findOwningMember(), and set().

+ Here is the caller graph for this function:

◆ rebuildEntryIndices()

void fedem::fson::Object::rebuildEntryIndices ( EntryKind  kind,
std::size_t  removedIndex 
)
privatenoexcept

References fedem::fson::Object::Entry::index, kind, and fedem::fson::Object::Entry::kind.

Referenced by eraseInclude(), and eraseMember().

+ Here is the caller graph for this function:

◆ findOwningMember()

Member const * fedem::fson::Object::findOwningMember ( std::string const &  path) const
privatenoexcept

References fedem::fson::Value::asArray(), fedem::fson::Value::asObject(), fedem::fson::Array::at(), find(), findActiveIndex(), index, members, and fedem::fson::Array::size().

Referenced by provenanceOf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ members

std::vector< Member > fedem::fson::Object::members
private

◆ includes

std::vector< Include > fedem::fson::Object::includes
private

Referenced by appendInclude(), clone(), and eraseInclude().

◆ entries

std::vector< Entry > fedem::fson::Object::entries
private

◆ dangling

CommentList fedem::fson::Object::dangling
private

Referenced by clone().

◆ NPOS

constexpr std::size_t const fedem::fson::Object::NPOS = static_cast< std::size_t >( -1 )
staticconstexprprivate

Referenced by set().


The documentation for this class was generated from the following files: