as2js: as2js::JSON::JSONValue::saving_t Class Reference

as2js::JSON::JSONValue::saving_t Class Reference
Collaboration diagram for as2js::JSON::JSONValue::saving_t:
Public Member Functions  saving_t (JSONValue const &value)  Initialize a JSONValue saving_t object. More...
   ~saving_t ()  Destroy a JSONValue saving_t object. More...
  Private Attributes JSONValuef_value   Detailed Description

Definition at line 112 of file json.h.

Constructor & Destructor Documentation
as2js::JSON::JSONValue::saving_t::saving_t ( JSONValue const &  value)

This function initializes a JSONValue saving_t object attached to the specified JSONValue value.

While saving we cannot know whether the JSON is currently cyclical or not. We use this saving_t object to mark all the objects being saved with a flag. If the flag is already set, this constructor fails with an exception.

To avoid cyclical JSON trees, make sure to always allocate any new value that you add to your tree.

exception_cyclical_structureThis exception is raised if the JSONValue about to be saved is already marked as being saved, meaning that a child of JSONValue points back to this JSONValue.
[in]valueThe value being marked as being saved.

Definition at line 195 of file json.cpp.

References as2js::JSON::JSONValue::f_saving, and f_value.

as2js::JSON::JSONValue::saving_t::~saving_t ( )

The destructor of a JSONValue marks the attached JSONValue object as saved. In other words, it allows it to be saved again.

It is used to make sure that the same JSON tree can be saved multiple times.

Note that since this happens once the value is saved, if it appears multiple times in the tree, but is not cyclical, the save will work.

Definition at line 218 of file json.cpp.

References as2js::JSON::JSONValue::f_saving, and f_value.

Member Data Documentation
JSONValue& as2js::JSON::JSONValue::saving_t::f_value private

Definition at line 119 of file json.h.

Referenced by saving_t(), and ~saving_t().

The documentation for this class was generated from the following files:
  • /home/snapwebsites/snapcpp/contrib/as2js/include/as2js/json.h
  • /home/snapwebsites/snapcpp/contrib/as2js/lib/json.cpp

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly