SNAP Library 2.2, Developer Reference  2014-03-11 19:15:55
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TJsonVal Class Reference

#include <json.h>

Collaboration diagram for TJsonVal:

List of all members.

Public Member Functions

 TJsonVal ()
 TJsonVal (TSIn &SIn)
void Save (TSOut &SOut) const
TStr SaveStr ()
bool operator== (const TJsonVal &JsonVal) const
bool operator!= (const TJsonVal &JsonVal) const
void PutNull ()
void PutBool (const bool &_Bool)
void PutNum (const double &_Num)
void PutStr (const TStr &_Str)
void PutArr ()
void AddToArr (const PJsonVal &Val)
void PutObj ()
void AddToObj (const TStr &KeyNm, const PJsonVal &Val)
void AddToObj (const TStr &KeyNm, const int &Val)
void AddToObj (const TStr &KeyNm, const double &Val)
void AddToObj (const TStr &KeyNm, const TStr &Val)
void AddToObj (const TStr &KeyNm, const char *Val)
void AddToObj (const TStr &KeyNm, const bool &Val)
void AddToObj (const TStr &KeyNm, const TJsonValV &ValV)
void AddToObj (const PJsonVal &Val)
TJsonValType GetJsonValType () const
bool IsDef () const
bool IsNull () const
bool IsBool () const
bool IsNum () const
bool IsStr () const
bool IsArr () const
bool IsObj () const
bool GetBool () const
double GetNum () const
TStr GetStr () const
int GetArrVals () const
PJsonVal GetArrVal (const int &ValN) const
int GetObjKeys () const
void GetObjKeyVal (const int &KeyValN, TStr &Key, PJsonVal &Val) const
bool IsObjKey (const TStr &Key) const
bool IsObjKey (const char *Key) const
PJsonVal GetObjKey (const TStr &Key) const
PJsonVal GetObjKey (const char *Key) const
bool GetObjBool (const TStr &Key) const
bool GetObjBool (const char *Key) const
double GetObjNum (const TStr &Key) const
double GetObjNum (const char *Key) const
TStr GetObjStr (const TStr &Key) const
TStr GetObjStr (const char *Key) const
bool GetObjBool (const TStr &Key, const bool &DefBool) const
bool GetObjBool (const char *Key, const bool &DefBool) const
double GetObjNum (const TStr &Key, const double &DefNum) const
double GetObjNum (const char *Key, const double &DefNum) const
TStr GetObjStr (const TStr &Key, const TStr &DefStr) const
TStr GetObjStr (const char *Key, const TStr &DefStr) const

Static Public Member Functions

static PJsonVal New ()
static PJsonVal Load (TSIn &SIn)
static PJsonVal NewNull ()
static PJsonVal NewBool (const bool &Bool)
static PJsonVal NewNum (const double &Num)
static PJsonVal NewStr (const TStr &Str)
static PJsonVal NewArr ()
static PJsonVal NewArr (const TJsonValV &ValV)
static PJsonVal NewArr (const TIntV &IntV)
static PJsonVal NewArr (const TFltV &FltV)
static PJsonVal NewArr (const TStrV &StrV)
static PJsonVal NewArr (const TFltPr &FltPr)
static PJsonVal NewObj ()
static PJsonVal NewObj (const TStr &KeyNm, const PJsonVal &ObjVal)
static PJsonVal NewObj (const TStr &KeyNm, const int &ObjVal)
static PJsonVal NewObj (const TStr &KeyNm, const double &ObjVal)
static PJsonVal NewObj (const TStr &KeyNm, const TStr &ObjVal)
static PJsonVal NewObj (const TStr &KeyNm, const bool &ObjVal)
static PJsonVal GetValFromLx (TILx &Lx)
static PJsonVal GetValFromSIn (const PSIn &SIn)
static PJsonVal GetValFromStr (const TStr &JsonStr)
static void AddEscapeChAFromStr (const TStr &Str, TChA &ChA)
static TStr AddEscapeStrFromStr (const TStr &Str)
static void AddQChAFromStr (const TStr &Str, TChA &ChA)
static void GetChAFromVal (const PJsonVal &Val, TChA &ChA)
static TStr GetStrFromVal (const PJsonVal &Val)

Private Member Functions

 UndefCopyAssign (TJsonVal)

Private Attributes

