From: <ag...@us...> - 2011-11-17 14:49:25
|
Revision: 2609 http://zoolib.svn.sourceforge.net/zoolib/?rev=2609&view=rev Author: agreen Date: 2011-11-17 14:49:19 +0000 (Thu, 17 Nov 2011) Log Message: ----------- Use ZSetRestore_T rather than custom class. Modified Paths: -------------- trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp trunk/zoolib/source/cxx/zoolib/ZYad_JSON.h Modified: trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp 2011-11-17 14:48:44 UTC (rev 2608) +++ trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp 2011-11-17 14:49:19 UTC (rev 2609) @@ -19,6 +19,7 @@ ------------------------------------------------------------------------------------------------- */ #include "zoolib/ZCompat_cmath.h" +#include "zoolib/ZSetRestore_T.h" #include "zoolib/ZStrim_Escaped.h" #include "zoolib/ZTime.h" #include "zoolib/ZUnicode.h" @@ -213,7 +214,7 @@ } else if (sTryRead_CaselessString(iStrimU, "null")) { - oVal = ZAny(); + oVal = null; //## Watch this } else if (sTryRead_CaselessString(iStrimU, "false")) { @@ -484,33 +485,6 @@ // ================================================================================================= #pragma mark - -#pragma mark * Visitor_Writer::SaveState - -class Visitor_Writer::SaveState - { -public: - SaveState(Visitor_Writer* iVisitor); - ~SaveState(); - - Visitor_Writer* fVisitor; - size_t fIndent; - bool fMayNeedInitialLF; - }; - -Visitor_Writer::SaveState::SaveState(Visitor_Writer* iVisitor) -: fVisitor(iVisitor), - fIndent(fVisitor->fIndent), - fMayNeedInitialLF(fVisitor->fMayNeedInitialLF) - {} - -Visitor_Writer::SaveState::~SaveState() - { - fVisitor->fIndent = fIndent; - fVisitor->fMayNeedInitialLF = fMayNeedInitialLF; - } - -// ================================================================================================= -#pragma mark - #pragma mark * Visitor_Writer Visitor_Writer::Visitor_Writer @@ -564,8 +538,7 @@ spWriteLFIndent(fStrimW, fIndent, fOptions); } - SaveState save(this); - fMayNeedInitialLF = false; + ZSetRestore_T<bool> theSR_MayNeedInitialLF(fMayNeedInitialLF, false); fStrimW.Write("["); for (bool isFirst = true; /*no test*/ ; isFirst = false) @@ -644,9 +617,8 @@ spWriteString(fStrimW, curName); fStrimW << ": "; - SaveState save(this); - fIndent = fIndent + 1; - fMayNeedInitialLF = true; + ZSetRestore_T<size_t> theSR_Indent(fIndent, fIndent + 1); + ZSetRestore_T<bool> theSR_MayNeedInitialLF(fMayNeedInitialLF, true); cur->Accept(*this); } } @@ -674,7 +646,8 @@ if (fOptions.fBreakStrings) fStrimW.Write(" "); - SaveState save(this); + ZSetRestore_T<size_t> theSR_Indent(fIndent, fIndent + 1); + ZSetRestore_T<bool> theSR_MayNeedInitialLF(fMayNeedInitialLF, true); fIndent = fIndent + 1; fMayNeedInitialLF = true; cur->Accept(*this); Modified: trunk/zoolib/source/cxx/zoolib/ZYad_JSON.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_JSON.h 2011-11-17 14:48:44 UTC (rev 2608) +++ trunk/zoolib/source/cxx/zoolib/ZYad_JSON.h 2011-11-17 14:49:19 UTC (rev 2609) @@ -127,9 +127,6 @@ virtual void Visit_YadMapR(const ZRef<ZYadMapR>& iYadMapR); private: - class SaveState; - friend class SaveState; - size_t fIndent; const ZYadOptions fOptions; const ZStrimW& fStrimW; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |