Ejemplo n.º 1
0
 void Value::CommentInfo::setComment(const char *text) {
   if (comment_)
     valueAllocator()->releaseStringValue(comment_);
   JSON_ASSERT(text);
   JSON_ASSERT_MESSAGE(text[0] == '\0' || text[0] == '/', "Comments must start with /");
   // It seems that /**/ style comments are acceptable as well.
   comment_ = valueAllocator()->duplicateStringValue(text);
 }
Ejemplo n.º 2
0
Value::Value ( const Value& other )
    : type_ ( other.type_ )
{
    switch ( type_ )
    {
    case nullValue:
    case intValue:
    case uintValue:
    case realValue:
    case booleanValue:
        value_ = other.value_;
        break;

    case stringValue:
        if ( other.value_.string_ )
        {
            value_.string_ = valueAllocator ()->duplicateStringValue ( other.value_.string_ );
            allocated_ = true;
        }
        else
            value_.string_ = 0;

        break;

    case arrayValue:
    case objectValue:
        value_.map_ = new ObjectValues ( *other.value_.map_ );
        break;

    default:
        JSON_ASSERT_UNREACHABLE;
    }
}
Ejemplo n.º 3
0
  Value::~Value() {
    switch (type_) {
      case nullValue:
      case intValue:
      case uintValue:
      case realValue:
      case booleanValue:
        break;
      case stringValue:
        if (allocated_)
          valueAllocator()->releaseStringValue(value_.string_);
        break;
#ifndef JSON_VALUE_USE_INTERNAL_MAP
      case arrayValue:
      case objectValue:
        delete value_.map_;
        break;
#else
      case arrayValue:
        arrayAllocator()->destructArray(value_.array_);
        break;
      case objectValue:
        mapAllocator()->destructMap(value_.map_);
        break;
#endif
      default:
        JSON_ASSERT_UNREACHABLE;
    }

    if (comments_)
      delete[] comments_;
  }
Ejemplo n.º 4
0
Value::~Value ()
{
    switch ( type_ )
    {
    case nullValue:
    case intValue:
    case uintValue:
    case realValue:
    case booleanValue:
        break;

    case stringValue:
        if ( allocated_ )
            valueAllocator ()->releaseStringValue ( value_.string_ );

        break;

    case arrayValue:
    case objectValue:
        delete value_.map_;
        break;

    default:
        JSON_ASSERT_UNREACHABLE;
    }
}
Ejemplo n.º 5
0
Value::Value ( std::string const& value )
    : type_ ( stringValue )
    , allocated_ ( true )
{
    value_.string_ = valueAllocator ()->duplicateStringValue ( value.c_str (),
                     (unsigned int)value.length () );

}
Ejemplo n.º 6
0
Value::Value ( const char* beginValue,
               const char* endValue )
    : type_ ( stringValue )
    , allocated_ ( true )
{
    value_.string_ = valueAllocator ()->duplicateStringValue ( beginValue,
                     UInt (endValue - beginValue) );
}
Ejemplo n.º 7
0
Value::Value (beast::String const& beastString)
    : type_ ( stringValue )
    , allocated_ ( true )
{
    value_.string_ = valueAllocator ()->duplicateStringValue ( beastString.toStdString ().c_str (),
                     (unsigned int)beastString.length () );

}
Ejemplo n.º 8
0
Value::CZString::CZString( const CZString &other )
: cstr_( other.index_ != noDuplication &&  other.cstr_ != 0
                ?  valueAllocator()->makeMemberName( other.cstr_ )
                : other.cstr_ )
   , index_( other.cstr_ ? (other.index_ == noDuplication ? noDuplication : duplicate)
                         : other.index_ )
{
}
Ejemplo n.º 9
0
Value::Value( const CppTL::ConstString &value )
   : type_( stringValue )
   , allocated_( true )
   , comments_( 0 )
# ifdef JSON_VALUE_USE_INTERNAL_MAP
   , itemIsUsed_( 0 )
#endif
{
   value_.string_ = valueAllocator()->duplicateStringValue( value, value.length() );
}
Ejemplo n.º 10
0
Value::Value( const char *value )
   : type_( stringValue )
   , allocated_( true )
   , comments_( 0 )
# ifdef JSON_VALUE_USE_INTERNAL_MAP
   , itemIsUsed_( 0 )
#endif
{
   value_.string_ = valueAllocator()->duplicateStringValue( value );
}
Ejemplo n.º 11
0
  Value::Value(const std::string &value)
      : type_(stringValue),
        allocated_(true),
        comments_(nullptr)
#ifdef JSON_VALUE_USE_INTERNAL_MAP
        ,
        itemIsUsed_(0)
#endif
  {
    value_.string_ = valueAllocator()->duplicateStringValue(value.c_str(), (unsigned int)value.length());
  }
Ejemplo n.º 12
0
  Value::Value(const char *beginValue, const char *endValue)
      : type_(stringValue),
        allocated_(true),
        comments_(nullptr)
#ifdef JSON_VALUE_USE_INTERNAL_MAP
        ,
        itemIsUsed_(0)
#endif
  {
    value_.string_ = valueAllocator()->duplicateStringValue(beginValue, UInt(endValue - beginValue));
  }
Ejemplo n.º 13
0
Value::Value( const Value &other )
   : type_( other.type_ )
   , comments_( 0 )
# ifdef JSON_VALUE_USE_INTERNAL_MAP
   , itemIsUsed_( 0 )
#endif
{
   switch ( type_ )
   {
   case nullValue:
   case intValue:
   case uintValue:
   case realValue:
   case int64Value:
   case uint64Value:
   case booleanValue:
      value_ = other.value_;
      break;
   case stringValue:
      if ( other.value_.string_ )
      {
         value_.string_ = valueAllocator()->duplicateStringValue( other.value_.string_ );
         allocated_ = true;
      }
      else
         value_.string_ = 0;
      break;
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   case arrayValue:
   case objectValue:
      value_.map_ = new ObjectValues( *other.value_.map_ );
      break;
#else
   case arrayValue:
      value_.array_ = arrayAllocator()->newArrayCopy( *other.value_.array_ );
      break;
   case objectValue:
      value_.map_ = mapAllocator()->newMapCopy( *other.value_.map_ );
      break;
#endif
   default:
      JSON_ASSERT_UNREACHABLE;
   }
   if ( other.comments_ )
   {
      comments_ = new CommentInfo[numberOfCommentPlacement];
      for ( int comment =0; comment < numberOfCommentPlacement; ++comment )
      {
         const CommentInfo &otherComment = other.comments_[comment];
         if ( otherComment.comment_ )
            comments_[comment].setComment( otherComment.comment_ );
      }
   }
}
Ejemplo n.º 14
0
Value::Value( const Datacratic::Utf8String &value )
   : type_( stringValue )
   , allocated_( true )
   , comments_( 0 )
# ifdef JSON_VALUE_USE_INTERNAL_MAP
   , itemIsUsed_( 0 )
#endif
{
   value_.string_ = valueAllocator()->duplicateStringValue( value.rawData(),
                                                            (unsigned int)value.rawLength() );

}
Ejemplo n.º 15
0
Value::Value (beast::String const& beastString)
    : type_ ( stringValue )
    , allocated_ ( true )
    , comments_ ( 0 )
# ifdef JSON_VALUE_USE_INTERNAL_MAP
    , itemIsUsed_ ( 0 )
#endif
{
    value_.string_ = valueAllocator ()->duplicateStringValue ( beastString.toStdString ().c_str (),
                     (unsigned int)beastString.length () );

}
Ejemplo n.º 16
0
 Value::CZString::~CZString() {
   if (cstr_ && index_ == duplicate)
     valueAllocator()->releaseMemberName(const_cast<char *>(cstr_));
 }
Ejemplo n.º 17
0
 Value::CZString::CZString(const char *cstr, DuplicationPolicy allocate)
     : cstr_(allocate == duplicate ? valueAllocator()->makeMemberName(cstr) : cstr), index_(allocate) {}
Ejemplo n.º 18
0
 Value::CommentInfo::~CommentInfo() {
   if (comment_)
     valueAllocator()->releaseStringValue(comment_);
 }
Ejemplo n.º 19
0
Value::Value ( const char* value )
    : type_ ( stringValue )
    , allocated_ ( true )
{
    value_.string_ = valueAllocator ()->duplicateStringValue ( value );
}
Ejemplo n.º 20
0
 DummyValueAllocatorInitializer() {
   valueAllocator();  // ensure valueAllocator() statics are initialized before main().
 }
Ejemplo n.º 21
0
 DummyValueAllocatorInitializer() {
     // ensure value allocator statics are initialized before main
     valueAllocator();
 }