TCRef CRef
TJsonValType JsonValType
TBool Bool
TFlt Num
TStr Str
TJsonValV ValV
THash< TStr, PJsonValKeyValH

Friends

class TPt< TJsonVal >

Detailed Description

Definition at line 9 of file json.h.


Constructor & Destructor Documentation

TJsonVal::TJsonVal ( ) [inline]

Definition at line 19 of file json.h.

Definition at line 3 of file json.cpp.

                           :
  JsonValType((TJsonValType)(TInt(SIn).Val)), Bool(SIn), 
  Num(SIn), Str(SIn), ValV(SIn), KeyValH(SIn) { }

Member Function Documentation

void TJsonVal::AddEscapeChAFromStr ( const TStr Str,
TChA ChA 
) [static]

Definition at line 188 of file json.cpp.

References TChA::AddCh(), TUnicode::DecodeUtf8(), TStr::Fmt(), TUnicodeDef::GetDef(), TUnicodeDef::IsDef(), TStr::Len(), and TVec< TVal, TSizeTy >::Len().

Referenced by AddQChAFromStr().

                                                            {
        if (TUnicodeDef::IsDef()) {
                // parse the UTF8 string
                TIntV UStr; TUnicodeDef::GetDef()->DecodeUtf8(Str, UStr);
                // escape the string
                for (int ChN = 0; ChN < UStr.Len(); ChN++) {
                        const int UCh = UStr[ChN];
                        if (UCh < 0x80) {
                                // 7-bit ascii
                                const char Ch = (char)UCh;
                                switch (Ch) {
                                        case '"' : ChA.AddCh('\\'); ChA.AddCh('"'); break;
                                        case '\\' : ChA.AddCh('\\'); ChA.AddCh('\\'); break;
                                        case '/' : ChA.AddCh('\\'); ChA.AddCh('/'); break;
                                        case '\b' : ChA.AddCh('\\'); ChA.AddCh('b'); break;
                                        case '\f' : ChA.AddCh('\\'); ChA.AddCh('f'); break;
                                        case '\n' : ChA.AddCh('\\'); ChA.AddCh('n'); break;
                                        case '\r' : ChA.AddCh('\\'); ChA.AddCh('r'); break;
                                        case '\t' : ChA.AddCh('\\'); ChA.AddCh('t'); break;
                                        default :
                                                ChA.AddCh(Ch);
                                }
                        } else {
                                // escape
                                ChA += "\\u";
                                ChA += TStr::Fmt("%04x", UCh);
                        }
                }
        } else {
                // escape the string
                for (int ChN = 0; ChN < Str.Len(); ChN++) {
                        const char Ch = Str[ChN];
                        if ((Ch & 0x80) == 0) {
                                // 7-bit ascii
                                switch (Ch) {
                                        case '"' : ChA.AddCh('\\'); ChA.AddCh('"'); break;
                                        case '\\' : ChA.AddCh('\\'); ChA.AddCh('\\'); break;
                                        case '/' : ChA.AddCh('\\'); ChA.AddCh('/'); break;
                                        case '\b' : ChA.AddCh('\\'); ChA.AddCh('b'); break;
                                        case '\f' : ChA.AddCh('\\'); ChA.AddCh('f'); break;
                                        case '\n' : ChA.AddCh('\\'); ChA.AddCh('n'); break;
                                        case '\r' : ChA.AddCh('\\'); ChA.AddCh('r'); break;
                                        case '\t' : ChA.AddCh('\\'); ChA.AddCh('t'); break;
                                        default : ChA.AddCh(Ch);
                                }
                        } else {
                                // escape
                                ChA += "\\u";
                                ChA += TStr::Fmt("%02x", (int)Ch);
                        }
                }
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static TStr TJsonVal::AddEscapeStrFromStr ( const TStr Str) [inline, static]

Definition at line 113 of file json.h.

                                                   { 
          TChA ChA; AddEscapeChAFromStr(Str, ChA); return ChA; }
void TJsonVal::AddQChAFromStr ( const TStr Str,
TChA ChA 
) [static]

Definition at line 242 of file json.cpp.

References AddEscapeChAFromStr().

Referenced by GetChAFromVal().

                                                       {
  ChA+="\"";
  AddEscapeChAFromStr(Str, ChA);
  ChA+="\"";
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TJsonVal::AddToArr ( const PJsonVal Val) [inline]

Definition at line 36 of file json.h.

References EAssert, and jvtArr.

void TJsonVal::AddToObj ( const TStr KeyNm,
const PJsonVal Val 
) [inline]

Definition at line 39 of file json.h.

References EAssert, and jvtObj.

Referenced by AddToObj().

                                                       {
    EAssert(JsonValType==jvtObj); KeyValH.AddDat(KeyNm, Val);}

Here is the caller graph for this function:

void TJsonVal::AddToObj ( const TStr KeyNm,
const int &  Val 
) [inline]

Definition at line 41 of file json.h.

References AddToObj().

Referenced by AddToObj().

{ AddToObj(KeyNm, NewNum((double)Val)); }

Here is the call graph for this function:

Here is the caller graph for this function:

void TJsonVal::AddToObj ( const TStr KeyNm,
const double &  Val 
) [inline]

Definition at line 42 of file json.h.

References AddToObj().

Referenced by AddToObj().

{ AddToObj(KeyNm, NewNum(Val)); }

Here is the call graph for this function:

Here is the caller graph for this function:

void TJsonVal::AddToObj ( const TStr KeyNm,
const TStr Val 
) [inline]

Definition at line 43 of file json.h.

References AddToObj().

Referenced by AddToObj().

{ AddToObj(KeyNm, NewStr(Val)); }

Here is the call graph for this function:

Here is the caller graph for this function:

void TJsonVal::AddToObj ( const TStr KeyNm,
const char *  Val 
) [inline]

Definition at line 44 of file json.h.

References AddToObj().

Referenced by AddToObj().

{ AddToObj(KeyNm, NewStr(Val)); }

Here is the call graph for this function:

Here is the caller graph for this function:

void TJsonVal::AddToObj ( const TStr KeyNm,
const bool &  Val 
) [inline]

Definition at line 45 of file json.h.

References AddToObj().

Referenced by AddToObj().

{ AddToObj(KeyNm, NewBool(Val)); }

Here is the call graph for this function:

Here is the caller graph for this function:

void TJsonVal::AddToObj ( const TStr KeyNm,
const TJsonValV ValV 
) [inline]

Definition at line 46 of file json.h.

References AddToObj().

Referenced by AddToObj().

{ AddToObj(KeyNm, NewArr(ValV)); }

Here is the call graph for this function:

Here is the caller graph for this function:

void TJsonVal::AddToObj ( const PJsonVal Val)

Definition at line 31 of file json.cpp.

References AddToObj(), and EAssert.

                                           {
        EAssert(Val->IsObj());
        int KeyId = Val->KeyValH.FFirstKeyId();
        while (Val->KeyValH.FNextKeyId(KeyId)) {
                AddToObj(Val->KeyValH.GetKey(KeyId), Val->KeyValH[KeyId]);
        }
}

Here is the call graph for this function:

PJsonVal TJsonVal::GetArrVal ( const int &  ValN) const [inline]

Definition at line 87 of file json.h.

{return ValV[ValN];}
int TJsonVal::GetArrVals ( ) const [inline]

Definition at line 86 of file json.h.

References EAssert.

{EAssert(IsArr()); return ValV.Len();}
bool TJsonVal::GetBool ( ) const [inline]

Definition at line 83 of file json.h.

References EAssert.

{EAssert(IsBool()); return Bool;}
void TJsonVal::GetChAFromVal ( const PJsonVal Val,
TChA ChA 
) [static]

Definition at line 248 of file json.cpp.

References AddQChAFromStr(), TStr::Fmt(), jvtArr, jvtBool, jvtNull, jvtNum, jvtObj, jvtStr, and TExcept::Throw().

Referenced by GetStrFromVal().

                                                          {
  switch (Val->GetJsonValType()){
    case jvtNull: 
      ChA+="null"; break;
    case jvtBool:
      if (Val->GetBool()){ChA+="true";} else {ChA+="false";} break;
    case jvtNum: 
      ChA+=TStr::Fmt("%f", Val->GetNum()); break;
    case jvtStr:
      AddQChAFromStr(Val->GetStr(), ChA); break;
    case jvtArr:
      ChA+="[";
      for (int ArrValN=0; ArrValN<Val->GetArrVals(); ArrValN++){
        if (ArrValN>0){ChA+=", ";}
        GetChAFromVal(Val->GetArrVal(ArrValN), ChA);
      }
      ChA+="]"; 
      break;
    case jvtObj:
      ChA+="{";
      for (int ObjKeyN=0; ObjKeyN<Val->GetObjKeys(); ObjKeyN++){
        if (ObjKeyN>0){ChA+=", ";}
        TStr ObjKey; PJsonVal ObjVal; Val->GetObjKeyVal(ObjKeyN, ObjKey, ObjVal);
        AddQChAFromStr(ObjKey, ChA);
        ChA+=":";
        GetChAFromVal(ObjVal, ChA);
      }
      ChA+="}"; 
      break;
        default: TExcept::Throw("Error parsing json");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 73 of file json.h.

{return JsonValType;}
double TJsonVal::GetNum ( ) const [inline]

Definition at line 84 of file json.h.

References EAssert.

{EAssert(IsNum()); return Num;}
bool TJsonVal::GetObjBool ( const TStr Key) const [inline]

Definition at line 95 of file json.h.

{ return GetObjKey(Key)->GetBool(); }
bool TJsonVal::GetObjBool ( const char *  Key) const [inline]

Definition at line 96 of file json.h.

{ return GetObjKey(Key)->GetBool(); }
bool TJsonVal::GetObjBool ( const TStr Key,
const bool &  DefBool 
) const

Definition at line 90 of file json.cpp.

References EAssert, THash< TKey, TDat, THashFunc >::GetDat(), IsObj(), IsObjKey(), and KeyValH.

                                                                    { 
  EAssert(IsObj());
  return (IsObjKey(Key)) ? KeyValH.GetDat(Key)->GetBool() : DefBool;
}

Here is the call graph for this function:

bool TJsonVal::GetObjBool ( const char *  Key,
const bool &  DefBool 
) const

Definition at line 95 of file json.cpp.

References EAssert, THash< TKey, TDat, THashFunc >::GetDat(), IsObj(), IsObjKey(), and KeyValH.

                                                                    { 
  EAssert(IsObj());
  return (IsObjKey(Key)) ? KeyValH.GetDat(Key)->GetBool() : DefBool;
}

Here is the call graph for this function:

PJsonVal TJsonVal::GetObjKey ( const TStr Key) const

Definition at line 78 of file json.cpp.

References EAssert, THash< TKey, TDat, THashFunc >::GetDat(), IsObj(), IsObjKey(), and KeyValH.

                                                  {
  EAssert(IsObj());
  EAssert(IsObjKey(Key)); 
  return KeyValH.GetDat(Key);
}

Here is the call graph for this function:

PJsonVal TJsonVal::GetObjKey ( const char *  Key) const

Definition at line 84 of file json.cpp.

References EAssert, THash< TKey, TDat, THashFunc >::GetDat(), IsObj(), IsObjKey(), and KeyValH.

                                                  {
  EAssert(IsObj());
  EAssert(IsObjKey(Key));
  return KeyValH.GetDat(Key);
}

Here is the call graph for this function:

int TJsonVal::GetObjKeys ( ) const [inline]

Definition at line 88 of file json.h.

References EAssert.

{EAssert(IsObj()); return KeyValH.Len();}
void TJsonVal::GetObjKeyVal ( const int &  KeyValN,
TStr Key,
PJsonVal Val 
) const [inline]

Definition at line 89 of file json.h.

References EAssert.

                                                                        {
    EAssert(IsObj()); Key=KeyValH.GetKey(KeyValN); Val=KeyValH[KeyValN];}
double TJsonVal::GetObjNum ( const TStr Key) const [inline]

Definition at line 97 of file json.h.

{ return GetObjKey(Key)->GetNum(); }
double TJsonVal::GetObjNum ( const char *  Key) const [inline]

Definition at line 98 of file json.h.

{ return GetObjKey(Key)->GetNum(); }
double TJsonVal::GetObjNum ( const TStr Key,
const double &  DefNum 
) const

Definition at line 100 of file json.cpp.

References EAssert, THash< TKey, TDat, THashFunc >::GetDat(), IsObj(), IsObjKey(), and KeyValH.

                                                                      { 
  EAssert(IsObj());
  return (IsObjKey(Key)) ? KeyValH.GetDat(Key)->GetNum() : DefNum;
} 

Here is the call graph for this function:

double TJsonVal::GetObjNum ( const char *  Key,
const double &  DefNum 
) const

Definition at line 105 of file json.cpp.

References EAssert, THash< TKey, TDat, THashFunc >::GetDat(), IsObj(), IsObjKey(), and KeyValH.

                                                                      { 
  EAssert(IsObj());
  return (IsObjKey(Key)) ? KeyValH.GetDat(Key)->GetNum() : DefNum;
}

Here is the call graph for this function:

TStr TJsonVal::GetObjStr ( const TStr Key) const [inline]

Definition at line 99 of file json.h.

References TStr::GetStr().

{ return GetObjKey(Key)->GetStr(); }

Here is the call graph for this function:

TStr TJsonVal::GetObjStr ( const char *  Key) const [inline]

Definition at line 100 of file json.h.

References TStr::GetStr().

{ return GetObjKey(Key)->GetStr(); }

Here is the call graph for this function:

TStr TJsonVal::GetObjStr ( const TStr Key,
const TStr DefStr 
) const

Definition at line 110 of file json.cpp.

References EAssert, THash< TKey, TDat, THashFunc >::GetDat(), IsObj(), IsObjKey(), and KeyValH.

                                                                  { 
  EAssert(IsObj());
  return (IsObjKey(Key)) ? KeyValH.GetDat(Key)->GetStr() : DefStr;
}

Here is the call graph for this function:

TStr TJsonVal::GetObjStr ( const char *  Key,
const TStr DefStr 
) const

Definition at line 115 of file json.cpp.

References EAssert, THash< TKey, TDat, THashFunc >::GetDat(), IsObj(), IsObjKey(), and KeyValH.

                                                                  { 
  EAssert(IsObj());
  return (IsObjKey(Key)) ? KeyValH.GetDat(Key)->GetStr() : DefStr;
}

Here is the call graph for this function:

TStr TJsonVal::GetStr ( ) const [inline]

Definition at line 85 of file json.h.

References EAssert.

{EAssert(IsStr()); return Str;}
TStr TJsonVal::GetStrFromVal ( const PJsonVal Val) [static]

Definition at line 281 of file json.cpp.

References GetChAFromVal().

Referenced by SaveStr().

                                               {
  TChA ChA;
  GetChAFromVal(Val, ChA);
  return ChA;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PJsonVal TJsonVal::GetValFromLx ( TILx Lx) [static]

Definition at line 120 of file json.cpp.

References TILx::Flt, forever, TILx::GetSym(), New(), TILx::Str, syColon, syComma, syFlt, syIdStr, syLBrace, syLBracket, TILx::Sym, syQStr, syRBrace, syRBracket, and TExcept::Throw().

Referenced by GetValFromSIn().

                                       {
  static TFSet ValExpect=TFSet()|syIdStr|syFlt|syQStr|syLBracket|syLBrace|syRBracket;
  PJsonVal Val=TJsonVal::New();
  if ((Lx.Sym==syIdStr)&&(Lx.Str=="null")){
    Val->PutNull(); Lx.GetSym();
  } else if ((Lx.Sym==syIdStr)&&(Lx.Str=="true")){
    Val->PutBool(true); Lx.GetSym();
  } else if ((Lx.Sym==syIdStr)&&(Lx.Str=="false")){
    Val->PutBool(false); Lx.GetSym();
  } else if (Lx.Sym==syFlt){
    Val->PutNum(Lx.Flt); Lx.GetSym();
  } else if (Lx.Sym==syQStr){
    Val->PutStr(Lx.Str); Lx.GetSym();
  } else if (Lx.Sym==syLBracket){
    Val->PutArr(); Lx.GetSym(ValExpect); // added ValExpect to correctyl parse arrays of floats
    if (Lx.Sym!=syRBracket){
      forever{
        PJsonVal SubVal=TJsonVal::GetValFromLx(Lx);
        Val->AddToArr(SubVal);
        if (Lx.Sym==syComma){Lx.GetSym(ValExpect);} 
        else if (Lx.Sym==syRBracket){break;} 
        else {TExcept::Throw("JSON Array not properly formed.");}
      }
    }
    Lx.GetSym();
  } else if (Lx.Sym==syLBrace){
    Val->PutObj(); Lx.GetSym(TFSet()|syRBrace|syQStr);
    if (Lx.Sym!=syRBrace){
      forever{
        TStr SubKey=Lx.Str; 
        Lx.GetSym(syColon); 
        Lx.GetSym(ValExpect);
        PJsonVal SubVal=TJsonVal::GetValFromLx(Lx);
        Val->AddToObj(SubKey, SubVal);
        if (Lx.Sym==syComma){Lx.GetSym(TFSet()|syQStr);} 
        else if (Lx.Sym==syRBrace){break;} 
        else {TExcept::Throw("JSON Object not properly formed.");}
      }
    }
    Lx.GetSym();
  } else {
    TExcept::Throw("Unexpected JSON symbol.");
  }
  return Val;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PJsonVal TJsonVal::GetValFromSIn ( const PSIn SIn) [static]

Definition at line 166 of file json.cpp.

References TILx::GetSym(), GetValFromLx(), iloCmtAlw, iloCsSens, iloExcept, iloSigNum, New(), syLBrace, and syLBracket.

Referenced by GetValFromStr().

                                               {
  TILx Lx(SIn, TFSet()|iloCmtAlw|iloCsSens|iloExcept|iloSigNum);
  PJsonVal Val;
  //bool Ok=true;
  TStr MsgStr="Ok";
  try {
    Lx.GetSym(TFSet()|syLBracket|syLBrace);
    Val=GetValFromLx(Lx);
  }
  catch (PExcept Except){
    //Ok=false;
    MsgStr=Except->GetMsgStr();
    Val=TJsonVal::New();
  }
  return Val;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PJsonVal TJsonVal::GetValFromStr ( const TStr JsonStr) [static]

Definition at line 183 of file json.cpp.

References GetValFromSIn(), and New().

                                                   {
  PSIn SIn=TStrIn::New(JsonStr);
  return GetValFromSIn(SIn);
}

Here is the call graph for this function:

bool TJsonVal::IsArr ( ) const [inline]

Definition at line 79 of file json.h.

References jvtArr.

{return JsonValType==jvtArr;}
bool TJsonVal::IsBool ( ) const [inline]

Definition at line 76 of file json.h.

References jvtBool.

{return JsonValType==jvtBool;}
bool TJsonVal::IsDef ( ) const [inline]

Definition at line 74 of file json.h.

References jvtUndef.

{return JsonValType!=jvtUndef;}
bool TJsonVal::IsNull ( ) const [inline]

Definition at line 75 of file json.h.

References jvtNull.

{return JsonValType==jvtNull;}
bool TJsonVal::IsNum ( ) const [inline]

Definition at line 77 of file json.h.

References jvtNum.

{return JsonValType==jvtNum;}
bool TJsonVal::IsObj ( ) const [inline]

Definition at line 80 of file json.h.

References jvtObj.

Referenced by GetObjBool(), GetObjKey(), GetObjNum(), and GetObjStr().

{return JsonValType==jvtObj;}

Here is the caller graph for this function:

bool TJsonVal::IsObjKey ( const TStr Key) const [inline]

Definition at line 91 of file json.h.

References EAssert.

Referenced by GetObjBool(), GetObjKey(), GetObjNum(), and GetObjStr().

{EAssert(IsObj()); return KeyValH.IsKey(Key);}

Here is the caller graph for this function:

bool TJsonVal::IsObjKey ( const char *  Key) const [inline]

Definition at line 92 of file json.h.

References EAssert.

{EAssert(IsObj()); return KeyValH.IsKey(Key);}
bool TJsonVal::IsStr ( ) const [inline]

Definition at line 78 of file json.h.

References jvtStr.

{return JsonValType==jvtStr;}
static PJsonVal TJsonVal::Load ( TSIn SIn) [inline, static]

Definition at line 23 of file json.h.

{return new TJsonVal(SIn);}
static PJsonVal TJsonVal::New ( ) [inline, static]

Definition at line 20 of file json.h.

Referenced by GetValFromLx(), GetValFromSIn(), GetValFromStr(), NewArr(), NewBool(), NewNull(), NewNum(), NewObj(), and NewStr().

                       {
    return new TJsonVal();}

Here is the caller graph for this function:

static PJsonVal TJsonVal::NewArr ( ) [inline, static]

Definition at line 54 of file json.h.

References New().

Referenced by NewArr().

{ PJsonVal Val = TJsonVal::New(); Val->PutArr(); return Val; }

Here is the call graph for this function:

Here is the caller graph for this function:

PJsonVal TJsonVal::NewArr ( const TJsonValV ValV) [static]

Definition at line 39 of file json.cpp.

References TVec< TVal, TSizeTy >::Len(), and NewArr().

                                               {
        PJsonVal Val = TJsonVal::NewArr();
        for (int ValN = 0; ValN < ValV.Len(); ValN++) {
                Val->AddToArr(ValV[ValN]);
        }
        return Val;
}

Here is the call graph for this function:

PJsonVal TJsonVal::NewArr ( const TIntV IntV) [static]

Definition at line 47 of file json.cpp.

References TVec< TVal, TSizeTy >::Len(), NewArr(), and NewNum().

                                           {
        PJsonVal Val = TJsonVal::NewArr();
        for (int IntN = 0; IntN < IntV.Len(); IntN++) {
                Val->AddToArr(TJsonVal::NewNum((double)IntV[IntN]));
        }
        return Val;
}

Here is the call graph for this function:

PJsonVal TJsonVal::NewArr ( const TFltV FltV) [static]

Definition at line 55 of file json.cpp.

References TVec< TVal, TSizeTy >::Len(), NewArr(), and NewNum().

                                           {
        PJsonVal Val = TJsonVal::NewArr();
        for (int FltN = 0; FltN < FltV.Len(); FltN++) {
                Val->AddToArr(TJsonVal::NewNum(FltV[FltN]));
        }
        return Val;
}

Here is the call graph for this function:

PJsonVal TJsonVal::NewArr ( const TStrV StrV) [static]

Definition at line 63 of file json.cpp.

References TVec< TVal, TSizeTy >::Len(), NewArr(), and NewStr().

                                           {
        PJsonVal Val = TJsonVal::NewArr();
        for (int StrN = 0; StrN < StrV.Len(); StrN++) {
                Val->AddToArr(TJsonVal::NewStr(StrV[StrN]));
        }
        return Val;
}

Here is the call graph for this function:

PJsonVal TJsonVal::NewArr ( const TFltPr FltPr) [static]

Definition at line 71 of file json.cpp.

References NewArr(), NewNum(), TPair< TVal1, TVal2 >::Val1, and TPair< TVal1, TVal2 >::Val2.

                                             {
  PJsonVal Val = TJsonVal::NewArr();
  Val->AddToArr(TJsonVal::NewNum(FltPr.Val1));
  Val->AddToArr(TJsonVal::NewNum(FltPr.Val2));
  return Val;
}

Here is the call graph for this function:

static PJsonVal TJsonVal::NewBool ( const bool &  Bool) [inline, static]

Definition at line 51 of file json.h.

References New().

{ PJsonVal Val = TJsonVal::New(); Val->PutBool(Bool); return Val; }

Here is the call graph for this function:

static PJsonVal TJsonVal::NewNull ( ) [inline, static]

Definition at line 50 of file json.h.

References New().

{ PJsonVal Val = TJsonVal::New(); Val->PutNull(); return Val; }

Here is the call graph for this function:

static PJsonVal TJsonVal::NewNum ( const double &  Num) [inline, static]

Definition at line 52 of file json.h.

References New().

Referenced by NewArr().

{ PJsonVal Val = TJsonVal::New(); Val->PutNum(Num); return Val; }

Here is the call graph for this function:

Here is the caller graph for this function:

static PJsonVal TJsonVal::NewObj ( ) [inline, static]

Definition at line 60 of file json.h.

References New().

{ PJsonVal Val = TJsonVal::New(); Val->PutObj(); return Val; }

Here is the call graph for this function:

static PJsonVal TJsonVal::NewObj ( const TStr KeyNm,
const PJsonVal ObjVal 
) [inline, static]

Definition at line 61 of file json.h.

References New().

                                                                    {
          PJsonVal Val = TJsonVal::New(); Val->PutObj(); Val->AddToObj(KeyNm, ObjVal); return Val; }

Here is the call graph for this function:

static PJsonVal TJsonVal::NewObj ( const TStr KeyNm,
const int &  ObjVal 
) [inline, static]

Definition at line 63 of file json.h.

References New().

                                                               {
          PJsonVal Val = TJsonVal::New(); Val->PutObj(); Val->AddToObj(KeyNm, ObjVal); return Val; }

Here is the call graph for this function:

static PJsonVal TJsonVal::NewObj ( const TStr KeyNm,
const double &  ObjVal 
) [inline, static]

Definition at line 65 of file json.h.

References New().

                                                                  {
          PJsonVal Val = TJsonVal::New(); Val->PutObj(); Val->AddToObj(KeyNm, ObjVal); return Val; }

Here is the call graph for this function:

static PJsonVal TJsonVal::NewObj ( const TStr KeyNm,
const TStr ObjVal 
) [inline, static]

Definition at line 67 of file json.h.

References New().

                                                                {
          PJsonVal Val = TJsonVal::New(); Val->PutObj(); Val->AddToObj(KeyNm, ObjVal); return Val; }

Here is the call graph for this function:

static PJsonVal TJsonVal::NewObj ( const TStr KeyNm,
const bool &  ObjVal 
) [inline, static]

Definition at line 69 of file json.h.

References New().

                                                                {
          PJsonVal Val = TJsonVal::New(); Val->PutObj(); Val->AddToObj(KeyNm, ObjVal); return Val; }

Here is the call graph for this function:

static PJsonVal TJsonVal::NewStr ( const TStr Str) [inline, static]

Definition at line 53 of file json.h.

References New().

Referenced by NewArr().

{ PJsonVal Val = TJsonVal::New(); Val->PutStr(Str); return Val; }

Here is the call graph for this function:

Here is the caller graph for this function:

bool TJsonVal::operator!= ( const TJsonVal JsonVal) const

Definition at line 27 of file json.cpp.

                                                       {
  return !(*this == JsonVal);
}
bool TJsonVal::operator== ( const TJsonVal JsonVal) const

Definition at line 18 of file json.cpp.

References Bool, JsonValType, KeyValH, Num, Str, and ValV.

                                                       {
  return JsonValType == JsonVal.JsonValType &&
    Bool == JsonVal.Bool &&
    Num == JsonVal.Num &&
    Str == JsonVal.Str &&
    ValV == JsonVal.ValV && 
    KeyValH == JsonVal.KeyValH;    
}
void TJsonVal::PutArr ( ) [inline]

Definition at line 35 of file json.h.

References jvtArr.

void TJsonVal::PutBool ( const bool &  _Bool) [inline]

Definition at line 32 of file json.h.

References jvtBool.

void TJsonVal::PutNull ( ) [inline]

Definition at line 31 of file json.h.

References jvtNull.

void TJsonVal::PutNum ( const double &  _Num) [inline]

Definition at line 33 of file json.h.

References jvtNum.

void TJsonVal::PutObj ( ) [inline]

Definition at line 38 of file json.h.

References jvtObj.

void TJsonVal::PutStr ( const TStr _Str) [inline]

Definition at line 34 of file json.h.

References jvtStr.

void TJsonVal::Save ( TSOut SOut) const

Definition at line 7 of file json.cpp.

References Bool, JsonValType, KeyValH, Num, THash< TKey, TDat, THashFunc >::Save(), TStr::Save(), TVec< TVal, TSizeTy >::Save(), TBool::Save(), TInt::Save(), TFlt::Save(), Str, and ValV.

                                     {
  TInt((int)JsonValType).Save(SOut);
  Bool.Save(SOut); Num.Save(SOut);
  Str.Save(SOut); ValV.Save(SOut);
  KeyValH.Save(SOut);
}

Here is the call graph for this function:

Definition at line 14 of file json.cpp.

References GetStrFromVal().

                       { 
  return GetStrFromVal(this); 
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class TPt< TJsonVal > [friend]

Definition at line 9 of file json.h.


Member Data Documentation

TBool TJsonVal::Bool [private]

Definition at line 12 of file json.h.

Referenced by operator==(), and Save().

TCRef TJsonVal::CRef [private]

Definition at line 9 of file json.h.

Definition at line 11 of file json.h.

Referenced by operator==(), and Save().

Definition at line 16 of file json.h.

Referenced by GetObjBool(), GetObjKey(), GetObjNum(), GetObjStr(), operator==(), and Save().

TFlt TJsonVal::Num [private]

Definition at line 13 of file json.h.

Referenced by operator==(), and Save().

TStr TJsonVal::Str [private]

Definition at line 14 of file json.h.

Referenced by operator==(), and Save().

Definition at line 15 of file json.h.

Referenced by operator==(), and Save().


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