From: <ag...@us...> - 2009-04-23 23:31:50
|
Revision: 549 http://zoolib.svn.sourceforge.net/zoolib/?rev=549&view=rev Author: agreen Date: 2009-04-23 23:31:29 +0000 (Thu, 23 Apr 2009) Log Message: ----------- My intention with the SPI/API stuff was that a project could put its overrides in local files named ZCONFIG_SPI_Choices.h and ZCONFIG_API_Choices.h. I've never overridden an API choice, and the only time I've forced an SPI choice I've put the #define in the project's zconfig.h file. By not #including the XXX_Choices files we don't have to have zoolib/source/cxx/default_config listed as a user header directory, simplifying project settings slightly. Modified Paths: -------------- trunk/zoolib/source/cxx/zoolib/ZCONFIG_API.h trunk/zoolib/source/cxx/zoolib/ZCONFIG_SPI.h Removed Paths: ------------- trunk/zoolib/source/cxx/default_config/ZCONFIG_API_Choices.h trunk/zoolib/source/cxx/default_config/ZCONFIG_SPI_Choices.h Deleted: trunk/zoolib/source/cxx/default_config/ZCONFIG_API_Choices.h =================================================================== --- trunk/zoolib/source/cxx/default_config/ZCONFIG_API_Choices.h 2009-04-17 02:53:50 UTC (rev 548) +++ trunk/zoolib/source/cxx/default_config/ZCONFIG_API_Choices.h 2009-04-23 23:31:29 UTC (rev 549) @@ -1,25 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2005 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZCONFIG_API_Choices__ -#define __ZCONFIG_API_Choices__ 1 -#include "zconfig.h" - -#endif // __ZCONFIG_API_Choices__ Deleted: trunk/zoolib/source/cxx/default_config/ZCONFIG_SPI_Choices.h =================================================================== --- trunk/zoolib/source/cxx/default_config/ZCONFIG_SPI_Choices.h 2009-04-17 02:53:50 UTC (rev 548) +++ trunk/zoolib/source/cxx/default_config/ZCONFIG_SPI_Choices.h 2009-04-23 23:31:29 UTC (rev 549) @@ -1,25 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2005 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZCONFIG_SPI_Choices__ -#define __ZCONFIG_SPI_Choices__ 1 -#include "zconfig.h" - -#endif // __ZCONFIG_SPI_Choices__ Modified: trunk/zoolib/source/cxx/zoolib/ZCONFIG_API.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZCONFIG_API.h 2009-04-17 02:53:50 UTC (rev 548) +++ trunk/zoolib/source/cxx/zoolib/ZCONFIG_API.h 2009-04-23 23:31:29 UTC (rev 549) @@ -23,6 +23,5 @@ #include "zconfig.h" #include "zoolib/ZCONFIG_API_Definitions.h" -#include "ZCONFIG_API_Choices.h" #endif // __ZCONFIG_API__ Modified: trunk/zoolib/source/cxx/zoolib/ZCONFIG_SPI.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZCONFIG_SPI.h 2009-04-17 02:53:50 UTC (rev 548) +++ trunk/zoolib/source/cxx/zoolib/ZCONFIG_SPI.h 2009-04-23 23:31:29 UTC (rev 549) @@ -23,10 +23,13 @@ #include "zconfig.h" #include "zoolib/ZCONFIG_SPI_Definitions.h" -#include "ZCONFIG_SPI_Choices.h" +// Pick up Apple's config macros if they're available #if __MACH__ # include <AvailabilityMacros.h> +# if defined (AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER) +# include <TargetConditionals.h> +# endif #endif // Although it seems that this formulation should work in this header, as it @@ -106,8 +109,10 @@ // ================================================================================================= #pragma mark Carbon #ifndef ZCONFIG_SPI_Avail__Carbon -# if __MACH__ && !__arm__ -# define ZCONFIG_SPI_Avail__Carbon 1 +# if __MACH__ +# if ! TARGET_IPHONE_SIMULATOR && ! TARGET_OS_IPHONE +# define ZCONFIG_SPI_Avail__Carbon 1 +# endif # elif macintosh # if defined(TARGET_API_MAC_CARBON) && TARGET_API_MAC_CARBON # define ZCONFIG_SPI_Avail__Carbon 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2009-07-19 17:27:08
|
Revision: 854 http://zoolib.svn.sourceforge.net/zoolib/?rev=854&view=rev Author: agreen Date: 2009-07-19 17:27:02 +0000 (Sun, 19 Jul 2009) Log Message: ----------- Moved to cxx_old/zoolib. Added Paths: ----------- trunk/zoolib/source/cxx_old/zoolib/ZASCompiler.cpp trunk/zoolib/source/cxx_old/zoolib/ZASCompiler.h trunk/zoolib/source/cxx_old/zoolib/ZASParser.cpp trunk/zoolib/source/cxx_old/zoolib/ZASParser.h trunk/zoolib/source/cxx_old/zoolib/ZAsset.cpp trunk/zoolib/source/cxx_old/zoolib/ZAsset.h trunk/zoolib/source/cxx_old/zoolib/ZAsset_FS.cpp trunk/zoolib/source/cxx_old/zoolib/ZAsset_FS.h trunk/zoolib/source/cxx_old/zoolib/ZAsset_MacOS.cpp trunk/zoolib/source/cxx_old/zoolib/ZAsset_MacOS.h trunk/zoolib/source/cxx_old/zoolib/ZAsset_POSIX.cpp trunk/zoolib/source/cxx_old/zoolib/ZAsset_POSIX.h trunk/zoolib/source/cxx_old/zoolib/ZAsset_Std.cpp trunk/zoolib/source/cxx_old/zoolib/ZAsset_Std.h trunk/zoolib/source/cxx_old/zoolib/ZAsset_Win.cpp trunk/zoolib/source/cxx_old/zoolib/ZAsset_Win.h trunk/zoolib/source/cxx_old/zoolib/ZDC.cpp trunk/zoolib/source/cxx_old/zoolib/ZDC.h trunk/zoolib/source/cxx_old/zoolib/ZDCGlyphServer.cpp trunk/zoolib/source/cxx_old/zoolib/ZDCGlyphServer.h trunk/zoolib/source/cxx_old/zoolib/ZDCGlyphServer_Asset.cpp trunk/zoolib/source/cxx_old/zoolib/ZDCGlyphServer_Asset.h trunk/zoolib/source/cxx_old/zoolib/ZDCInk.cpp trunk/zoolib/source/cxx_old/zoolib/ZDCInk.h trunk/zoolib/source/cxx_old/zoolib/ZDCPoly.cpp trunk/zoolib/source/cxx_old/zoolib/ZDCPoly.h trunk/zoolib/source/cxx_old/zoolib/ZDC_GDI.cpp trunk/zoolib/source/cxx_old/zoolib/ZDC_GDI.h trunk/zoolib/source/cxx_old/zoolib/ZDC_QD.cpp trunk/zoolib/source/cxx_old/zoolib/ZDC_QD.h trunk/zoolib/source/cxx_old/zoolib/ZDC_X.cpp trunk/zoolib/source/cxx_old/zoolib/ZDC_X.h trunk/zoolib/source/cxx_old/zoolib/ZDC_ZooLib.cpp trunk/zoolib/source/cxx_old/zoolib/ZDC_ZooLib.h trunk/zoolib/source/cxx_old/zoolib/ZMutexComposite.cpp trunk/zoolib/source/cxx_old/zoolib/ZMutexComposite.h trunk/zoolib/source/cxx_old/zoolib/ZNode.cpp trunk/zoolib/source/cxx_old/zoolib/ZNode.h trunk/zoolib/source/cxx_old/zoolib/ZNodeRep_Overlay.cpp trunk/zoolib/source/cxx_old/zoolib/ZNodeRep_Overlay.h trunk/zoolib/source/cxx_old/zoolib/ZNodeRep_Wrapper.cpp trunk/zoolib/source/cxx_old/zoolib/ZNodeRep_Wrapper.h trunk/zoolib/source/cxx_old/zoolib/ZNode_FS.cpp trunk/zoolib/source/cxx_old/zoolib/ZNode_FS.h trunk/zoolib/source/cxx_old/zoolib/ZWebDAV.cpp trunk/zoolib/source/cxx_old/zoolib/ZWebDAV.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZASCompiler.cpp trunk/zoolib/source/cxx/zoolib/ZASCompiler.h trunk/zoolib/source/cxx/zoolib/ZASParser.cpp trunk/zoolib/source/cxx/zoolib/ZASParser.h trunk/zoolib/source/cxx/zoolib/ZAsset.cpp trunk/zoolib/source/cxx/zoolib/ZAsset.h trunk/zoolib/source/cxx/zoolib/ZAsset_FS.cpp trunk/zoolib/source/cxx/zoolib/ZAsset_FS.h trunk/zoolib/source/cxx/zoolib/ZAsset_MacOS.cpp trunk/zoolib/source/cxx/zoolib/ZAsset_MacOS.h trunk/zoolib/source/cxx/zoolib/ZAsset_POSIX.cpp trunk/zoolib/source/cxx/zoolib/ZAsset_POSIX.h trunk/zoolib/source/cxx/zoolib/ZAsset_Std.cpp trunk/zoolib/source/cxx/zoolib/ZAsset_Std.h trunk/zoolib/source/cxx/zoolib/ZAsset_Win.cpp trunk/zoolib/source/cxx/zoolib/ZAsset_Win.h trunk/zoolib/source/cxx/zoolib/ZDC.cpp trunk/zoolib/source/cxx/zoolib/ZDC.h trunk/zoolib/source/cxx/zoolib/ZDCGlyphServer.cpp trunk/zoolib/source/cxx/zoolib/ZDCGlyphServer.h trunk/zoolib/source/cxx/zoolib/ZDCGlyphServer_Asset.cpp trunk/zoolib/source/cxx/zoolib/ZDCGlyphServer_Asset.h trunk/zoolib/source/cxx/zoolib/ZDCInk.cpp trunk/zoolib/source/cxx/zoolib/ZDCInk.h trunk/zoolib/source/cxx/zoolib/ZDCPoly.cpp trunk/zoolib/source/cxx/zoolib/ZDCPoly.h trunk/zoolib/source/cxx/zoolib/ZDC_GDI.cpp trunk/zoolib/source/cxx/zoolib/ZDC_GDI.h trunk/zoolib/source/cxx/zoolib/ZDC_QD.cpp trunk/zoolib/source/cxx/zoolib/ZDC_QD.h trunk/zoolib/source/cxx/zoolib/ZDC_X.cpp trunk/zoolib/source/cxx/zoolib/ZDC_X.h trunk/zoolib/source/cxx/zoolib/ZDC_ZooLib.cpp trunk/zoolib/source/cxx/zoolib/ZDC_ZooLib.h trunk/zoolib/source/cxx/zoolib/ZMutexComposite.cpp trunk/zoolib/source/cxx/zoolib/ZMutexComposite.h trunk/zoolib/source/cxx/zoolib/ZNode.cpp trunk/zoolib/source/cxx/zoolib/ZNode.h trunk/zoolib/source/cxx/zoolib/ZNodeRep_Overlay.cpp trunk/zoolib/source/cxx/zoolib/ZNodeRep_Overlay.h trunk/zoolib/source/cxx/zoolib/ZNodeRep_Wrapper.cpp trunk/zoolib/source/cxx/zoolib/ZNodeRep_Wrapper.h trunk/zoolib/source/cxx/zoolib/ZNode_FS.cpp trunk/zoolib/source/cxx/zoolib/ZNode_FS.h trunk/zoolib/source/cxx/zoolib/ZWebDAV.cpp trunk/zoolib/source/cxx/zoolib/ZWebDAV.h Deleted: trunk/zoolib/source/cxx/zoolib/ZASCompiler.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZASCompiler.cpp 2009-07-19 17:22:35 UTC (rev 853) +++ trunk/zoolib/source/cxx/zoolib/ZASCompiler.cpp 2009-07-19 17:27:02 UTC (rev 854) @@ -1,439 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2000 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZASCompiler.h" - -#include "zoolib/ZCompat_algorithm.h" // For sort -#include "zoolib/ZMemory.h" -#include "zoolib/ZStream_Memory.h" -#include "zoolib/ZStreamRWPos_RAM.h" - -using std::runtime_error; -using std::string; -using std::vector; - -NAMESPACE_ZOOLIB_BEGIN - -static void sWriteCount(const ZStreamW& inStream, uint32 inCount) - { - if (inCount < 0xFF) - { - inStream.WriteUInt8(uint8(inCount)); - } - else - { - inStream.WriteUInt8(0xFF); - inStream.WriteUInt32(inCount); - } - } - -static void sWriteStringWithSizePrefixAndZeroTerminator( - const ZStreamW& inStream, const string& inString) - { - sWriteCount(inStream, inString.size()); - if (inString.size()) - inStream.Write(inString.data(), inString.size()); - inStream.WriteUInt8(0); - } - -static void sSkipWrite(const ZStreamW& inStream, size_t inCount) - { - for (size_t x = 0; x < inCount; ++x) - inStream.WriteUInt8(0); - } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZASCompiler::NameEntry - -class ZASCompiler::NameEntry - { -public: - struct ReverseCompareUseCounts - { bool operator()(NameEntry* a, NameEntry* b) { return a->fUseCount > b->fUseCount; } }; - - struct CompareName - { bool operator()(NameEntry* a, const string& b) { return a->fName < b; } }; - - string fName; - int fUseCount; - int fNameIndex; - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZASCompiler::Node - -class ZASCompiler::Node - { -public: - Node(NameEntry* inNameEntry); - ~Node(); - - void FindOrAllocate( - NameEntry** inNameEntries, size_t inNameCount, size_t inDataOffset, size_t inDataSize); - - void FindOrAllocate( - NameEntry** inNameEntries, size_t inNameCount, const vector<NameEntry*>& inUnionEntries); - - void WriteTo(const ZStreamW& inStream); - - size_t AssignUseCounts(); -private: - NameEntry* fNameEntry; - Node* fChild; - Node* fSibling; - size_t fDataOffset; - size_t fDataSize; - vector<NameEntry*> fUnionEntries; - }; - -ZASCompiler::Node::Node(NameEntry* inNameEntry) - { - fNameEntry = inNameEntry; - fChild = nullptr; - fSibling = nullptr; - fDataOffset = 0; - fDataSize = 0; - } - -ZASCompiler::Node::~Node() - { - Node* currentChild = fChild; - while (currentChild) - { - Node* nextChild = currentChild->fSibling; - delete currentChild; - currentChild = nextChild; - } - } - -void ZASCompiler::Node::FindOrAllocate( - NameEntry** inNameEntries, size_t inNameCount, size_t inDataOffset, size_t inDataSize) - { - if (inNameCount == 0) - { - fDataOffset = inDataOffset; - fDataSize = inDataSize; - return; - } - - Node* priorNode = nullptr; - Node* currentNode = fChild; - while (currentNode) - { - if (currentNode->fNameEntry == inNameEntries[0]) - { - currentNode->FindOrAllocate( - inNameEntries + 1, inNameCount - 1, inDataOffset, inDataSize); - return; - } - priorNode = currentNode; - currentNode = currentNode->fSibling; - } - - Node* newNode = new Node(inNameEntries[0]); - newNode->fSibling = currentNode; - if (priorNode) - priorNode->fSibling = newNode; - else - fChild = newNode; - - newNode->FindOrAllocate(inNameEntries + 1, inNameCount - 1, inDataOffset, inDataSize); - } - -void ZASCompiler::Node::FindOrAllocate( - NameEntry** inNameEntries, size_t inNameCount, const vector<NameEntry*>& inUnionEntries) - { - if (inNameCount == 0) - { - for (vector<NameEntry*>::const_iterator i = inUnionEntries.begin(); - i != inUnionEntries.end(); ++i) - { - fUnionEntries.push_back(*i); - } - return; - } - - Node* priorNode = nullptr; - Node* currentNode = fChild; - while (currentNode) - { - if (currentNode->fNameEntry == inNameEntries[0]) - { - currentNode->FindOrAllocate(inNameEntries + 1, inNameCount - 1, inUnionEntries); - return; - } - priorNode = currentNode; - currentNode = currentNode->fSibling; - } - - Node* newNode = new Node(inNameEntries[0]); - newNode->fSibling = currentNode; - if (priorNode) - priorNode->fSibling = newNode; - else - fChild = newNode; - - newNode->FindOrAllocate(inNameEntries + 1, inNameCount - 1, inUnionEntries); - } - -size_t ZASCompiler::Node::AssignUseCounts() - { - for (vector<NameEntry*>::iterator i = fUnionEntries.begin(); i != fUnionEntries.end(); ++i) - ++(*i)->fUseCount; - - // Start at one to count ourselves - size_t childTreeSize = 1; - Node* currentChild = fChild; - while (currentChild) - { - childTreeSize += currentChild->AssignUseCounts(); - ++childTreeSize; - currentChild = currentChild->fSibling; - } - if (fNameEntry) - fNameEntry->fUseCount += childTreeSize; - return childTreeSize; - } - -void ZASCompiler::Node::WriteTo(const ZStreamW& inStream) - { - if (fUnionEntries.size()) - { - // Write our type code - inStream.WriteUInt8(2); - sWriteCount(inStream, fUnionEntries.size()); - for (vector<NameEntry*>::iterator i = fUnionEntries.begin(); i != fUnionEntries.end(); ++i) - sWriteCount(inStream, (*i)->fNameIndex); - } - else if (fDataOffset || fDataSize) - { - // Write our type code - inStream.WriteUInt8(1); - // Write the size and offset of our data (if any) - sWriteCount(inStream, fDataSize); - if (fDataSize) - inStream.WriteUInt32(fDataOffset); - } - else - { - // Write our type code - inStream.WriteUInt8(0); - - // Figure out and write the count of children we have - size_t countOfChildren = 0; - Node* currentChild = fChild; - while (currentChild) - { - ++countOfChildren; - currentChild = currentChild->fSibling; - } - sWriteCount(inStream, countOfChildren); - - // Write each child - currentChild = fChild; - while (currentChild) - { - sWriteCount(inStream, currentChild->fNameEntry->fNameIndex); - currentChild->WriteTo(inStream); - currentChild = currentChild->fSibling; - } - } - } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZASCompiler - -ZASCompiler::ZASCompiler(const ZStreamW& inStream) -: fStreamW(inStream) - { - fRoot = nullptr; - } - -ZASCompiler::~ZASCompiler() - { - delete fRoot; - for (vector<NameEntry*>::iterator i = fNameEntries.begin(); i != fNameEntries.end(); ++i) - delete *i; - } - -void ZASCompiler::StartParse() - { - ZAssert(fRoot == nullptr); - fRoot = new Node(nullptr); - } - -static const char sMagicText[] = "ZAO v1.0"; -static size_t sMagicTextSize = sizeof(sMagicText); - -void ZASCompiler::EndParse() - { - ZAssert(fRoot); - - // Walk our tree and have the nodes set up our name entries' use counts - fRoot->AssignUseCounts(); - - // Sort our name entries by use count - sort(fNameEntries.begin(), fNameEntries.end(), NameEntry::ReverseCompareUseCounts()); - - // Find the first with a zero use count - vector<NameEntry*>::iterator firstZero; - for (firstZero = fNameEntries.begin(); - (firstZero != fNameEntries.end()) && ((*firstZero)->fUseCount != 0); - ++firstZero) - {} - - // Set the names' indices for use by the nodes as they write themselves. - for (vector<NameEntry*>::iterator i = fNameEntries.begin(); i != firstZero; ++i) - (*i)->fNameIndex = i - fNameEntries.begin(); - - uint64 startOfHeader = fStreamW.GetCount(); - - // Write out the table of contents for the name table - fStreamW.WriteUInt32(firstZero - fNameEntries.begin()); - - size_t offset = 0; - for (vector<NameEntry*>::iterator i = fNameEntries.begin(); i != firstZero; ++i) - { - fStreamW.WriteInt32(offset); - offset += (*i)->fName.size() + 1; - } - // Write the offset of the end of the last name - fStreamW.WriteInt32(offset); - - // Write out the names, including terminating zero - for (vector<NameEntry*>::iterator i = fNameEntries.begin(); i != firstZero; ++i) - { - if ((*i)->fName.size()) - fStreamW.Write((*i)->fName.data(), (*i)->fName.size()); - fStreamW.WriteUInt8(0); - } - - // Walk the node tree - fRoot->WriteTo(fStreamW); - - // Write the overall size of the header - fStreamW.WriteUInt32(fStreamW.GetCount() - startOfHeader); - - // Write out the magic text - fStreamW.Write(sMagicText, sMagicTextSize); - - delete fRoot; - fRoot = nullptr; - for (vector<NameEntry*>::iterator i = fNameEntries.begin(); i != fNameEntries.end(); ++i) - delete *i; - fNameEntries.clear(); - } - -void ZASCompiler::EnterName(const string& inName, bool iWasInBlock, bool iNowInBlock) - { - fNameStack.push_back(inName); - } - -void ZASCompiler::ExitName(bool iWasInBlock, bool iNowInBlock) - { - fNameStack.pop_back(); - } - -void ZASCompiler::ParsedString(const string& inValue) - { - // We add the data of the string including its zero terminator, hence the '+ 1' below. - this->AddAsset(fNameStack, "!string", ZStreamRPos_Memory(inValue.c_str(), inValue.size() + 1)); - } - -void ZASCompiler::ParsedStringTable(const vector<string>& inValues) - { - ZStreamRWPos_RAM theStream; - sWriteCount(theStream, inValues.size()); - for (size_t x = 0; x < inValues.size(); ++x) - sWriteStringWithSizePrefixAndZeroTerminator(theStream, inValues[x]); - theStream.SetPosition(0); - this->AddAsset(fNameStack, "!stringtable", theStream); - } - -void ZASCompiler::ParsedBinary(const ZStreamR& inStream) - { - this->AddAsset(fNameStack, "!binary", inStream); - } - -void ZASCompiler::ParsedUnion(const vector<string>& iNames) - { - // Turn the list of names into a list of NameEntries - vector<NameEntry*> nameEntries; - for (size_t x = 0; x < fNameStack.size(); ++x) - nameEntries.push_back(this->AllocateName(fNameStack[x])); - - vector<NameEntry*> unionEntries; - for (size_t x = 0; x < iNames.size(); ++x) - unionEntries.push_back(this->AllocateName(iNames[x])); - fRoot->FindOrAllocate(&nameEntries[0], nameEntries.size(), unionEntries); - } - -void ZASCompiler::AddAsset(const vector<string>& inNameStack, - const string& inType, const ZStreamR& inStream) - { - // Turn the list of names into a list of NameEntries - vector<NameEntry*> nameEntries; - for (size_t x = 0; x < inNameStack.size(); ++x) - nameEntries.push_back(this->AllocateName(inNameStack[x])); - // Add the type to the end - nameEntries.push_back(this->AllocateName(inType)); - - // Transcribe the data - uint64 startPosition = fStreamW.GetCount(); - uint64 countRead; - uint64 countWritten; - fStreamW.CopyAllFrom(inStream, &countRead, &countWritten); - if (countRead != countWritten) - throw runtime_error("ZASCompiler::AddAsset, unexpected end of output stream"); - - uint64 endPosition = fStreamW.GetCount(); - - // Find the node and tell it its data info - fRoot->FindOrAllocate( - &nameEntries[0], nameEntries.size(), startPosition, endPosition - startPosition); - - // Align the end of the data at the next four byte boundary. Note that we're aligned - // relative to where we wrote our first byte in the stream, _not_ relative to the start - // of whatever underlies the stream. - sSkipWrite(fStreamW, ((endPosition + 3) & ~3) - endPosition); - } - -ZASCompiler::NameEntry* ZASCompiler::AllocateName(const string& inName) - { - if (inName.empty()) - throw runtime_error("ZASCompiler::AllocateName, empty name"); - - vector<NameEntry*>::iterator iter - = lower_bound(fNameEntries.begin(), fNameEntries.end(), inName, NameEntry::CompareName()); - - if (iter != fNameEntries.end() && (*iter)->fName == inName) - return *iter; - - NameEntry* theEntry = new NameEntry; - theEntry->fName = inName; - theEntry->fUseCount = 0; - fNameEntries.insert(iter, theEntry); - return theEntry; - } - -NAMESPACE_ZOOLIB_END Deleted: trunk/zoolib/source/cxx/zoolib/ZASCompiler.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZASCompiler.h 2009-07-19 17:22:35 UTC (rev 853) +++ trunk/zoolib/source/cxx/zoolib/ZASCompiler.h 2009-07-19 17:27:02 UTC (rev 854) @@ -1,72 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2001 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZASCompiler__ -#define __ZASCompiler__ 1 -#include "zconfig.h" - -#include "zoolib/ZASParser.h" -#include "zoolib/ZStream_Count.h" - -#include <vector> -#include <string> - -NAMESPACE_ZOOLIB_BEGIN - -// ================================================================================================= -#pragma mark - -#pragma mark * ZASCompiler - -class ZASCompiler : public ZASParser::ParseHandler - { -public: - ZASCompiler(const ZStreamW& inStream); - virtual ~ZASCompiler(); - - virtual void StartParse(); - virtual void EndParse(); - - virtual void EnterName(const std::string& inName, bool iWasInBlock, bool iNowInBlock); - virtual void ExitName(bool iWasInBlock, bool iNowInBlock); - - virtual void ParsedString(const std::string& inValue); - virtual void ParsedStringTable(const std::vector<std::string>& inValues); - virtual void ParsedBinary(const ZStreamR& inStream); - virtual void ParsedUnion(const std::vector<std::string>& iNames); - -protected: - class NameEntry; - class Node; - - void AddAsset(const std::vector<std::string>& inNameStack, - const std::string& inType, const ZStreamR& inStream); - - NameEntry* AllocateName(const std::string& inName); - - ZStreamW_Count fStreamW; - - Node* fRoot; - std::vector<NameEntry*> fNameEntries; - std::vector<std::string> fNameStack; - }; - -NAMESPACE_ZOOLIB_END - -#endif // __ZASCompiler__ Deleted: trunk/zoolib/source/cxx/zoolib/ZASParser.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZASParser.cpp 2009-07-19 17:22:35 UTC (rev 853) +++ trunk/zoolib/source/cxx/zoolib/ZASParser.cpp 2009-07-19 17:27:02 UTC (rev 854) @@ -1,915 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2001 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZASParser.h" - -#include "zoolib/ZFile.h" -#include "zoolib/ZStreamRWPos_RAM.h" -#include "zoolib/ZStream_Buffered.h" -#include "zoolib/ZStreamR_HexStrim.h" -#include "zoolib/ZStreamW_HexStrim.h" -#include "zoolib/ZStreamer.h" -#include "zoolib/ZStrim_CRLF.h" -#include "zoolib/ZStrim_Escaped.h" -#include "zoolib/ZStrim_Stream.h" -#include "zoolib/ZStrimU_Std.h" -#include "zoolib/ZString.h" -#include "zoolib/ZTextCoder.h" -#include "zoolib/ZTextCoder_Unicode.h" -#include "zoolib/ZUnicode.h" -#include "zoolib/ZUtil_Strim.h" - -#include <stdio.h> - -using std::exception; -using std::pair; -using std::string; -using std::vector; - -NAMESPACE_ZOOLIB_BEGIN - -namespace ZANONYMOUS { - -// ================================================================================================= -#pragma mark - -#pragma mark * Static helper functions - -static bool sAtEnd(ZStrimU& iStrimU) - { - UTF32 theCP; - if (!iStrimU.ReadCP(theCP)) - return true; - iStrimU.Unread(theCP); - return false; - } - -// ================================================================================================= -#pragma mark - -#pragma mark * DecoderSetter - -class DecoderSetter - { -public: - DecoderSetter(ZStrimU_Std& iStrim, ZTextDecoder* iDecoder); - ~DecoderSetter(); - -private: - ZStrimU_Std& fStrim; - ZTextDecoder* fPrior; - }; - -DecoderSetter::DecoderSetter(ZStrimU_Std& iStrim, ZTextDecoder* iDecoder) -: fStrim(iStrim) - { - fPrior = fStrim.SetDecoderReturnOld(iDecoder); - } - -DecoderSetter::~DecoderSetter() - { - delete fStrim.SetDecoderReturnOld(fPrior); - } - -// ================================================================================================= -#pragma mark - -#pragma mark * Parser - -class NestedParse : public std::exception - { -public: - NestedParse(const string& iMessage, const ZFileSpec& iFileSpec, int iLineNumber); - ~NestedParse() throw(); - - void Append(const ZFileSpec& iFileSpec, int iLineNumber); - - const string& GetMessage() const { return fMessage; } - const vector<pair<ZFileSpec, int> >& GetSources() const { return fSources; } - -private: - string fMessage; - vector<pair<ZFileSpec, int> > fSources; - }; - -NestedParse::NestedParse(const string& iMessage, const ZFileSpec& iFileSpec, int iLineNumber) -: fMessage(iMessage), - fSources(1, pair<ZFileSpec, int>(iFileSpec, iLineNumber)) - {} - -NestedParse::~NestedParse() throw() - {} - -void NestedParse::Append(const ZFileSpec& iFileSpec, int iLineNumber) - { - fSources.push_back(pair<ZFileSpec, int>(iFileSpec, iLineNumber)); - } - -class Parser - { -public: - Parser(ZASParser::ParseHandler& iParseHandler, - const ZASParser::StreamProvider& iStreamProvider, - const ZASParser::ErrorHandler& iErrorHandler, - ZASParser::IncludeHandler* iIncludeHandler); - ~Parser(); - - void Parse(const ZFileSpec& iFileSpec, const ZStreamR& iStream); - - void Parse(); - - bool TryParseStatement(); - - void ParseNameBody(const string& inName); - - void ParseStringTable(); - - void ParseBinary(); - - void ParseUnion(); - - void ParseCharSet(); - - bool TryParseQuotedString(string& oString); - - bool TryParseStringBody(string& oString); - -protected: - ZStrimU_Std* fStrimU; - ZFileSpec fFileSpec; - int fCumulativeLineCount; - bool fInBlock; - - ZASParser::ParseHandler& fParseHandler; - const ZASParser::StreamProvider& fStreamProvider; - const ZASParser::ErrorHandler& fErrorHandler; - ZASParser::IncludeHandler* fIncludeHandler; - }; - -Parser::Parser(ZASParser::ParseHandler& iParseHandler, - const ZASParser::StreamProvider& iStreamProvider, - const ZASParser::ErrorHandler& iErrorHandler, - ZASParser::IncludeHandler* iIncludeHandler) -: fStrimU(nullptr), - fCumulativeLineCount(0), - fInBlock(false), - fParseHandler(iParseHandler), - fStreamProvider(iStreamProvider), - fErrorHandler(iErrorHandler), - fIncludeHandler(iIncludeHandler) - {} - -Parser::~Parser() - {} - -void Parser::Parse(const ZFileSpec& iFileSpec, const ZStreamR& iStream) - { - using namespace ZUtil_Strim; - - // We start off with an auto-detecting unicode decoder. So we'll try - // to read a UTF16 BE or LE BOM off the stream. If that's not detected we'll - // treat the stream as being UTF8, at least until a charset statement - // is encountered specifying something else. - - ZStrimU_Std theStrimU(new ZTextDecoder_Unicode_AutoDetect, iStream); - - ZStrimU_Std* priorStrimU = fStrimU; - fStrimU = &theStrimU; - - ZFileSpec priorFileSpec = fFileSpec; - fFileSpec = iFileSpec; - - try - { - try - { - this->Parse(); - } - catch (NestedParse& theEx) - { - theEx.Append(iFileSpec, theStrimU.GetLineCount()); - printf("EX1\n"); - throw; - } - catch (exception& ex) - { - printf("EX2\n"); - throw NestedParse(ex.what(), iFileSpec, theStrimU.GetLineCount()); - } - } - catch (...) - { - printf("EX3\n"); - fStrimU = priorStrimU; - fFileSpec = priorFileSpec; - throw; - } - - fCumulativeLineCount += theStrimU.GetLineCount(); - fStrimU = priorStrimU; - fFileSpec = priorFileSpec; - } - -void Parser::Parse() - { - using namespace ZUtil_Strim; - - for (;;) - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - if (sAtEnd(*fStrimU)) - return; - - if (!this->TryParseStatement()) - throw ParseException("Expected a top-level statement"); - } - } - -bool Parser::TryParseStatement() - { - using namespace ZUtil_Strim; - - fErrorHandler.ReportProgress(fCumulativeLineCount + fStrimU->GetLineCount()); - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - string theIdentifier; - if (!sTryRead_Identifier(*fStrimU, theIdentifier)) - { - // We didn't see an identifier. It might be a statement without a "name", - // "directory" or "dir" prefix. - string name; - if (!sTryRead_EscapedString(*fStrimU, '"', name)) - return false; - - this->ParseNameBody(name); - } - else - { - theIdentifier = ZUnicode::sToLower(theIdentifier); - - if (theIdentifier == "name" || theIdentifier == "directory" || theIdentifier == "dir") - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - - string name; - if (!sTryRead_EscapedString(*fStrimU, '"', name)) - throw ParseException("Expected a quoted string"); - - this->ParseNameBody(name); - } - else if (theIdentifier == "string") - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - string theString; - if (!this->TryParseStringBody(theString)) - throw ParseException("Expected a valid string body"); - fParseHandler.ParsedString(theString); - } - else if (theIdentifier == "stringtable") - { - this->ParseStringTable(); - } - else if (theIdentifier == "binary") - { - this->ParseBinary(); - } - else if (theIdentifier == "union" || theIdentifier == "alias") - { - this->ParseUnion(); - } - else if (theIdentifier == "charset") - { - this->ParseCharSet(); - } - else if (theIdentifier == "include") - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - string path; - if (!sTryRead_EscapedString(*fStrimU, '"', path)) - throw ParseException("Expected a quoted file name"); - - ZFileSpec specUsed; - if (ZRef<ZStreamerR> theStreamer - = fStreamProvider.ProvideStreamSource(fFileSpec, path, true, specUsed)) - { - if (fIncludeHandler) - fIncludeHandler->NotifyInclude(specUsed); - fParseHandler.EnterInclude(specUsed); - this->Parse(specUsed, theStreamer->GetStreamR()); - fParseHandler.ExitInclude(); - } - else - { - throw ParseException("Could not open file \"" + path + "\""); - } - } - else - { - throw ParseException("Unrecognized keyword \"" + theIdentifier +"\""); - } - } - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - // Allow an optional statement terminator. - sTryRead_CP(*fStrimU, ';'); - return true; - } - -void Parser::ParseNameBody(const string& inName) - { - using namespace ZUtil_Strim; - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - if (sTryRead_CP(*fStrimU, '{')) - { - bool wasInBlock = fInBlock; - fInBlock = true; - fParseHandler.EnterName(inName, wasInBlock, true); - for (;;) - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - if (sAtEnd(*fStrimU)) - break; - - if (!this->TryParseStatement()) - break; - } - fParseHandler.ExitName(true, wasInBlock); - fInBlock = wasInBlock; - - if (!sTryRead_CP(*fStrimU, '}')) - throw ParseException("Expected '}'"); - } - else - { - bool wasInBlock = fInBlock; - fInBlock = false; - - fParseHandler.EnterName(inName, wasInBlock, false); - - if (!this->TryParseStatement()) - throw ParseException("Expected a statement after the name"); - - fParseHandler.ExitName(false, wasInBlock); - - fInBlock = wasInBlock; - } - } - -void Parser::ParseStringTable() - { - using namespace ZUtil_Strim; - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - if (!sTryRead_CP(*fStrimU, '{')) - throw ParseException("Expected '{'"); - - vector<string> strings; - for (;;) - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - string currentString; - if (!this->TryParseStringBody(currentString)) - break; - sSkip_WSAndCPlusPlusComments(*fStrimU); - if (!sTryRead_CP(*fStrimU, ',') && !sTryRead_CP(*fStrimU, ';')) - break; - strings.push_back(currentString); - } - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - if (!sTryRead_CP(*fStrimU, '}')) - throw ParseException("Expected '}'"); - - fParseHandler.ParsedStringTable(strings); - } - -void Parser::ParseBinary() - { - using namespace ZUtil_Strim; - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - if (sTryRead_CP(*fStrimU, '{')) - { - fParseHandler.ParsedBinary(ZStreamR_HexStrim(true, *fStrimU)); - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - if (!sTryRead_CP(*fStrimU, '}')) - throw ParseException("Expected '}'"); - } - else - { - string fileName; - if (!sTryRead_EscapedString(*fStrimU, '"', fileName)) - throw ParseException("Expected a quoted file name"); - - ZFileSpec fileSpecUsed; - ZRef<ZStreamerR> theStreamer - = fStreamProvider.ProvideStreamBinary(fFileSpec, fileName, true, fileSpecUsed); - if (!theStreamer) - { - throw ParseException( - string("Could not open file \"") + fileName + string("\" to read binary data")); - } - - if (fIncludeHandler) - fIncludeHandler->NotifyInclude(fileSpecUsed); - - fParseHandler.ParsedBinary(theStreamer->GetStreamR()); - } - } - -void Parser::ParseUnion() - { - using namespace ZUtil_Strim; - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - vector<string> names; - - if (sTryRead_CP(*fStrimU, '{')) - { - for (;;) - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - string currentName; - if (!sTryRead_EscapedString(*fStrimU, '"', currentName)) - break; - names.push_back(currentName); - sSkip_WSAndCPlusPlusComments(*fStrimU); - if (!sTryRead_CP(*fStrimU, ',') && !sTryRead_CP(*fStrimU, ';')) - break; - } - sSkip_WSAndCPlusPlusComments(*fStrimU); - - if (!sTryRead_CP(*fStrimU, '}')) - throw ParseException("Expected '}'"); - } - else - { - string theName; - if (!sTryRead_EscapedString(*fStrimU, '"', theName)) - throw ParseException("Expected a quoted name"); - - names.push_back(theName); - } - - fParseHandler.ParsedUnion(names); - } - -void Parser::ParseCharSet() - { - using namespace ZUtil_Strim; - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - string charSetName; - if (!sTryRead_EscapedString(*fStrimU, '"', charSetName)) - throw ParseException("Expected a quoted string for charset"); - - ZTextDecoder* theTextDecoder = ZTextDecoder::sMake(charSetName); - if (theTextDecoder == nullptr) - throw ParseException("Unsupported charset \"" + charSetName + "\""); - - DecoderSetter theSetter(*fStrimU, theTextDecoder); - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - if (sTryRead_CP(*fStrimU, '{')) - { - bool wasInBlock = fInBlock; - fInBlock = true; - fParseHandler.EnterCharSet(charSetName, wasInBlock, true); - - for (;;) - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - if (!this->TryParseStatement()) - break; - } - - fParseHandler.ExitCharSet(true, wasInBlock); - fInBlock = wasInBlock; - - if (!sTryRead_CP(*fStrimU, '}')) - throw ParseException("Expected a '}'"); - } - else - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - - bool wasInBlock = fInBlock; - fInBlock = false; - fParseHandler.EnterCharSet(charSetName, wasInBlock, false); - - if (!this->TryParseStatement()) - throw ParseException("#3 Expected a statement"); - - fParseHandler.ExitCharSet(false, wasInBlock); - fInBlock = wasInBlock; - } - } - -bool Parser::TryParseStringBody(string& oString) - { - using namespace ZUtil_Strim; - - oString.resize(0); - - sSkip_WSAndCPlusPlusComments(*fStrimU); - - string curString; - if (!sTryRead_EscapedString(*fStrimU, '"', curString)) - return false; - - oString = curString; - for (;;) - { - sSkip_WSAndCPlusPlusComments(*fStrimU); - if (!sTryRead_EscapedString(*fStrimU, '"', curString)) - return true; - oString += curString; - } - } - -} // anonymous namespace - -// ================================================================================================= -#pragma mark - -#pragma mark * ZASParser::sParse - -/** -This is the entry point for parsing when you have a source file's path. It just -attempts to open the file and passes it on to the stream-taking sParse, which is -responsible for actually catching and reporting parse exceptions. -*/ -bool ZASParser::sParse(const string& iPath, ParseHandler& iParseHandler, - const StreamProvider& iStreamProvider, - const ErrorHandler& iErrorHandler, IncludeHandler* iIncludeHandler) - { - ZFileSpec fileSpecUsed; - if (ZRef<ZStreamerR> theStreamer - = iStreamProvider.ProvideStreamSource(ZFileSpec(), iPath, true, fileSpecUsed)) - { - return sParse(fileSpecUsed, theStreamer->GetStreamR(), - iParseHandler, iStreamProvider, iErrorHandler, iIncludeHandler); - } - else - { - iErrorHandler.ReportError("Could not open source file \"" + iPath + "\""); - } - return false; - } - -/** -This is the entry point for parsing when you have source stream and the textual name -of that stream, and is also called -*/ -bool ZASParser::sParse( - const ZFileSpec& iFileSpec, const ZStreamR& iStream, ParseHandler& iParseHandler, - const StreamProvider& iStreamProvider, - const ErrorHandler& iErrorHandler, IncludeHandler* iIncludeHandler) - { - try - { - Parser theParser(iParseHandler, iStreamProvider, iErrorHandler, iIncludeHandler); - iParseHandler.StartParse(); - theParser.Parse(iFileSpec, iStream); - iParseHandler.EndParse(); - return true; - } - catch (NestedParse& ex) - { - printf("EX4\n"); - iErrorHandler.ReportError(ex.GetSources(), ex.GetMessage()); - } - catch (exception& ex) - { - printf("EX5\n"); - iErrorHandler.ReportError(ex.what()); - } - catch (...) - { - iErrorHandler.ReportError("Unknown exception"); - } - return false; - } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZASParser::ParseHandler - -void ZASParser::ParseHandler::StartParse() - {} - -void ZASParser::ParseHandler::EndParse() - {} - -void ZASParser::ParseHandler::EnterName(const string& iName, bool iWasInBlock, bool iNowInBlock) - {} - -void ZASParser::ParseHandler::ExitName(bool iWasInBlock, bool iNowInBlock) - {} - -void ZASParser::ParseHandler::ParsedString(const string& iValue) - {} - -void ZASParser::ParseHandler::ParsedStringTable(const vector<string>& iValues) - {} - -void ZASParser::ParseHandler::ParsedBinary(const ZStreamR& iStream) - { - // Just suck up and ignore the data - iStream.SkipAll(nullptr); - } - -void ZASParser::ParseHandler::ParsedUnion(const vector<string>& iNames) - {} - -void ZASParser::ParseHandler::EnterInclude(const ZFileSpec& iFileSpec) - {} - -void ZASParser::ParseHandler::ExitInclude() - {} - -void ZASParser::ParseHandler::EnterCharSet( - const string& iCharSet, bool iWasInBlock, bool iNowInBlock) - {} - -void ZASParser::ParseHandler::ExitCharSet(bool iWasInBlock, bool iNowInBlock) - {} - -// ================================================================================================= -#pragma mark - -#pragma mark * ZASParser::StreamProvider - -ZRef<ZStreamerR> ZASParser::StreamProvider::ProvideStreamSource( - const ZFileSpec& iCurrent, const string& iPath, - bool iSearchUserDirectories, ZFileSpec& oFileSpec) const - { return ZRef<ZStreamerR>(); } - -ZRef<ZStreamerR> ZASParser::StreamProvider::ProvideStreamBinary( - const ZFileSpec& iCurrent, const string& iPath, - bool iSearchUserDirectories, ZFileSpec& oFileSpec) const - { return ZRef<ZStreamerR>(); } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZASParser::ErrorHandler - -void ZASParser::ErrorHandler::ReportError( - const vector<pair<ZFileSpec, int> >& iSources, const string& iMessage) const - {} - -void ZASParser::ErrorHandler::ReportError(const string& iMessage) const - {} - -void ZASParser::ErrorHandler::ReportProgress(int iLinesProcessed) const - {} - -// ================================================================================================= -#pragma mark - -#pragma mark * ZASParser::ParseHandler_Prettify - -static void sWriteIndent(const ZStrimW& iStrimW, int iIndent) - { - ZAssert(iIndent >= 0); - for (int x = 0; x < iIndent; ++x) - iStrimW.WriteCP('\t'); - } - -static void sWriteEscapifiedString(const ZStrimW& iStrimW, const string& iString) - { - ZStrimW_Escaped(iStrimW).Write(iString); - } - -static void sWriteEscapifiedStringIndented( - const ZStrimW& iStrimW, const string& iString, int iIndent) - { - string eol = "\"\n"; - eol += string(iIndent, '\t'); - eol += "\""; - ZStrimW_Escaped::Options theOptions; - theOptions.fEOL = eol; - ZStrimW_Escaped(theOptions, iStrimW).Write(iString); - } - -ZASParser::ParseHandler_Prettify::ParseHandler_Prettify(const ZStrimW& iStrimW, bool iDumpBinaries) -: fStrimW(iStrimW), - fDumpBinaries(iDumpBinaries), - fIndent(0), - fInBlock(false) - {} - -void ZASParser::ParseHandler_Prettify::EnterName( - const string& iName, bool iWasInBlock, bool iNowInBlock) - { - if (iWasInBlock) - sWriteIndent(fStrimW, fIndent); - fStrimW.Write("name \""); - sWriteEscapifiedString(fStrimW, iName); - fStrimW.Write("\""); - - fNames.push_back(iName); - if (iNowInBlock) - { - ++fIndent; - fStrimW.Write("\n"); - sWriteIndent(fStrimW, fIndent); - fStrimW.Write("{\n"); - } - else - { - fStrimW.Write(" "); - } - fInBlock = iNowInBlock; - } - -void ZASParser::ParseHandler_Prettify::ExitName(bool iWasInBlock, bool iNowInBlock) - { - if (iWasInBlock) - { - sWriteIndent(fStrimW, fIndent); - fStrimW.Write("} // name \""); - sWriteEscapifiedString(fStrimW, fNames.back()); - fStrimW.Write("\"\n"); - --fIndent; - } - fInBlock = iNowInBlock; - fNames.pop_back(); - } - -void ZASParser::ParseHandler_Prettify::ParsedString(const string& iValue) - { - if (fInBlock) - sWriteIndent(fStrimW, fIndent); - fStrimW.Write("string \""); - sWriteEscapifiedStringIndented(fStrimW, iValue, fIndent); - fStrimW.Write("\"\n"); - } - -void ZASParser::ParseHandler_Prettify::ParsedStringTable(const vector<string>& iValues) - { - if (fInBlock) - sWriteIndent(fStrimW, fIndent); - - fStrimW.Write("stringtable\n"); - - sWriteIndent(fStrimW, fIndent + 1); - fStrimW.Write("{\n"); - - for (size_t x = 0; x < iValues.size(); ++x) - { - sWriteIndent(fStrimW, fIndent + 1); - fStrimW.Write("\""); - sWriteEscapifiedStringIndented(fStrimW, iValues[x], fIndent); - fStrimW.Write("\""); - if (x != iValues.size() - 1) - fStrimW.Write(","); - fStrimW.Write("\n"); - } - sWriteIndent(fStrimW, fIndent + 1); - fStrimW.Writef("} // (%d entries)\n", iValues.size()); - } - -void ZASParser::ParseHandler_Prettify::ParsedBinary(const ZStreamR& iStream) - { - if (fDumpBinaries) - { - if (fInBlock) - sWriteIndent(fStrimW, fIndent); - - // Let's see if we've got more than 16 bytes. We only have a read - // stream, so we can't _ask_ how many bytes would be physically - // readable (CountReadable only provides a lower limit, and - // can return zero even when there's data available). So we - // have to actually suck it and see. We use a ZStreamR_DynamicBuffered, - // which lets us read the stream, then return the read bytes to - // be re-read if it turns out we've got enough to warrant doing - // indentation. - - ZStreamRWPos_RAM theStreamRAM; - ZStreamR_DynamicBuffered theStream(iStream, theStreamRAM); - uint64 countSkipped; - theStream.Skip(17, &countSkipped); - theStream.Rewind(); - theStream.Commit(); - - if (countSkipped <= 16) - { - // We've got 16 or fewer bytes, emit them on the same line. - fStrimW.Write("binary { "); - ZStreamW_HexStrim(" ", "", 16, fStrimW).CopyAllFrom(theStream, nullptr, nullptr); - fStrimW.Write(" }\n"); - } - else - { - // We've got more than 16 bytes, break them up into nice lines. - fStrimW.Write("binary\n"); - - sWriteIndent(fStrimW, fIndent + 1); - fStrimW.Write("{"); - - uint64 size; - string chunkSeparator = "\n" + string(fIndent + 1, '\t'); - ZStreamW_HexStrim(" ", chunkSeparator, 16, fStrimW).CopyAllFrom(theStream, &size, nullptr); - - fStrimW.Write("\n"); - sWriteIndent(fStrimW, fIndent + 1); - fStrimW.Writef("} // %lld bytes\n", size); - } - } - else - { - uint64 size; - iStream.SkipAll(&size); - - if (fInBlock) - sWriteIndent(fStrimW, fIndent); - - fStrimW.Writef("binary { /* content not shown */ } // %d bytes\n", size); - } - } - -void ZASParser::ParseHandler_Prettify::ParsedUnion(const vector<string>& iNames) - { - if (fInBlock) - sWriteIndent(fStrimW, fIndent); - - fStrimW.Write("union\n"); - - sWriteIndent(fStrimW, fIndent + 1); - fStrimW.Write("{\n"); - - for (size_t x = 0; x < iNames.size(); ++x) - { - sWriteIndent(fStrimW, fIndent + 1); - fStrimW.Write("\""); - sWriteEscapifiedString(fStrimW, iNames[x]); - fStrimW.Write("\""); - if (x != iNames.size() - 1) - fStrimW.Write(","); - fStrimW.Write("\n"); - } - sWriteIndent(fStrimW, fIndent + 1); - fStrimW.Writef("} // (%d entries)\n", iNames.size()); - } - -void ZASParser::ParseHandler_Prettify::EnterInclude(const ZFileSpec& iFileSpec) - { - sWriteIndent(fStrimW, fIndent); - fStrimW.Write("// -----> enter file \""); - string fileAsString = iFileSpec.AsString(); - sWriteEscapifiedString(fStrimW, fileAsString); - fStrimW.Write("\"\n"); - - fIncludes.push_back(fileAsString); - } - -void ZASParser::ParseHandler_Prettify::ExitInclude() - { - sWriteIndent(fStrimW, fIndent); - fStrimW.Write("// <----- exit file \""); - sWriteEscapifiedString(fStrimW, fIncludes.back()); - fStrimW.Write("\"\n"); - - fIncludes.pop_back(); - } - -void ZASParser::ParseHandler_Prettify::EnterCharSet( - const string& iCharSet, bool iWasInBlock, bool iNowInBlock) - { - // We don't emit any charset designator -- we're dumping everything as unicode. - // However we do need to handle indentation. - if (iWasInBlock && !iNowInBlock) - sWriteIndent(fStrimW, fIndent); - fInBlock = iNowInBlock; - } - -void ZASParser::ParseHandler_Prettify::ExitCharSet(bool iWasInBlock, bool iNowInBlock) - { - fInBlock = iNowInBlock; - } - -NAMESPACE_ZOOLIB_END Deleted: trunk/zoolib/source/cxx/zoolib/ZASParser.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZASParser.h 2009-07-19 17:22:35 UTC (rev 853) +++ trunk/zoolib/source/cxx/zoolib/ZASParser.h 2009-07-19 17:27:02 UTC (rev 854) @@ -1,181 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2000 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZASParser__ -#define __ZASParser__ 1 -#include "zconfig.h" - -#include "zoolib/ZRef.h" -#include "zoolib/ZStream.h" -#include "zoolib/ZStrim.h" - -#include <vector> - -NAMESPACE_ZOOLIB_BEGIN - -class ZFileSpec; -class ZStreamerR; - -namespace ZASParser { - -class ErrorHandler; -class IncludeHandler; -class ParseHandler; -class StreamProvider; - -bool sParse(const std::string& iPath, ParseHandler& iParseHandler, - const StreamProvider& iStreamProvider, - const ErrorHandler& iErrorHandler, IncludeHandler* iIncludeHandler); - -bool sParse(const ZFileSpec& iFileSpec, const ZStreamR& iStream, ParseHandler& iParseHandler, - const StreamProvider& iStreamProvider, - const ErrorHandler& iErrorHandler, IncludeHandler* iIncludeHandler); - -// ================================================================================================= -#pragma mark - -#pragma mark * ParseHandler - -class ParseHandler - { -protected: - ParseHandler(const ParseHandler&) {} - ParseHandler& operator=(ParseHandler&) { return *this; } - -public: - ParseHandler() {} - ~ParseHandler() {} - - virtual void StartParse(); - virtual void EndParse(); - - virtual void EnterName(const std::string& iName, bool iWasInBlock, bool iNowInBlock); - virtual void ExitName(bool iWasInBlock, bool iNowInBlock); - - virtual void ParsedString(const std::string& iValue); - virtual void ParsedStringTable(const std::vector<std::string>& iValues); - virtual void ParsedBinary(const ZStreamR& iStream); - virtual void ParsedUnion(const std::vector<std::string>& iNames); - - virtual void EnterInclude(const ZFileSpec& iFileSpec); - virtual void ExitInclude(); - - virtual void EnterCharSet(const std::string& iCharSet, bool iWasInBlock, bool iNowInBlock); - virtual void ExitCharSet(bool iWasInBlock, bool iNowInBlock); - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * StreamProvider - -class StreamProvider - { -protected: - StreamProvider(const StreamProvider&) {} - StreamProvider& operator=(StreamProvider&) { return *this; } - -public: - StreamProvider() {} - ~StreamProvider() {} - - virtual ZRef<ZStreamerR> ProvideStreamSource( - const ZFileSpec& iCurrent, const std::string& iPath, - bool iSearchUserDirectories, ZFileSpec& oFileSpec) const; - - virtual ZRef<ZStreamerR> ProvideStreamBinary( - const ZFileSpec& iCurrent, const std::string& iPath, - bool iSearchUserDirectories, ZFileSpec& oFileSpec) const; - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * ErrorHandler - -class ErrorHandler - { -protected: - ErrorHandler(const ErrorHandler&) {} - ErrorHandler& operator=(ErrorHandler&) { return *this; } - -public: - ErrorHandler() {} - ~ErrorHandler() {} - - virtual void ReportError( - const std::vector<std::pair<ZFileSpec, int> >& iSources, - const std::string& iMessage) const; - - virtual void ReportError(const std::string& iMessage) const; - virtual void ReportProgress(int iLinesProcessed) const; - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * IncludeHandler - -class IncludeHandler - { -protected: - IncludeHandler() {} - IncludeHandler(const IncludeHandler&) {} - ~IncludeHandler() {} - IncludeHandler& operator=(IncludeHandler&) { return *this; } - -public: - virtual void NotifyInclude(const ZFileSpec& iFileSpec) = 0; - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * ParseHandler_Prettify - -class ParseHandler_Prettify : public ZASParser::ParseHandler - { -public: - ParseHandler_Prettify(const ZStrimW& iStrimW, bool iDumpBinaries); - - virtual void EnterName(const std::string& iName, bool iWasInBlock, bool iNowInBlock); - virtual void ExitName(bool iWasInBlock, bool iNowInBlock); - - virtual void ParsedString(const std::string& iValue); - virtual void ParsedStringTable(const std::vector<std::string>& iValues); - virtual void ParsedBinary(const ZStreamR& iStream); - virtual void ParsedUnion(const std::vector<std::string>& iNames); - - virtual void EnterInclude(const ZFileSpec& iFileSpec); - virtual void ExitInclude(); - - virtual void EnterCharSet(const std::string& iCharSet, bool iWasInBlock, bool iNowInBlock); - virtual void ExitCharSet(bool iWasInBlock, bool iNowInBlock); - -protected: - const ZStrimW& fStrimW; - bool fDumpBinaries; - std::vector<std::string> fNames; - std::vector<std::string> fIncludes; - std::vector<std::string> fCharSets; - int fIndent; - bool fInBlock; - }; - -} // namespace ZASParser - -NAMESPACE_ZOOLIB_END - -#endif // __ZASParser__ Deleted: trunk/zoolib/source/cxx/zoolib/ZAsset.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZAsset.cpp 2009-07-19 17:22:35 UTC (rev 853) +++ trunk/zoolib/source/cxx/zoolib/ZAsset.cpp 2009-07-19 17:27:02 UTC (rev 854) @@ -1,820 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2000 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZAsset.h" - -using std::set; -using std::string; -using std::vector; - -NAMESPACE_ZOOLIB_BEGIN - -/** -\defgroup group_Asset Assets - -The name \e asset was chosen as an alternative to \e resource. Resource is a -term that already has too many disparate meanings on our target platforms, -an alternate designation keeps the distinction clear. That said, assets are -used in the same situations that MacOS/Win32/BeOS resources would be, although -the mechanism is more flexible. - -Rather than occupying a flat space, or one segmented by a type code and -name/ID, assets are instead organized as a tree. Each asset in the tree -is named and has a parent. The root asset's name is the empty string, and -its parent is null. Assets may have children, in which case they're known as -directories, or they may be leaf assets and contain actual data. Let's use -an example: - -\code -name "MyApplication" - { - name "MyDialog" - { - name "Title" string "My Dialog Title" - name "Icon" binary "MyDialogIcon.bmp" - } - } -\endcode - -The unnamed root asset is a directory with the single child <tt>MyApplication</tt>, -which in turn is a directory with the single child <tt>"MyDialog"</tt>. That -directory asset has two children, <tt>"Title"</tt> and <tt>"Icon"</tt>, the first -being a data asset containing the string <tt>"My Dialog Title"</tt> and the second -being a data asset whose content will be read from the file -<tt>"MyDialogIcon.bmp"</tt> when this source snippet is compiled. - -A program references assets by using ZAsset objects. A ZAsset is a smart -pointer to an asset in a tree. ZAsset::GetChild takes a string (or const -char*) as a parameter and returns a ZAsset referencing that child. If no -such child exists a null ZAsset is returned for which -ZAsset::operator_bool_type() will return false, and for which all -other methods are no-ops. Accessing the example asset tree example would -look something like this: - -\code - ZAsset theRootAsset = SomeMagicMethodToObtainTheRoot(); - ZAsset theAppAsset = theRootAsset.GetChild("MyApplication"); - ZAsset theDialogAsset = theAppAsset.GetChild("MyDialog"); - ZAsset theTitleAsset = theDialogAsset.GetChild("Title"); - ZAsset theIconAsset = theDialogAsset.GetChild("Icon"); - ZAsset theAppAssetAgain = theDialogAsset.GetParent(); -\endcode - -ZAssets have value semantics, just like ZDCRgn, ZDCPixmap, \c std::string etc. -They can be passed by value into methods, stored in instance variables or -locals: - -\code - ZAsset myAsset = theAppAsset; -\endcode - -\c myAsset now references the asset named "MyApplication". After executing this: - -\code - theAppAsset = someOtherAsset; -\endcode - -\c myAsset \e still references the asset named "MyApplication". - -\note Currently there are no mutating operations on ZAssets nor on what -ZAsset references. They're effectively const pointers to nodes in the tree. - -Given a ZAsset one can get its name from ZAsset::GetName, and get the -path from the root to that asset from ZAsset::GetPath. Executing this -snippet: - -\code - string theTitlePath = theTitleAsset.GetPath(); -\endcode - -ZAsset::GetChild inteprets path strings as well as standalone names, -so we could have initialized \c theTitleAsset by doing this: - -\code - ZAsset theTitleAsset = theRootAsset.GetChild("MyApplication|MyDialog|Title"); -\endcode - -A path which \e begins with the pipe character starts resolving the path at -the root, regardless of which asset we're dealing with, so this would still -work: - -\code - ZAsset theTitleAsset = theIconAsset.GetChild("|MyApplication|MyDialog|Title"); -\endcode - -The hat character (^) indicates that resolution should bounce up to the -parent. You can use it anywhere in a path and it will work as expected, but -it's really only useful at the beginning of a path: - -\code - ZAsset theTitleAsset = theIconAsset.GetChild("^Title"); -\endcode - -You're unlikely to use hat in C++ code, because ZAsset::GetParent is -available. However it is useful in asset source code when using the so far -unmentioned third asset type, aliases. An alias occupies a place in the tree -like any other asset, but when methods are called on it, to get one of its -children for example, that request is passed on to the asset the alias -references. For example, augmenting our sample with some button titles: -\verbatim -name "MyApplication" - { - name "StandardButtons" - { - name "OK" string "OK" - name "Cancel" string "Cancel" - } - name "MyDialog" - { - name "Title" string "My Dialog Title" - name "Icon" binary "MyDialogIcon.bmp" - name "Cancel" alias "^^StandardButtons|Cancel" - } - } -\endverbatim - -Any request to <tt>"|MyApplication|MyDialog|Cancel"</tt> will actually be fielded by -<tt>"|MyApplication|StandardButtons|Cancel"</tt>. - -The neat thing about assets being organized hierarchically is that different -subsets of an application can be passed an asset that references 'their' -node in the tree, and they're not affected by changes to -the rest of the tree -- there's no need to worry about name clashes or -reorganization elsewhere. - - -<h3>Using asset data</h3> - -So we're able to navigate the tree. Big deal. What we really want is to get -at the data that the tree is organizing. Depending on how you want to use -the data there are two ways, ZAsset::OpenRPos and ZAsset::GetData. But -first I'll explain one hidden detail. A node defined in asset source code that -supposedly contains data, like the \c Title node above, does not in -fact \e directly contain the data. To provide for a limited degree of type -safety the following: -\verbatim - name "Title" string "My Dialog Title" -\endverbatim - -in fact creates a directory node called \c Title with a single child -called \c !string. \e That node is the one that actually contains the data in -question. For binaries the data-containing node is called \c !binary, and for -string tables (which I'm leaving out of this discussion for now) it's called -\c !stringtable. If I've explained things well enough, or you've read the parser's -source you'll recognize that the following snippet is legal, if obscure: -\verbatim - name "SomeName" string "Some string" binary "somebinary.bin" -\endverbatim - -It creates a node called \c SomeName, with two children. One called -\c !string containing the text <tt>"Some string"</tt> and one called \c !binary -containing the data from the file <tt>"somebinary.bin"</tt>. - -Back to getting at asset data. I'll start with ZAsset::OpenRPos, as it's a -little easier to understand. - -\warning There's a whole suite of \c ZAsset::OpenXXX methods, but as \c ZAssets -are currently immutable only ZAsset::OpenR and ZAsset::OpenRPos will return a -valid streamer. - -\c ZAsset::OpenXXX each return a newly created \link group_Streamer streamer\endlink -of the appropriate type. The streamer that's returned is yours to do with as you wish. -It's independent of any other streamer created ... [truncated message content] |
From: <ag...@us...> - 2009-07-19 17:34:33
|
Revision: 855 http://zoolib.svn.sourceforge.net/zoolib/?rev=855&view=rev Author: agreen Date: 2009-07-19 17:34:21 +0000 (Sun, 19 Jul 2009) Log Message: ----------- Move to cxx_old. Added Paths: ----------- trunk/zoolib/source/cxx_old/zoolib/ZDCRgn.cpp trunk/zoolib/source/cxx_old/zoolib/ZDCRgn.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZDCRgn.cpp trunk/zoolib/source/cxx/zoolib/ZDCRgn.h Deleted: trunk/zoolib/source/cxx/zoolib/ZDCRgn.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCRgn.cpp 2009-07-19 17:27:02 UTC (rev 854) +++ trunk/zoolib/source/cxx/zoolib/ZDCRgn.cpp 2009-07-19 17:34:21 UTC (rev 855) @@ -1,293 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2000 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZDCRgn.h" - -NAMESPACE_ZOOLIB_BEGIN - -using std::vector; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZDCRgn - -ZDCRgn ZDCRgn::sLine(ZCoord iStartH, ZCoord iStartV, - ZCoord iEndH, ZCoord iEndV, ZCoord iLineWidth) - { - ZUnimplemented(); - return ZDCRgn(); - } - -ZDCRgn ZDCRgn::sRects(const ZRect* iRects, size_t iCount, bool iAlreadySorted) - { - ZUnimplemented(); - return ZDCRgn(); - } - -ZDCRgn ZDCRgn::sRoundRect(const ZRect& iRect, const ZPoint& iCornerSize) - { - ZUnimplemented(); - return ZDCRgn(); - } - -ZDCRgn ZDCRgn::sRoundRect(ZCoord iLeft, ZCoord iTop, - ZCoord iRight, ZCoord iBottom, ZCoord iCornerSizeH, ZCoord iCornerSizeV) - { - ZUnimplemented(); - return ZDCRgn(); - } - -ZDCRgn ZDCRgn::sEllipse(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom) - { - ZUnimplemented(); - return ZDCRgn(); - } - -ZDCRgn ZDCRgn::sPoly(const ZDCPoly& iPoly, bool iEvenOdd, ZCoord iOffsetH, ZCoord iOffsetV) - { - ZUnimplemented(); - return ZDCRgn(); - } - -ZDCRgn ZDCRgn::sPoly(const ZPoint* iPoints, size_t iCount, bool iEvenOdd, - ZCoord iOffsetH, ZCoord iOffsetV) - { - ZUnimplemented(); - return ZDCRgn(); - } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZDCRgn - -ZDCRgn::operator operator_bool_type() const - { return operator_bool_generator_type::translate(fGRgn); } - -ZDCRgn::ZDCRgn() - {} - -ZDCRgn::ZDCRgn(const ZDCRgn& iOther) -: fGRgn(iOther.fGRgn) - {} - -ZDCRgn& ZDCRgn::operator=(const ZDCRgn& iOther) - { - fGRgn = iOther.fGRgn; - return *this; - } - -ZDCRgn::~ZDCRgn() - {} - -ZDCRgn::ZDCRgn(const ZGRgn& iGRgn) -: fGRgn(iGRgn) - {} - -ZDCRgn::ZDCRgn(const ZRect& iRect) -: fGRgn(iRect) - {} - -ZDCRgn::ZDCRgn(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom) -: fGRgn(iLeft, iTop, iRight, iBottom) - {} - -ZDCRgn& ZDCRgn::operator=(const ZRect& iRect) - { - fGRgn = iRect; - return *this; - } - -#if ZCONFIG_API_Enabled(GRgnRep_RgnHandle) -ZDCRgn::ZDCRgn(RgnHandle iRgnHandle, bool iAdopt) -: fGRgn(new ZGRgnRep_RgnHandle(iRgnHandle, iAdopt)) - {} - -ZDCRgn& ZDCRgn::operator=(RgnHandle iRgnHandle) - { - fGRgn = new ZGRgnRep_RgnHandle(iRgnHandle); - return *this; - } - -RgnHandle ZDCRgn::GetRgnHandle() - { - ZRef<ZGRgnRep_RgnHandle> theRep = ZGRgnRep_RgnHandle::sGetRep(fGRgn.GetRep()); - fGRgn = theRep; - return theRep->GetRgnHandle(); - } -#endif - -#if ZCONFIG_API_Enabled(GRgnRep_HRGN) -ZDCRgn::ZDCRgn(HRGN iHRGN, bool iAdopt) -: fGRgn(new ZGRgnRep_HRGN(iHRGN, iAdopt)) - {} - -ZDCRgn& ZDCRgn::operator=(HRGN iHRGN) - { - fGRgn = new ZGRgnRep_HRGN(iHRGN); - return *this; - } - -HRGN ZDCRgn::GetHRGN() - { - ZRef<ZGRgnRep_HRGN> theRep = ZGRgnRep_HRGN::sGetRep(fGRgn.GetRep()); - fGRgn = theRep; - return theRep->GetHRGN(); - } -#endif - -static bool sDecompose_IntoVector(const ZRect& iRect, void* iRefcon) - { - reinterpret_cast<vector<ZRect>*>(iRefcon)->push_back(iRect); - return false; - } - -void ZDCRgn::Decompose(vector<ZRect>& oRects) const - { - oRects.clear(); - this->Decompose(sDecompose_IntoVector, &oRects); - } - -size_t ZDCRgn::Decompose(DecomposeProc iProc, void* iRefcon) const - { return fGRgn.Decompose(iProc, iRefcon); } - -bool ZDCRgn::Contains(const ZPoint& iPoint) const - { return fGRgn.Contains(iPoint); } - -bool ZDCRgn::Contains(ZCoord iH, ZCoord iV) const - { return fGRgn.Contains(iH, iV); } - -void ZDCRgn::MakeOutline() - { fGRgn.Outline(); } - -ZDCRgn ZDCRgn::Outline() const - { return fGRgn.Outlined(); } - -ZDCRgn ZDCRgn::Inset(const ZPoint& iPoint) const - { return fGRgn.Insetted(iPoint); } - -ZDCRgn ZDCRgn::Inset(ZCoord iH, ZCoord iV) const - { return fGRgn.Insetted(iH, iV); } - -void ZDCRgn::MakeInset(const ZPoint& iPoint) - { fGRgn.Inset(iPoint); } - -void ZDCRgn::MakeInset(ZCoord iH, ZCoord iV) - { fGRgn.Inset(iH, iV); } - -void ZDCRgn::Clear() - { fGRgn.Clear(); } - -bool ZDCRgn::IsEmpty() const - { return fGRgn.IsEmpty(); } - -ZRect ZDCRgn::Bounds() const - { return fGRgn.Bounds(); } - -bool ZDCRgn::IsSimpleRect() const - { return fGRgn.IsSimpleRect(); } - -bool ZDCRgn::operator==(const ZDCRgn& iOther) const - { return fGRgn == iOther.fGRgn; } - -bool ZDCRgn::operator!=(const ZDCRgn& iOther) const - { return ! (*this == iOther); } - -ZDCRgn& ZDCRgn::operator+=(const ZPoint& iOffset) - { - fGRgn += iOffset; - return *this; - } - -ZDCRgn ZDCRgn::operator+(const ZPoint& iOffset) const - { return fGRgn + iOffset; } - -ZDCRgn& ZDCRgn::operator-=(const ZPoint& iOffset) - { - fGRgn -= iOffset; - return *this; - } - -ZDCRgn ZDCRgn::operator-(const ZPoint& iOffset) const - { return fGRgn - iOffset; } - -ZDCRgn& ZDCRgn::operator|=(const ZRect& iRect) - { - fGRgn |= iRect; - return *this; - } - -ZDCRgn ZDCRgn::operator|(const ZRect& iRect) const - { return fGRgn | iRect; } - -ZDCRgn& ZDCRgn::operator&=(const ZRect& iRect) - { - fGRgn &= iRect; - return *this; - } - -ZDCRgn ZDCRgn::operator&(const ZRect& iRect) const - { return fGRgn & iRect; } - -ZDCRgn& ZDCRgn::operator-=(const ZRect& iRect) - { - fGRgn -= iRect; - return *this; - } - -ZDCRgn ZDCRgn::operator-(const ZRect& iRect) const - { return fGRgn - iRect; } - -ZDCRgn& ZDCRgn::operator|=(const ZDCRgn& iOther) - { - fGRgn |= iOther.fGRgn; - return *this; - } - -ZDCRgn ZDCRgn::operator|(const ZDCRgn& iOther) const - { return fGRgn | iOther.fGRgn; } - -ZDCRgn& ZDCRgn::operator&=(const ZDCRgn& iOther) - { - fGRgn &= iOther.fGRgn; - return *this; - } - -ZDCRgn ZDCRgn::operator&(const ZDCRgn& iOther) const - { return fGRgn & iOther.fGRgn; } - -ZDCRgn& ZDCRgn::operator-=(const ZDCRgn& iOther) - { - fGRgn -= iOther.fGRgn; - return *this; - } - -ZDCRgn ZDCRgn::operator-(const ZDCRgn& iOther) const - { return fGRgn - iOther.fGRgn; } - -ZDCRgn& ZDCRgn::operator^=(const ZDCRgn& iOther) - { - fGRgn ^= iOther.fGRgn; - return *this; - } - -ZDCRgn ZDCRgn::operator^(const ZDCRgn& iOther) const - { return fGRgn ^ iOther.fGRgn; } - -NAMESPACE_ZOOLIB_END Deleted: trunk/zoolib/source/cxx/zoolib/ZDCRgn.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCRgn.h 2009-07-19 17:27:02 UTC (rev 854) +++ trunk/zoolib/source/cxx/zoolib/ZDCRgn.h 2009-07-19 17:34:21 UTC (rev 855) @@ -1,205 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2000 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZDCRgn__ -#define __ZDCRgn__ 1 -#include "zconfig.h" - -#include "zoolib/ZGRgn.h" -#include "zoolib/ZGRgnRep_HRGN.h" -#include "zoolib/ZGRgnRep_RgnHandle.h" -#include "zoolib/ZGRgnRep_XRegion.h" - -NAMESPACE_ZOOLIB_BEGIN - -class ZDCPoly; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZDCRgn - -class ZDCRgn - { -public: - static ZDCRgn sLine(ZCoord iStartH, ZCoord iStartV, - ZCoord iEndH, ZCoord iEndV, ZCoord iLineWidth); - - static ZDCRgn sLine(const ZPoint& iStart, const ZPoint& iEnd, ZCoord iLineWidth) - { return sLine(iStart.h, iStart.v, iEnd.h, iEnd.v, iLineWidth); } - -// Rect - static ZDCRgn sRect(const ZRect& iRect) - { return ZDCRgn(iRect); } - - static ZDCRgn sRect(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom) - { return ZDCRgn(iLeft, iTop, iRight, iBottom); } - - static ZDCRgn sRects(const ZRect* iRects, size_t iCount, bool iAlreadySorted); - -// Round rect - static ZDCRgn sRoundRect(const ZRect& iRect, const ZPoint& iCornerSize); - - static ZDCRgn sRoundRect(ZCoord iLeft, ZCoord iTop, - ZCoord iRight, ZCoord iBottom, ZCoord iCornerSizeH, ZCoord iCornerSizeV); - -// Ellipse - static ZDCRgn sEllipse(const ZRect& iBounds) - { return sEllipse(iBounds.left, iBounds.top, iBounds.right, iBounds.bottom); } - static ZDCRgn sEllipse(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom); - -// Polygon - static ZDCRgn sPoly(const ZDCPoly& iPoly, bool iEvenOdd, ZCoord iOffsetH, ZCoord iOffsetV); - - static ZDCRgn sPoly(const ZDCPoly& iPoly, ZCoord iOffsetH, ZCoord iOffsetV) - { return sPoly(iPoly, true, iOffsetH, iOffsetV); } - - static ZDCRgn sPoly(const ZDCPoly& iPoly, bool iEvenOdd) - { return sPoly(iPoly, iEvenOdd, 0, 0); } - - static ZDCRgn sPoly(const ZDCPoly& iPoly) - { return sPoly(iPoly, true, 0, 0); } - - static ZDCRgn sPoly(const ZPoint* iPoints, size_t iCount, bool iEvenOdd, - ZCoord iOffsetH, ZCoord iOffsetV); - - static ZDCRgn sPoly(const ZPoint* iPoints, size_t iCount, ZCoord iOffsetH, ZCoord iOffsetV) - { return sPoly(iPoints, iCount, true, iOffsetH, iOffsetV); } - - static ZDCRgn sPoly(const ZPoint* iPoints, size_t iCount, bool iEvenOdd) - { return sPoly(iPoints, iCount, iEvenOdd, 0, 0); } - - static ZDCRgn sPoly(const ZPoint* iPoints, size_t iCount) - { return sPoly(iPoints, iCount, true, 0, 0); } - - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZDCRgn, operator_bool_generator_type, operator_bool_type); - operator operator_bool_type() const; - - ZDCRgn(); - ZDCRgn(const ZDCRgn& iOther); - ZDCRgn& operator=(const ZDCRgn& iOther); - ~ZDCRgn(); - - ZDCRgn(const ZGRgn& iGRgn); - - ZDCRgn(const ZRect& iRect); - ZDCRgn(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom); - - ZDCRgn& operator=(const ZRect& iRect); - - #if ZCONFIG_API_Enabled(GRgnRep_RgnHandle) - ZDCRgn(RgnHandle iRgnHandle, bool iAdopt); - ZDCRgn& operator=(RgnHandle iRgnHandle); - RgnHandle GetRgnHandle(); - #endif - - #if ZCONFIG_API_Enabled(GRgnRep_HRGN) - ZDCRgn(HRGN iHRGN, bool iAdopt); - ZDCRgn& operator=(HRGN iHRGN); - HRGN GetHRGN(); - #endif - - #if ZCONFIG_API_Enabled(GRgnRep_XRegion) - ZDCRgn(Region iRegion, bool iAdopt); - ZDCRgn& operator=(Region iRegion); - Region GetRegion(); - #endif - - #if ZCONFIG_SPI_Enabled(GDI) - void MakeScale(float m11, float m12, float m21, float m22, float hOffset, float vOffset); - #endif - - void Decompose(std::vector<ZRect>& oRects) const; - typedef ZGRgnRep::DecomposeProc DecomposeProc; - size_t Decompose(DecomposeProc iProc, void* iRefcon) const; - - bool Contains(const ZPoint& iPoint) const; - bool Contains(ZCoord iH, ZCoord iV) const; - - void MakeOutline(); - ZDCRgn Outline() const; - - ZDCRgn Inset(const ZPoint& iPoint) const; - ZDCRgn Inset(ZCoord iH, ZCoord iV) const; - - void MakeInset(const ZPoint& iPoint); - void MakeInset(ZCoord iH, ZCoord iV); - - void Clear(); - bool IsEmpty() const; - - ZRect Bounds() const; - bool IsSimpleRect() const; - -// Equality - bool operator==(const ZDCRgn& iOther) const; - bool operator!=(const ZDCRgn& iOther) const; - -// Algebraic API - ZDCRgn& operator+=(const ZPoint& iOffset); - ZDCRgn operator+(const ZPoint& iOffset) const; - - ZDCRgn& operator-=(const ZPoint& iOffset); - ZDCRgn operator-(const ZPoint& iOffset) const; - -// Combining with rectangles - ZDCRgn& operator|=(const ZRect& iRect); - ZDCRgn operator|(const ZRect& iRect) const; - - ZDCRgn& operator&=(const ZRect& iRect); - ZDCRgn operator&(const ZRect& iRect) const; - - ZDCRgn& operator-=(const ZRect& iRect); - ZDCRgn operator-(const ZRect& iRect) const; - -// Combining with regions - ZDCRgn& operator|=(const ZDCRgn& iOther); - ZDCRgn operator|(const ZDCRgn& iOther) const; - - ZDCRgn& operator&=(const ZDCRgn& iOther); - ZDCRgn operator&(const ZDCRgn& iOther) const; - - ZDCRgn& operator-=(const ZDCRgn& iOther); - ZDCRgn operator-(const ZDCRgn& iOther) const; - - ZDCRgn& operator^=(const ZDCRgn& iOther); - ZDCRgn operator^(const ZDCRgn& iOther) const; - -private: - ZGRgn fGRgn; - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZDCRgnAccumulator - -class ZDCRgnUnioner_t - { -public: - void operator()(ZDCRgn& ioRgn, const ZDCRgn& iOther) const - { ioRgn |= iOther; } - }; - -typedef ZAccumulator_T<ZDCRgn, ZDCRgnUnioner_t, std::vector<ZDCRgn> > ZDCRgnAccumulator; - -// ================================================================================================= - -NAMESPACE_ZOOLIB_END - -#endif // __ZDCRgn__ Copied: trunk/zoolib/source/cxx_old/zoolib/ZDCRgn.cpp (from rev 745, trunk/zoolib/source/cxx/zoolib/ZDCRgn.cpp) =================================================================== --- trunk/zoolib/source/cxx_old/zoolib/ZDCRgn.cpp (rev 0) +++ trunk/zoolib/source/cxx_old/zoolib/ZDCRgn.cpp 2009-07-19 17:34:21 UTC (rev 855) @@ -0,0 +1,293 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2000 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZDCRgn.h" + +NAMESPACE_ZOOLIB_BEGIN + +using std::vector; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZDCRgn + +ZDCRgn ZDCRgn::sLine(ZCoord iStartH, ZCoord iStartV, + ZCoord iEndH, ZCoord iEndV, ZCoord iLineWidth) + { + ZUnimplemented(); + return ZDCRgn(); + } + +ZDCRgn ZDCRgn::sRects(const ZRect* iRects, size_t iCount, bool iAlreadySorted) + { + ZUnimplemented(); + return ZDCRgn(); + } + +ZDCRgn ZDCRgn::sRoundRect(const ZRect& iRect, const ZPoint& iCornerSize) + { + ZUnimplemented(); + return ZDCRgn(); + } + +ZDCRgn ZDCRgn::sRoundRect(ZCoord iLeft, ZCoord iTop, + ZCoord iRight, ZCoord iBottom, ZCoord iCornerSizeH, ZCoord iCornerSizeV) + { + ZUnimplemented(); + return ZDCRgn(); + } + +ZDCRgn ZDCRgn::sEllipse(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom) + { + ZUnimplemented(); + return ZDCRgn(); + } + +ZDCRgn ZDCRgn::sPoly(const ZDCPoly& iPoly, bool iEvenOdd, ZCoord iOffsetH, ZCoord iOffsetV) + { + ZUnimplemented(); + return ZDCRgn(); + } + +ZDCRgn ZDCRgn::sPoly(const ZPoint* iPoints, size_t iCount, bool iEvenOdd, + ZCoord iOffsetH, ZCoord iOffsetV) + { + ZUnimplemented(); + return ZDCRgn(); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZDCRgn + +ZDCRgn::operator operator_bool_type() const + { return operator_bool_generator_type::translate(fGRgn); } + +ZDCRgn::ZDCRgn() + {} + +ZDCRgn::ZDCRgn(const ZDCRgn& iOther) +: fGRgn(iOther.fGRgn) + {} + +ZDCRgn& ZDCRgn::operator=(const ZDCRgn& iOther) + { + fGRgn = iOther.fGRgn; + return *this; + } + +ZDCRgn::~ZDCRgn() + {} + +ZDCRgn::ZDCRgn(const ZGRgn& iGRgn) +: fGRgn(iGRgn) + {} + +ZDCRgn::ZDCRgn(const ZRect& iRect) +: fGRgn(iRect) + {} + +ZDCRgn::ZDCRgn(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom) +: fGRgn(iLeft, iTop, iRight, iBottom) + {} + +ZDCRgn& ZDCRgn::operator=(const ZRect& iRect) + { + fGRgn = iRect; + return *this; + } + +#if ZCONFIG_API_Enabled(GRgnRep_RgnHandle) +ZDCRgn::ZDCRgn(RgnHandle iRgnHandle, bool iAdopt) +: fGRgn(new ZGRgnRep_RgnHandle(iRgnHandle, iAdopt)) + {} + +ZDCRgn& ZDCRgn::operator=(RgnHandle iRgnHandle) + { + fGRgn = new ZGRgnRep_RgnHandle(iRgnHandle); + return *this; + } + +RgnHandle ZDCRgn::GetRgnHandle() + { + ZRef<ZGRgnRep_RgnHandle> theRep = ZGRgnRep_RgnHandle::sGetRep(fGRgn.GetRep()); + fGRgn = theRep; + return theRep->GetRgnHandle(); + } +#endif + +#if ZCONFIG_API_Enabled(GRgnRep_HRGN) +ZDCRgn::ZDCRgn(HRGN iHRGN, bool iAdopt) +: fGRgn(new ZGRgnRep_HRGN(iHRGN, iAdopt)) + {} + +ZDCRgn& ZDCRgn::operator=(HRGN iHRGN) + { + fGRgn = new ZGRgnRep_HRGN(iHRGN); + return *this; + } + +HRGN ZDCRgn::GetHRGN() + { + ZRef<ZGRgnRep_HRGN> theRep = ZGRgnRep_HRGN::sGetRep(fGRgn.GetRep()); + fGRgn = theRep; + return theRep->GetHRGN(); + } +#endif + +static bool sDecompose_IntoVector(const ZRect& iRect, void* iRefcon) + { + reinterpret_cast<vector<ZRect>*>(iRefcon)->push_back(iRect); + return false; + } + +void ZDCRgn::Decompose(vector<ZRect>& oRects) const + { + oRects.clear(); + this->Decompose(sDecompose_IntoVector, &oRects); + } + +size_t ZDCRgn::Decompose(DecomposeProc iProc, void* iRefcon) const + { return fGRgn.Decompose(iProc, iRefcon); } + +bool ZDCRgn::Contains(const ZPoint& iPoint) const + { return fGRgn.Contains(iPoint); } + +bool ZDCRgn::Contains(ZCoord iH, ZCoord iV) const + { return fGRgn.Contains(iH, iV); } + +void ZDCRgn::MakeOutline() + { fGRgn.Outline(); } + +ZDCRgn ZDCRgn::Outline() const + { return fGRgn.Outlined(); } + +ZDCRgn ZDCRgn::Inset(const ZPoint& iPoint) const + { return fGRgn.Insetted(iPoint); } + +ZDCRgn ZDCRgn::Inset(ZCoord iH, ZCoord iV) const + { return fGRgn.Insetted(iH, iV); } + +void ZDCRgn::MakeInset(const ZPoint& iPoint) + { fGRgn.Inset(iPoint); } + +void ZDCRgn::MakeInset(ZCoord iH, ZCoord iV) + { fGRgn.Inset(iH, iV); } + +void ZDCRgn::Clear() + { fGRgn.Clear(); } + +bool ZDCRgn::IsEmpty() const + { return fGRgn.IsEmpty(); } + +ZRect ZDCRgn::Bounds() const + { return fGRgn.Bounds(); } + +bool ZDCRgn::IsSimpleRect() const + { return fGRgn.IsSimpleRect(); } + +bool ZDCRgn::operator==(const ZDCRgn& iOther) const + { return fGRgn == iOther.fGRgn; } + +bool ZDCRgn::operator!=(const ZDCRgn& iOther) const + { return ! (*this == iOther); } + +ZDCRgn& ZDCRgn::operator+=(const ZPoint& iOffset) + { + fGRgn += iOffset; + return *this; + } + +ZDCRgn ZDCRgn::operator+(const ZPoint& iOffset) const + { return fGRgn + iOffset; } + +ZDCRgn& ZDCRgn::operator-=(const ZPoint& iOffset) + { + fGRgn -= iOffset; + return *this; + } + +ZDCRgn ZDCRgn::operator-(const ZPoint& iOffset) const + { return fGRgn - iOffset; } + +ZDCRgn& ZDCRgn::operator|=(const ZRect& iRect) + { + fGRgn |= iRect; + return *this; + } + +ZDCRgn ZDCRgn::operator|(const ZRect& iRect) const + { return fGRgn | iRect; } + +ZDCRgn& ZDCRgn::operator&=(const ZRect& iRect) + { + fGRgn &= iRect; + return *this; + } + +ZDCRgn ZDCRgn::operator&(const ZRect& iRect) const + { return fGRgn & iRect; } + +ZDCRgn& ZDCRgn::operator-=(const ZRect& iRect) + { + fGRgn -= iRect; + return *this; + } + +ZDCRgn ZDCRgn::operator-(const ZRect& iRect) const + { return fGRgn - iRect; } + +ZDCRgn& ZDCRgn::operator|=(const ZDCRgn& iOther) + { + fGRgn |= iOther.fGRgn; + return *this; + } + +ZDCRgn ZDCRgn::operator|(const ZDCRgn& iOther) const + { return fGRgn | iOther.fGRgn; } + +ZDCRgn& ZDCRgn::operator&=(const ZDCRgn& iOther) + { + fGRgn &= iOther.fGRgn; + return *this; + } + +ZDCRgn ZDCRgn::operator&(const ZDCRgn& iOther) const + { return fGRgn & iOther.fGRgn; } + +ZDCRgn& ZDCRgn::operator-=(const ZDCRgn& iOther) + { + fGRgn -= iOther.fGRgn; + return *this; + } + +ZDCRgn ZDCRgn::operator-(const ZDCRgn& iOther) const + { return fGRgn - iOther.fGRgn; } + +ZDCRgn& ZDCRgn::operator^=(const ZDCRgn& iOther) + { + fGRgn ^= iOther.fGRgn; + return *this; + } + +ZDCRgn ZDCRgn::operator^(const ZDCRgn& iOther) const + { return fGRgn ^ iOther.fGRgn; } + +NAMESPACE_ZOOLIB_END Copied: trunk/zoolib/source/cxx_old/zoolib/ZDCRgn.h (from rev 745, trunk/zoolib/source/cxx/zoolib/ZDCRgn.h) =================================================================== --- trunk/zoolib/source/cxx_old/zoolib/ZDCRgn.h (rev 0) +++ trunk/zoolib/source/cxx_old/zoolib/ZDCRgn.h 2009-07-19 17:34:21 UTC (rev 855) @@ -0,0 +1,205 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2000 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZDCRgn__ +#define __ZDCRgn__ 1 +#include "zconfig.h" + +#include "zoolib/ZGRgn.h" +#include "zoolib/ZGRgnRep_HRGN.h" +#include "zoolib/ZGRgnRep_RgnHandle.h" +#include "zoolib/ZGRgnRep_XRegion.h" + +NAMESPACE_ZOOLIB_BEGIN + +class ZDCPoly; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZDCRgn + +class ZDCRgn + { +public: + static ZDCRgn sLine(ZCoord iStartH, ZCoord iStartV, + ZCoord iEndH, ZCoord iEndV, ZCoord iLineWidth); + + static ZDCRgn sLine(const ZPoint& iStart, const ZPoint& iEnd, ZCoord iLineWidth) + { return sLine(iStart.h, iStart.v, iEnd.h, iEnd.v, iLineWidth); } + +// Rect + static ZDCRgn sRect(const ZRect& iRect) + { return ZDCRgn(iRect); } + + static ZDCRgn sRect(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom) + { return ZDCRgn(iLeft, iTop, iRight, iBottom); } + + static ZDCRgn sRects(const ZRect* iRects, size_t iCount, bool iAlreadySorted); + +// Round rect + static ZDCRgn sRoundRect(const ZRect& iRect, const ZPoint& iCornerSize); + + static ZDCRgn sRoundRect(ZCoord iLeft, ZCoord iTop, + ZCoord iRight, ZCoord iBottom, ZCoord iCornerSizeH, ZCoord iCornerSizeV); + +// Ellipse + static ZDCRgn sEllipse(const ZRect& iBounds) + { return sEllipse(iBounds.left, iBounds.top, iBounds.right, iBounds.bottom); } + static ZDCRgn sEllipse(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom); + +// Polygon + static ZDCRgn sPoly(const ZDCPoly& iPoly, bool iEvenOdd, ZCoord iOffsetH, ZCoord iOffsetV); + + static ZDCRgn sPoly(const ZDCPoly& iPoly, ZCoord iOffsetH, ZCoord iOffsetV) + { return sPoly(iPoly, true, iOffsetH, iOffsetV); } + + static ZDCRgn sPoly(const ZDCPoly& iPoly, bool iEvenOdd) + { return sPoly(iPoly, iEvenOdd, 0, 0); } + + static ZDCRgn sPoly(const ZDCPoly& iPoly) + { return sPoly(iPoly, true, 0, 0); } + + static ZDCRgn sPoly(const ZPoint* iPoints, size_t iCount, bool iEvenOdd, + ZCoord iOffsetH, ZCoord iOffsetV); + + static ZDCRgn sPoly(const ZPoint* iPoints, size_t iCount, ZCoord iOffsetH, ZCoord iOffsetV) + { return sPoly(iPoints, iCount, true, iOffsetH, iOffsetV); } + + static ZDCRgn sPoly(const ZPoint* iPoints, size_t iCount, bool iEvenOdd) + { return sPoly(iPoints, iCount, iEvenOdd, 0, 0); } + + static ZDCRgn sPoly(const ZPoint* iPoints, size_t iCount) + { return sPoly(iPoints, iCount, true, 0, 0); } + + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZDCRgn, operator_bool_generator_type, operator_bool_type); + operator operator_bool_type() const; + + ZDCRgn(); + ZDCRgn(const ZDCRgn& iOther); + ZDCRgn& operator=(const ZDCRgn& iOther); + ~ZDCRgn(); + + ZDCRgn(const ZGRgn& iGRgn); + + ZDCRgn(const ZRect& iRect); + ZDCRgn(ZCoord iLeft, ZCoord iTop, ZCoord iRight, ZCoord iBottom); + + ZDCRgn& operator=(const ZRect& iRect); + + #if ZCONFIG_API_Enabled(GRgnRep_RgnHandle) + ZDCRgn(RgnHandle iRgnHandle, bool iAdopt); + ZDCRgn& operator=(RgnHandle iRgnHandle); + RgnHandle GetRgnHandle(); + #endif + + #if ZCONFIG_API_Enabled(GRgnRep_HRGN) + ZDCRgn(HRGN iHRGN, bool iAdopt); + ZDCRgn& operator=(HRGN iHRGN); + HRGN GetHRGN(); + #endif + + #if ZCONFIG_API_Enabled(GRgnRep_XRegion) + ZDCRgn(Region iRegion, bool iAdopt); + ZDCRgn& operator=(Region iRegion); + Region GetRegion(); + #endif + + #if ZCONFIG_SPI_Enabled(GDI) + void MakeScale(float m11, float m12, float m21, float m22, float hOffset, float vOffset); + #endif + + void Decompose(std::vector<ZRect>& oRects) const; + typedef ZGRgnRep::DecomposeProc DecomposeProc; + size_t Decompose(DecomposeProc iProc, void* iRefcon) const; + + bool Contains(const ZPoint& iPoint) const; + bool Contains(ZCoord iH, ZCoord iV) const; + + void MakeOutline(); + ZDCRgn Outline() const; + + ZDCRgn Inset(const ZPoint& iPoint) const; + ZDCRgn Inset(ZCoord iH, ZCoord iV) const; + + void MakeInset(const ZPoint& iPoint); + void MakeInset(ZCoord iH, ZCoord iV); + + void Clear(); + bool IsEmpty() const; + + ZRect Bounds() const; + bool IsSimpleRect() const; + +// Equality + bool operator==(const ZDCRgn& iOther) const; + bool operator!=(const ZDCRgn& iOther) const; + +// Algebraic API + ZDCRgn& operator+=(const ZPoint& iOffset); + ZDCRgn operator+(const ZPoint& iOffset) const; + + ZDCRgn& operator-=(const ZPoint& iOffset); + ZDCRgn operator-(const ZPoint& iOffset) const; + +// Combining with rectangles + ZDCRgn& operator|=(const ZRect& iRect); + ZDCRgn operator|(const ZRect& iRect) const; + + ZDCRgn& operator&=(const ZRect& iRect); + ZDCRgn operator&(const ZRect& iRect) const; + + ZDCRgn& operator-=(const ZRect& iRect); + ZDCRgn operator-(const ZRect& iRect) const; + +// Combining with regions + ZDCRgn& operator|=(const ZDCRgn& iOther); + ZDCRgn operator|(const ZDCRgn& iOther) const; + + ZDCRgn& operator&=(const ZDCRgn& iOther); + ZDCRgn operator&(const ZDCRgn& iOther) const; + + ZDCRgn& operator-=(const ZDCRgn& iOther); + ZDCRgn operator-(const ZDCRgn& iOther) const; + + ZDCRgn& operator^=(const ZDCRgn& iOther); + ZDCRgn operator^(const ZDCRgn& iOther) const; + +private: + ZGRgn fGRgn; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZDCRgnAccumulator + +class ZDCRgnUnioner_t + { +public: + void operator()(ZDCRgn& ioRgn, const ZDCRgn& iOther) const + { ioRgn |= iOther; } + }; + +typedef ZAccumulator_T<ZDCRgn, ZDCRgnUnioner_t, std::vector<ZDCRgn> > ZDCRgnAccumulator; + +// ================================================================================================= + +NAMESPACE_ZOOLIB_END + +#endif // __ZDCRgn__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2009-10-08 11:37:21
|
Revision: 1008 http://zoolib.svn.sourceforge.net/zoolib/?rev=1008&view=rev Author: agreen Date: 2009-10-08 11:37:12 +0000 (Thu, 08 Oct 2009) Log Message: ----------- Move ZStream_JNI to old, and remove the config macro from ZCONFIG_SPI. Modified Paths: -------------- trunk/zoolib/source/cxx/zoolib/ZCONFIG_SPI.h Added Paths: ----------- trunk/zoolib/source/cxx/old/zoolib/ZStream_JNI.cpp trunk/zoolib/source/cxx/old/zoolib/ZStream_JNI.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZStream_JNI.cpp trunk/zoolib/source/cxx/zoolib/ZStream_JNI.h Copied: trunk/zoolib/source/cxx/old/zoolib/ZStream_JNI.cpp (from rev 1004, trunk/zoolib/source/cxx/zoolib/ZStream_JNI.cpp) =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZStream_JNI.cpp (rev 0) +++ trunk/zoolib/source/cxx/old/zoolib/ZStream_JNI.cpp 2009-10-08 11:37:12 UTC (rev 1008) @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2003 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZStream_JNI.h" + +#if ZCONFIG_SPI_Enabled(JNI) + +#include "zoolib/ZMemory.h" + +NAMESPACE_ZOOLIB_BEGIN + +// ================================================================================================= +#pragma mark - +#pragma mark * ZStreamR_JNI + +ZStreamR_JNI::ZStreamR_JNI(JNIEnv* iEnv, jobject iJavaStream) + { + fEnv = iEnv; + fJavaStream = iJavaStream; + } + +ZStreamR_JNI::~ZStreamR_JNI() + {} + +void ZStreamR_JNI::Imp_Read(void* iDest, size_t iCount, size_t* oCountRead) + { + if (oCountRead) + *oCountRead = 0; + + if (!fEnv || !fJavaStream) + return; + + jclass class_Stream = fEnv->GetObjectClass(fJavaStream); + if (!class_Stream) + return; + + jmethodID mid_read = fEnv->GetMethodID(class_Stream, "read", "([BII)I"); + if (!mid_read) + return; + + size_t theBufferSize = min(size_t(4096), iCount); + jbyteArray theBufferArray = fEnv->NewByteArray(theBufferSize); + + uint8* localDest = reinterpret_cast<uint8*>(iDest); + size_t countRemaining = iCount; + while (countRemaining > 0) + { + size_t countToRead = min(countRemaining, theBufferSize); + jint countRead = fEnv->CallIntMethod(fJavaStream, mid_read, theBufferArray, 0, countToRead); + if (countRead <= 0) + break; + jboolean isCopy; + jbyte* elems = static_cast<jbyte*>(fEnv->GetPrimitiveArrayCritical(theBufferArray, &isCopy)); + ZBlockCopy(elems, localDest, countRead); + fEnv->ReleasePrimitiveArrayCritical(theBufferArray, elems, JNI_ABORT); + localDest += countRead; + countRemaining -= countRead; + if (oCountRead) + *oCountRead += countRead; + } + fEnv->DeleteLocalRef(theBufferArray); + } + +size_t ZStreamR_JNI::Imp_CountReadable() + { + if (jclass class_Stream = fEnv->GetObjectClass(fJavaStream)) + { + if (jmethodID mid_available = fEnv->GetMethodID(class_Stream, "available", "()I")) + return fEnv->CallIntMethod(fJavaStream, mid_available); + } + return 0; + } + +NAMESPACE_ZOOLIB_END + +#endif // ZCONFIG_SPI_Enabled(JNI) Copied: trunk/zoolib/source/cxx/old/zoolib/ZStream_JNI.h (from rev 1004, trunk/zoolib/source/cxx/zoolib/ZStream_JNI.h) =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZStream_JNI.h (rev 0) +++ trunk/zoolib/source/cxx/old/zoolib/ZStream_JNI.h 2009-10-08 11:37:12 UTC (rev 1008) @@ -0,0 +1,58 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2003 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZStream_JNI__ +#define __ZStream_JNI__ 1 +#include "zoolib/ZCONFIG_SPI.h" + +#include "zoolib/ZStream.h" + +#if ZCONFIG_SPI_Enabled(JNI) + +#include <jni.h> + +NAMESPACE_ZOOLIB_BEGIN + +// ================================================================================================= +#pragma mark - +#pragma mark * ZStreamR_JNI + +/// A read stream that sources data from a java.io.InputStream. + +class ZStreamR_JNI : public ZStreamR + { +public: + ZStreamR_JNI(JNIEnv* iEnv, jobject iJavaStream); + ~ZStreamR_JNI(); + +// From ZStreamR + virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead); + virtual size_t Imp_CountReadable(); + +private: + jobject fJavaStream; + JNIEnv* fEnv; + }; + +NAMESPACE_ZOOLIB_END + +#endif // ZCONFIG_SPI_Enabled(JNI) + +#endif // __ZStream_JNI__ Modified: trunk/zoolib/source/cxx/zoolib/ZCONFIG_SPI.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZCONFIG_SPI.h 2009-10-08 11:36:10 UTC (rev 1007) +++ trunk/zoolib/source/cxx/zoolib/ZCONFIG_SPI.h 2009-10-08 11:37:12 UTC (rev 1008) @@ -311,17 +311,6 @@ // ================================================================================================= -#pragma mark JNI -#ifndef ZCONFIG_SPI_Avail__JNI -# define ZCONFIG_SPI_Avail__JNI 0 -#endif - -#ifndef ZCONFIG_SPI_Desired__JNI -# define ZCONFIG_SPI_Desired__JNI 1 -#endif - - -// ================================================================================================= #pragma mark libpng #ifndef ZCONFIG_SPI_Avail__libpng # define ZCONFIG_SPI_Avail__libpng 0 Deleted: trunk/zoolib/source/cxx/zoolib/ZStream_JNI.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStream_JNI.cpp 2009-10-08 11:36:10 UTC (rev 1007) +++ trunk/zoolib/source/cxx/zoolib/ZStream_JNI.cpp 2009-10-08 11:37:12 UTC (rev 1008) @@ -1,93 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2003 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZStream_JNI.h" - -#if ZCONFIG_SPI_Enabled(JNI) - -#include "zoolib/ZMemory.h" - -NAMESPACE_ZOOLIB_BEGIN - -// ================================================================================================= -#pragma mark - -#pragma mark * ZStreamR_JNI - -ZStreamR_JNI::ZStreamR_JNI(JNIEnv* iEnv, jobject iJavaStream) - { - fEnv = iEnv; - fJavaStream = iJavaStream; - } - -ZStreamR_JNI::~ZStreamR_JNI() - {} - -void ZStreamR_JNI::Imp_Read(void* iDest, size_t iCount, size_t* oCountRead) - { - if (oCountRead) - *oCountRead = 0; - - if (!fEnv || !fJavaStream) - return; - - jclass class_Stream = fEnv->GetObjectClass(fJavaStream); - if (!class_Stream) - return; - - jmethodID mid_read = fEnv->GetMethodID(class_Stream, "read", "([BII)I"); - if (!mid_read) - return; - - size_t theBufferSize = min(size_t(4096), iCount); - jbyteArray theBufferArray = fEnv->NewByteArray(theBufferSize); - - uint8* localDest = reinterpret_cast<uint8*>(iDest); - size_t countRemaining = iCount; - while (countRemaining > 0) - { - size_t countToRead = min(countRemaining, theBufferSize); - jint countRead = fEnv->CallIntMethod(fJavaStream, mid_read, theBufferArray, 0, countToRead); - if (countRead <= 0) - break; - jboolean isCopy; - jbyte* elems = static_cast<jbyte*>(fEnv->GetPrimitiveArrayCritical(theBufferArray, &isCopy)); - ZBlockCopy(elems, localDest, countRead); - fEnv->ReleasePrimitiveArrayCritical(theBufferArray, elems, JNI_ABORT); - localDest += countRead; - countRemaining -= countRead; - if (oCountRead) - *oCountRead += countRead; - } - fEnv->DeleteLocalRef(theBufferArray); - } - -size_t ZStreamR_JNI::Imp_CountReadable() - { - if (jclass class_Stream = fEnv->GetObjectClass(fJavaStream)) - { - if (jmethodID mid_available = fEnv->GetMethodID(class_Stream, "available", "()I")) - return fEnv->CallIntMethod(fJavaStream, mid_available); - } - return 0; - } - -NAMESPACE_ZOOLIB_END - -#endif // ZCONFIG_SPI_Enabled(JNI) Deleted: trunk/zoolib/source/cxx/zoolib/ZStream_JNI.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStream_JNI.h 2009-10-08 11:36:10 UTC (rev 1007) +++ trunk/zoolib/source/cxx/zoolib/ZStream_JNI.h 2009-10-08 11:37:12 UTC (rev 1008) @@ -1,58 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2003 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZStream_JNI__ -#define __ZStream_JNI__ 1 -#include "zoolib/ZCONFIG_SPI.h" - -#include "zoolib/ZStream.h" - -#if ZCONFIG_SPI_Enabled(JNI) - -#include <jni.h> - -NAMESPACE_ZOOLIB_BEGIN - -// ================================================================================================= -#pragma mark - -#pragma mark * ZStreamR_JNI - -/// A read stream that sources data from a java.io.InputStream. - -class ZStreamR_JNI : public ZStreamR - { -public: - ZStreamR_JNI(JNIEnv* iEnv, jobject iJavaStream); - ~ZStreamR_JNI(); - -// From ZStreamR - virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead); - virtual size_t Imp_CountReadable(); - -private: - jobject fJavaStream; - JNIEnv* fEnv; - }; - -NAMESPACE_ZOOLIB_END - -#endif // ZCONFIG_SPI_Enabled(JNI) - -#endif // __ZStream_JNI__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2010-01-19 04:18:55
|
Revision: 1101 http://zoolib.svn.sourceforge.net/zoolib/?rev=1101&view=rev Author: agreen Date: 2010-01-15 04:06:52 +0000 (Fri, 15 Jan 2010) Log Message: ----------- Move some files to old. Modify Map and List implementations to return a ref to this from mutating methods, so changes can be chained. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h trunk/zoolib/source/cxx/zoolib/ZRef_WinHANDLE.cpp trunk/zoolib/source/cxx/zoolib/ZTuple.cpp trunk/zoolib/source/cxx/zoolib/ZTuple.h trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Data.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Geom.h trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp trunk/zoolib/source/cxx/zoolib/ZVal_Any.h trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h trunk/zoolib/source/cxx/zoolib/ZVal_CFType.cpp trunk/zoolib/source/cxx/zoolib/ZVal_CFType.h trunk/zoolib/source/cxx/zoolib/ZVal_NS.h trunk/zoolib/source/cxx/zoolib/ZVal_NS.mm trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.h trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Val.h trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Yad.h trunk/zoolib/source/cxx/zoolib/ZYad_CFType.cpp trunk/zoolib/source/cxx/zoolib/ZYad_CFType.h Added Paths: ----------- trunk/zoolib/source/cxx/old/zoolib/ZDCPixmapCombo.cpp trunk/zoolib/source/cxx/old/zoolib/ZDCPixmapCombo.h trunk/zoolib/source/cxx/old/zoolib/ZProgressWatcher.cpp trunk/zoolib/source/cxx/old/zoolib/ZProgressWatcher.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.cpp trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.h trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.cpp trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.h Modified: trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -265,35 +265,34 @@ if (false) \ {} \ else if (const int32* theVal = iVal.PGet_T<int32>()) \ - { SUITE->PutInteger(PARAM, *theVal); return; } \ + { SUITE->PutInteger(PARAM, *theVal); } \ else if (const float* theVal = iVal.PGet_T<float>()) \ - { SUITE->PutFloat(PARAM, *theVal); return; } \ + { SUITE->PutFloat(PARAM, *theVal); } \ else if (const UnitFloat* theVal = iVal.PGet_T<UnitFloat>()) \ - { SUITE->PutUnitFloat(PARAM, theVal->fUnitID, theVal->fValue); return; } \ + { SUITE->PutUnitFloat(PARAM, theVal->fUnitID, theVal->fValue); } \ else if (const string8* theVal = iVal.PGet_T<string8>()) \ - { SUITE->PutString(PARAM, const_cast<char*>(theVal->c_str())); return; } \ + { SUITE->PutString(PARAM, const_cast<char*>(theVal->c_str())); } \ else if (const bool* theVal = iVal.PGet_T<bool>()) \ - { SUITE->PutBoolean(PARAM, *theVal); return; } \ + { SUITE->PutBoolean(PARAM, *theVal); } \ else if (const List* theVal = iVal.PGet_T<List>()) \ - { SUITE->PutList(PARAM, theVal->IParam()); return; } \ + { SUITE->PutList(PARAM, theVal->IParam()); } \ else if (const Map* theVal = iVal.PGet_T<Map>()) \ - { SUITE->PutObject(PARAM, theVal->GetType(), theVal->IParam()); return; } \ + { SUITE->PutObject(PARAM, theVal->GetType(), theVal->IParam()); } \ /* global object? */ \ else if (const Enumerated* theVal = iVal.PGet_T<Enumerated>()) \ - { SUITE->PutEnumerated(PARAM, theVal->fEnumType, theVal->fValue); return; } \ + { SUITE->PutEnumerated(PARAM, theVal->fEnumType, theVal->fValue); } \ else if (const Spec* theVal = iVal.PGet_T<Spec>()) \ { \ PIActionReference tempRef = theVal->MakeRef(); \ SUITE->PutReference(PARAM, tempRef); \ spPSActionReference->Free(tempRef); \ - return; \ } \ /*Hmmm else if (const ClassID* theVal = iVal.PGet_T<ClassID>()) \ - { ZUnimplemented(); } Hmm??? SUITE->PutInteger(PARAM, *theVal); return; } */\ + { ZUnimplemented(); } Hmm??? SUITE->PutInteger(PARAM, *theVal); } */\ else if (const FileRef* theVal = iVal.PGet_T<FileRef>()) \ - { SUITE->PutAlias(PARAM, theVal->Get()); return; } \ + { SUITE->PutAlias(PARAM, theVal->Get()); } \ else if (const Data* theVal = iVal.PGet_T<Data>()) \ - { SUITE->PutData(PARAM, theVal->GetSize(), const_cast<void*>(theVal->GetData())); return; } + { SUITE->PutData(PARAM, theVal->GetSize(), const_cast<void*>(theVal->GetData())); } // ================================================================================================= #pragma mark - @@ -1186,9 +1185,10 @@ Val List::Get(size_t iIndex) const { return this->DGet(Val(), iIndex); } -void List::Append(const Val& iVal) +List& List::Append(const Val& iVal) { SETTERCASES(spPSActionList, fAL) + return *this; } PIActionList& List::OParam() @@ -1346,29 +1346,46 @@ Val Map::Get(Index_t iIndex) const { return this->DGet(Val(), iIndex); } -void Map::Set(KeyID iKey, const Val& iVal) +Map& Map::Set(KeyID iKey, const Val& iVal) { #define COMMA() , SETTERCASES(spPSActionDescriptor, fAD COMMA() iKey) #undef COMMA + + return *this; } -void Map::Set(const string8& iName, const Val& iVal) - { this->Set(spAsKeyID(iName), iVal); } +Map& Map::Set(const string8& iName, const Val& iVal) + { + this->Set(spAsKeyID(iName), iVal); + return *this; + } -void Map::Set(Index_t iIndex, const Val& iVal) - { this->Set(this->KeyOf(iIndex), iVal); } +Map& Map::Set(Index_t iIndex, const Val& iVal) + { + this->Set(this->KeyOf(iIndex), iVal); + return *this; + } -void Map::Erase(KeyID iKey) - { spPSActionDescriptor->Erase(fAD, iKey); } +Map& Map::Erase(KeyID iKey) + { + spPSActionDescriptor->Erase(fAD, iKey); + return *this; + } -void Map::Erase(const string8& iName) - { this->Erase(spAsKeyID(iName)); } +Map& Map::Erase(const string8& iName) + { + this->Erase(spAsKeyID(iName)); + return *this; + } -void Map::Erase(Index_t iIndex) - { this->Erase(this->KeyOf(iIndex)); } +Map& Map::Erase(Index_t iIndex) + { + this->Erase(this->KeyOf(iIndex)); + return *this; + } PIActionDescriptor& Map::OParam() { Modified: trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -300,7 +300,7 @@ Val DGet(const Val& iDefault, size_t iIndex) const; Val Get(size_t iIndex) const; - void Append(const Val& iVal); + List& Append(const Val& iVal); // Our protocol PIActionList& OParam(); @@ -359,13 +359,13 @@ Val Get(const string8& iName) const; Val Get(Index_t iIndex) const; - void Set(KeyID iKey, const Val& iVal); - void Set(const string8& iName, const Val& iVal); - void Set(Index_t iIndex, const Val& iVal); + Map& Set(KeyID iKey, const Val& iVal); + Map& Set(const string8& iName, const Val& iVal); + Map& Set(Index_t iIndex, const Val& iVal); - void Erase(KeyID iKey); - void Erase(const string8& iName); - void Erase(Index_t iIndex); + Map& Erase(KeyID iKey); + Map& Erase(const string8& iName); + Map& Erase(Index_t iIndex); // Our protocol PIActionDescriptor& OParam(); Copied: trunk/zoolib/source/cxx/old/zoolib/ZDCPixmapCombo.cpp (from rev 1029, trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.cpp) =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZDCPixmapCombo.cpp (rev 0) +++ trunk/zoolib/source/cxx/old/zoolib/ZDCPixmapCombo.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -0,0 +1,110 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2008 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZDCPixmapCombo.h" + +NAMESPACE_ZOOLIB_BEGIN + +// ================================================================================================= +#pragma mark - +#pragma mark * ZDCPixmapCombo + +ZDCPixmapCombo::ZDCPixmapCombo() + {} + +ZDCPixmapCombo::ZDCPixmapCombo(const ZDCPixmap& iColorPixmap, + const ZDCPixmap& iMonoPixmap, + const ZDCPixmap& iMaskPixmap) +: fColorPixmap(iColorPixmap), + fMonoPixmap(iMonoPixmap), + fMaskPixmap(iMaskPixmap) + {} + +ZDCPixmapCombo::ZDCPixmapCombo(const ZDCPixmap& iMainPixmap, const ZDCPixmap& iMaskPixmap) +: fColorPixmap(iMainPixmap), + fMaskPixmap(iMaskPixmap) + {} + +ZDCPixmapCombo& ZDCPixmapCombo::operator=(const ZDCPixmapCombo& iOther) + { + fColorPixmap = iOther.fColorPixmap; + fMonoPixmap = iOther.fMonoPixmap; + fMaskPixmap = iOther.fMaskPixmap; + return *this; + } + +bool ZDCPixmapCombo::operator==(const ZDCPixmapCombo& iOther) const + { + return fColorPixmap == iOther.fColorPixmap + && fMonoPixmap == iOther.fMonoPixmap + && fMaskPixmap == iOther.fMaskPixmap; + } + +void ZDCPixmapCombo::SetPixmaps(const ZDCPixmap& iColorPixmap, + const ZDCPixmap& iMonoPixmap, + const ZDCPixmap& iMaskPixmap) + { + fColorPixmap = iColorPixmap; + fMonoPixmap = iMonoPixmap; + fMaskPixmap = iMaskPixmap; + } + +void ZDCPixmapCombo::SetPixmaps(const ZDCPixmap& iMainPixmap, const ZDCPixmap& iMaskPixmap) + { + fColorPixmap = iMainPixmap; + fMonoPixmap = ZDCPixmap(); + fMaskPixmap = iMaskPixmap; + } + +void ZDCPixmapCombo::GetPixmaps(ZDCPixmap& oColorPixmap, + ZDCPixmap& oMonoPixmap, + ZDCPixmap& oMaskPixmap) const + { + oColorPixmap = fColorPixmap; + oMonoPixmap = fMonoPixmap; + oMaskPixmap = fMaskPixmap; + } + +ZPoint ZDCPixmapCombo::Size() const + { + using std::max; + + ZPoint theSize = ZPoint::sZero; + ZPoint tempSize = fColorPixmap.Size(); + theSize.h = max(theSize.h, tempSize.h); + theSize.v = max(theSize.v, tempSize.v); + + tempSize = fMonoPixmap.Size(); + theSize.h = max(theSize.h, tempSize.h); + theSize.v = max(theSize.v, tempSize.v); + + tempSize = fMaskPixmap.Size(); + theSize.h = max(theSize.h, tempSize.h); + theSize.v = max(theSize.v, tempSize.v); + + return theSize; + } + +ZDCPixmapCombo::operator operator_bool_type() const + { return operator_bool_generator_type::translate(fColorPixmap || fMonoPixmap); } + +// ================================================================================================= + +NAMESPACE_ZOOLIB_END Copied: trunk/zoolib/source/cxx/old/zoolib/ZDCPixmapCombo.h (from rev 1029, trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.h) =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZDCPixmapCombo.h (rev 0) +++ trunk/zoolib/source/cxx/old/zoolib/ZDCPixmapCombo.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2008 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZDCPixmapCombo__ +#define __ZDCPixmapCombo__ 1 +#include "zconfig.h" + +#include "zoolib/ZDCPixmap.h" + +NAMESPACE_ZOOLIB_BEGIN + +// ================================================================================================= +#pragma mark - +#pragma mark * ZDCPixmapCombo + +class ZDCPixmapCombo + { + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZDCPixmapCombo, + operator_bool_generator_type, operator_bool_type); + +public: + ZDCPixmapCombo(); + + ZDCPixmapCombo(const ZDCPixmap& iColorPixmap, + const ZDCPixmap& iMonoPixmap, + const ZDCPixmap& iMaskPixmap); + + ZDCPixmapCombo(const ZDCPixmap& iMainPixmap, const ZDCPixmap& iMaskPixmap); + + ZDCPixmapCombo& operator=(const ZDCPixmapCombo& iOther); + + bool operator==(const ZDCPixmapCombo& other) const; + bool operator!=(const ZDCPixmapCombo& other) const + { return ! (*this == other); } + + void SetPixmaps(const ZDCPixmap& iColorPixmap, + const ZDCPixmap& iMonoPixmap, + const ZDCPixmap& iMaskPixmap); + + void SetPixmaps(const ZDCPixmap& iMainPixmap, const ZDCPixmap& iMaskPixmap); + + void GetPixmaps(ZDCPixmap& oColorPixmap, ZDCPixmap& oMonoPixmap, ZDCPixmap& oMaskPixmap) const; + + void SetColor(const ZDCPixmap& iPixmap) { fColorPixmap = iPixmap; } + const ZDCPixmap& GetColor() const { return fColorPixmap; } + + void SetMono(const ZDCPixmap& iPixmap) { fMonoPixmap = iPixmap; } + const ZDCPixmap& GetMono() const { return fMonoPixmap; } + + void SetMask(const ZDCPixmap& iPixmap) { fMaskPixmap = iPixmap; } + const ZDCPixmap& GetMask() const { return fMaskPixmap; } + + ZPoint Size() const; + +// Are we valid, i.e. do we have any pixels at all? + operator operator_bool_type() const; + +protected: + ZDCPixmap fColorPixmap; + ZDCPixmap fMonoPixmap; + ZDCPixmap fMaskPixmap; + }; + +// ================================================================================================= + +NAMESPACE_ZOOLIB_END + +#endif // __ZDCPixmapCombo__ Copied: trunk/zoolib/source/cxx/old/zoolib/ZProgressWatcher.cpp (from rev 1029, trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.cpp) =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZProgressWatcher.cpp (rev 0) +++ trunk/zoolib/source/cxx/old/zoolib/ZProgressWatcher.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -0,0 +1,104 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2001 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZProgressWatcher.h" +#include "zoolib/ZDebug.h" + +NAMESPACE_ZOOLIB_BEGIN + +using std::string; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZProgressPusher + +ZProgressPusher::ZProgressPusher( + ZProgressWatcher* iProgressWatcher, const string& iDescription, int32 iMax) + { + fWatcher = iProgressWatcher; + fPushes = 1; + if (fWatcher) + fWatcher->Push(iDescription, iMax); + } + +ZProgressPusher::ZProgressPusher(ZProgressWatcher* iProgressWatcher, int32 iMax) + { + fWatcher = iProgressWatcher; + fPushes = 1; + if (fWatcher) + fWatcher->Push(string(), iMax); + } + +ZProgressPusher::ZProgressPusher( + ZProgressPusher& iOtherPusher, const string& iDescription, int32 iMax) + { + fWatcher = iOtherPusher.fWatcher; + fPushes = 1; + if (fWatcher) + fWatcher->Push(iDescription, iMax); + } + +ZProgressPusher::ZProgressPusher(ZProgressPusher& iOtherPusher, int32 iMax) + { + fWatcher = iOtherPusher.fWatcher; + fPushes = 1; + if (fWatcher) + fWatcher->Push(string(), iMax); + } + +ZProgressPusher::~ZProgressPusher() + { + if (fWatcher) + { + while (fPushes--) + fWatcher->Pop(); + } + } + +void ZProgressPusher::Push(const string& iDescription, int32 iMax) + { + ++fPushes; + if (fWatcher) + fWatcher->Push(iDescription, iMax); + } + +void ZProgressPusher::Push(int32 iMax) + { + ++fPushes; + if (fWatcher) + fWatcher->Push(string(), iMax); + } + +void ZProgressPusher::Process(int32 iDelta) + { + if (fWatcher) + fWatcher->Process(iDelta); + } + +void ZProgressPusher::Pop() + { + ZAssertStop(2, fPushes > 0); + --fPushes; + + if (fWatcher) + fWatcher->Pop(); + } + +NAMESPACE_ZOOLIB_END Copied: trunk/zoolib/source/cxx/old/zoolib/ZProgressWatcher.h (from rev 1029, trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.h) =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZProgressWatcher.h (rev 0) +++ trunk/zoolib/source/cxx/old/zoolib/ZProgressWatcher.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -0,0 +1,73 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2001 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZProgressWatcher__ +#define __ZProgressWatcher__ 1 + +#include "zconfig.h" +#include "zoolib/ZTypes.h" +#include <string> + +NAMESPACE_ZOOLIB_BEGIN + +// ================================================================================================= +#pragma mark - +#pragma mark * ZProgressWatcher + +class ZProgressWatcher + { +protected: + ZProgressWatcher() {} + ~ZProgressWatcher() {} + +public: + virtual void Push(const std::string& iDescription, int32 iMax) = 0; + virtual void Process(int32 iDelta) = 0; + virtual void Pop() = 0; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZProgressPusher + +class ZProgressPusher + { +public: + ZProgressPusher(ZProgressWatcher* iProgressWatcher, const std::string& iDescription, int32 iMax); + ZProgressPusher(ZProgressWatcher* iProgressWatcher, int32 iMax); + + ZProgressPusher(ZProgressPusher& iOtherPusher, const std::string& iDescription, int32 iMax); + ZProgressPusher(ZProgressPusher& iOtherPusher, int32 iMax); + + ~ZProgressPusher(); + + void Push(const std::string& iDescription, int32 iMax); + void Push(int32 iMax); + void Process(int32 iDelta); + void Pop(); + +private: + ZProgressWatcher* fWatcher; + size_t fPushes; + }; + +NAMESPACE_ZOOLIB_END + +#endif // __ZProgressWatcher__ Deleted: trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.cpp 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -1,110 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2008 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZDCPixmapCombo.h" - -NAMESPACE_ZOOLIB_BEGIN - -// ================================================================================================= -#pragma mark - -#pragma mark * ZDCPixmapCombo - -ZDCPixmapCombo::ZDCPixmapCombo() - {} - -ZDCPixmapCombo::ZDCPixmapCombo(const ZDCPixmap& iColorPixmap, - const ZDCPixmap& iMonoPixmap, - const ZDCPixmap& iMaskPixmap) -: fColorPixmap(iColorPixmap), - fMonoPixmap(iMonoPixmap), - fMaskPixmap(iMaskPixmap) - {} - -ZDCPixmapCombo::ZDCPixmapCombo(const ZDCPixmap& iMainPixmap, const ZDCPixmap& iMaskPixmap) -: fColorPixmap(iMainPixmap), - fMaskPixmap(iMaskPixmap) - {} - -ZDCPixmapCombo& ZDCPixmapCombo::operator=(const ZDCPixmapCombo& iOther) - { - fColorPixmap = iOther.fColorPixmap; - fMonoPixmap = iOther.fMonoPixmap; - fMaskPixmap = iOther.fMaskPixmap; - return *this; - } - -bool ZDCPixmapCombo::operator==(const ZDCPixmapCombo& iOther) const - { - return fColorPixmap == iOther.fColorPixmap - && fMonoPixmap == iOther.fMonoPixmap - && fMaskPixmap == iOther.fMaskPixmap; - } - -void ZDCPixmapCombo::SetPixmaps(const ZDCPixmap& iColorPixmap, - const ZDCPixmap& iMonoPixmap, - const ZDCPixmap& iMaskPixmap) - { - fColorPixmap = iColorPixmap; - fMonoPixmap = iMonoPixmap; - fMaskPixmap = iMaskPixmap; - } - -void ZDCPixmapCombo::SetPixmaps(const ZDCPixmap& iMainPixmap, const ZDCPixmap& iMaskPixmap) - { - fColorPixmap = iMainPixmap; - fMonoPixmap = ZDCPixmap(); - fMaskPixmap = iMaskPixmap; - } - -void ZDCPixmapCombo::GetPixmaps(ZDCPixmap& oColorPixmap, - ZDCPixmap& oMonoPixmap, - ZDCPixmap& oMaskPixmap) const - { - oColorPixmap = fColorPixmap; - oMonoPixmap = fMonoPixmap; - oMaskPixmap = fMaskPixmap; - } - -ZPoint ZDCPixmapCombo::Size() const - { - using std::max; - - ZPoint theSize = ZPoint::sZero; - ZPoint tempSize = fColorPixmap.Size(); - theSize.h = max(theSize.h, tempSize.h); - theSize.v = max(theSize.v, tempSize.v); - - tempSize = fMonoPixmap.Size(); - theSize.h = max(theSize.h, tempSize.h); - theSize.v = max(theSize.v, tempSize.v); - - tempSize = fMaskPixmap.Size(); - theSize.h = max(theSize.h, tempSize.h); - theSize.v = max(theSize.v, tempSize.v); - - return theSize; - } - -ZDCPixmapCombo::operator operator_bool_type() const - { return operator_bool_generator_type::translate(fColorPixmap || fMonoPixmap); } - -// ================================================================================================= - -NAMESPACE_ZOOLIB_END Deleted: trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.h 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZDCPixmapCombo.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -1,85 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2008 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZDCPixmapCombo__ -#define __ZDCPixmapCombo__ 1 -#include "zconfig.h" - -#include "zoolib/ZDCPixmap.h" - -NAMESPACE_ZOOLIB_BEGIN - -// ================================================================================================= -#pragma mark - -#pragma mark * ZDCPixmapCombo - -class ZDCPixmapCombo - { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZDCPixmapCombo, - operator_bool_generator_type, operator_bool_type); - -public: - ZDCPixmapCombo(); - - ZDCPixmapCombo(const ZDCPixmap& iColorPixmap, - const ZDCPixmap& iMonoPixmap, - const ZDCPixmap& iMaskPixmap); - - ZDCPixmapCombo(const ZDCPixmap& iMainPixmap, const ZDCPixmap& iMaskPixmap); - - ZDCPixmapCombo& operator=(const ZDCPixmapCombo& iOther); - - bool operator==(const ZDCPixmapCombo& other) const; - bool operator!=(const ZDCPixmapCombo& other) const - { return ! (*this == other); } - - void SetPixmaps(const ZDCPixmap& iColorPixmap, - const ZDCPixmap& iMonoPixmap, - const ZDCPixmap& iMaskPixmap); - - void SetPixmaps(const ZDCPixmap& iMainPixmap, const ZDCPixmap& iMaskPixmap); - - void GetPixmaps(ZDCPixmap& oColorPixmap, ZDCPixmap& oMonoPixmap, ZDCPixmap& oMaskPixmap) const; - - void SetColor(const ZDCPixmap& iPixmap) { fColorPixmap = iPixmap; } - const ZDCPixmap& GetColor() const { return fColorPixmap; } - - void SetMono(const ZDCPixmap& iPixmap) { fMonoPixmap = iPixmap; } - const ZDCPixmap& GetMono() const { return fMonoPixmap; } - - void SetMask(const ZDCPixmap& iPixmap) { fMaskPixmap = iPixmap; } - const ZDCPixmap& GetMask() const { return fMaskPixmap; } - - ZPoint Size() const; - -// Are we valid, i.e. do we have any pixels at all? - operator operator_bool_type() const; - -protected: - ZDCPixmap fColorPixmap; - ZDCPixmap fMonoPixmap; - ZDCPixmap fMaskPixmap; - }; - -// ================================================================================================= - -NAMESPACE_ZOOLIB_END - -#endif // __ZDCPixmapCombo__ Deleted: trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.cpp 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -1,104 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2001 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZProgressWatcher.h" -#include "zoolib/ZDebug.h" - -NAMESPACE_ZOOLIB_BEGIN - -using std::string; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZProgressPusher - -ZProgressPusher::ZProgressPusher( - ZProgressWatcher* iProgressWatcher, const string& iDescription, int32 iMax) - { - fWatcher = iProgressWatcher; - fPushes = 1; - if (fWatcher) - fWatcher->Push(iDescription, iMax); - } - -ZProgressPusher::ZProgressPusher(ZProgressWatcher* iProgressWatcher, int32 iMax) - { - fWatcher = iProgressWatcher; - fPushes = 1; - if (fWatcher) - fWatcher->Push(string(), iMax); - } - -ZProgressPusher::ZProgressPusher( - ZProgressPusher& iOtherPusher, const string& iDescription, int32 iMax) - { - fWatcher = iOtherPusher.fWatcher; - fPushes = 1; - if (fWatcher) - fWatcher->Push(iDescription, iMax); - } - -ZProgressPusher::ZProgressPusher(ZProgressPusher& iOtherPusher, int32 iMax) - { - fWatcher = iOtherPusher.fWatcher; - fPushes = 1; - if (fWatcher) - fWatcher->Push(string(), iMax); - } - -ZProgressPusher::~ZProgressPusher() - { - if (fWatcher) - { - while (fPushes--) - fWatcher->Pop(); - } - } - -void ZProgressPusher::Push(const string& iDescription, int32 iMax) - { - ++fPushes; - if (fWatcher) - fWatcher->Push(iDescription, iMax); - } - -void ZProgressPusher::Push(int32 iMax) - { - ++fPushes; - if (fWatcher) - fWatcher->Push(string(), iMax); - } - -void ZProgressPusher::Process(int32 iDelta) - { - if (fWatcher) - fWatcher->Process(iDelta); - } - -void ZProgressPusher::Pop() - { - ZAssertStop(2, fPushes > 0); - --fPushes; - - if (fWatcher) - fWatcher->Pop(); - } - -NAMESPACE_ZOOLIB_END Deleted: trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.h 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZProgressWatcher.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -1,73 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2001 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZProgressWatcher__ -#define __ZProgressWatcher__ 1 - -#include "zconfig.h" -#include "zoolib/ZTypes.h" -#include <string> - -NAMESPACE_ZOOLIB_BEGIN - -// ================================================================================================= -#pragma mark - -#pragma mark * ZProgressWatcher - -class ZProgressWatcher - { -protected: - ZProgressWatcher() {} - ~ZProgressWatcher() {} - -public: - virtual void Push(const std::string& iDescription, int32 iMax) = 0; - virtual void Process(int32 iDelta) = 0; - virtual void Pop() = 0; - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZProgressPusher - -class ZProgressPusher - { -public: - ZProgressPusher(ZProgressWatcher* iProgressWatcher, const std::string& iDescription, int32 iMax); - ZProgressPusher(ZProgressWatcher* iProgressWatcher, int32 iMax); - - ZProgressPusher(ZProgressPusher& iOtherPusher, const std::string& iDescription, int32 iMax); - ZProgressPusher(ZProgressPusher& iOtherPusher, int32 iMax); - - ~ZProgressPusher(); - - void Push(const std::string& iDescription, int32 iMax); - void Push(int32 iMax); - void Process(int32 iDelta); - void Pop(); - -private: - ZProgressWatcher* fWatcher; - size_t fPushes; - }; - -NAMESPACE_ZOOLIB_END - -#endif // __ZProgressWatcher__ Modified: trunk/zoolib/source/cxx/zoolib/ZRef_WinHANDLE.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZRef_WinHANDLE.cpp 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZRef_WinHANDLE.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -23,7 +23,7 @@ #if ZCONFIG_SPI_Enabled(Win) -#include "zoolib/ZWinHeader.h" +#include "zoolib/ZCompat_Win.h" // ================================================================================================= Modified: trunk/zoolib/source/cxx/zoolib/ZTuple.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTuple.cpp 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZTuple.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -115,8 +115,11 @@ } \ TYPE ZTuple::Get##TYPENAME(Name_t iName) const \ { return this->Get(iName).Get_T<TYPE>(); } \ - void ZTuple::Set##TYPENAME(Name_t iName, const TYPE& iVal) \ - { return this->Set(iName, iVal); } \ + ZTuple& ZTuple::Set##TYPENAME(Name_t iName, const TYPE& iVal) \ + { \ + this->Set(iName, iVal); \ + return *this; \ + } \ #define ZMACRO_ZMapAccessors_Def(Name_t) \ ZMACRO_ZMapAccessors_Def_Entry(Name_t, ID, uint64) \ Modified: trunk/zoolib/source/cxx/zoolib/ZTuple.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTuple.h 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZTuple.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -36,7 +36,7 @@ bool QGet##TYPENAME(Name_t iName, TYPE& oVal) const; \ TYPE DGet##TYPENAME(const TYPE& iDefault, Name_t iName) const; \ TYPE Get##TYPENAME(Name_t iName) const; \ - void Set##TYPENAME(Name_t iName, const TYPE& iVal); \ + ZTuple& Set##TYPENAME(Name_t iName, const TYPE& iVal); \ #define ZMACRO_ZMapAccessors_Decl(T, Name_t) \ ZMACRO_ZMapAccessors_Decl_Entry(T, Name_t, ID, uint64) \ Modified: trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Data.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Data.cpp 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Data.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -34,10 +34,7 @@ #pragma mark * Helper functions void ZUtil_Strim_Data::sDumpData(const ZStreamRPos& iStreamRPos, const ZStrimW& s) - { - sDumpData(iStreamRPos, s, ZINT64_C(0xFFFFFFFFFFFFFFFF)); -// sDumpData(iStreamRPos, s, ZINT64_C(~0)); - } + { sDumpData(iStreamRPos, s, ZUINT64_C(0xFFFFFFFFFFFFFFFF)); } void ZUtil_Strim_Data::sDumpData(const ZStreamRPos& iStreamRPos, const ZStrimW& s, uint64 iMax) { @@ -46,7 +43,7 @@ const size_t chunkSize = 16; const uint64 theCount = iStreamRPos.GetSize() - iStreamRPos.GetPosition(); - uint64 countRemaining = min(theCount, uint64(iMax)); + uint64 countRemaining = min(theCount, iMax); s.Writef("Size: %lld", theCount); if (theCount > countRemaining) Modified: trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Geom.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Geom.h 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Geom.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -41,7 +41,7 @@ { return s.Writef("(%g, %g)", double(val.h), double(val.v)); } template <class C> -inline const ZStrimW& operator<<(const ZStrimW& s, const ZGPoint_T<C>& val) +inline const ZStrimW& operator<<(const ZStrimW& s, const ZGPointPOD_T<C>& val) { return s.Writef("(%g, %g)", double(val.x), double(val.y)); } template <class C> Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -134,35 +134,39 @@ return ZVal_Any(); } -void ZList_Any::Set(size_t iIndex, const ZVal_Any& iVal) +ZList_Any& ZList_Any::Set(size_t iIndex, const ZVal_Any& iVal) { if (fRep && iIndex < fRep->fVector.size()) { this->pTouch(); fRep->fVector[iIndex] = iVal; } + return *this; } -void ZList_Any::Erase(size_t iIndex) +ZList_Any& ZList_Any::Erase(size_t iIndex) { if (fRep && iIndex < fRep->fVector.size()) { this->pTouch(); fRep->fVector.erase(fRep->fVector.begin() + iIndex); } + return *this; } -void ZList_Any::Insert(size_t iIndex, const ZVal_Any& iVal) +ZList_Any& ZList_Any::Insert(size_t iIndex, const ZVal_Any& iVal) { this->pTouch(); if (iIndex <= fRep->fVector.size()) fRep->fVector.insert((fRep->fVector.begin() + iIndex), iVal); + return *this; } -void ZList_Any::Append(const ZVal_Any& iVal) +ZList_Any& ZList_Any::Append(const ZVal_Any& iVal) { this->pTouch(); fRep->fVector.push_back(iVal); + return *this; } void ZList_Any::pTouch() @@ -321,33 +325,37 @@ return ZVal_Any(); } -void ZMap_Any::Set(const string8& iName, const ZVal_Any& iVal) +ZMap_Any& ZMap_Any::Set(const string8& iName, const ZVal_Any& iVal) { this->pTouch(); fRep->fMap.insert(pair<string8, ZVal_Any>(iName, iVal)); + return *this; } -void ZMap_Any::Set(const Index_t& iIndex, const ZVal_Any& iVal) +ZMap_Any& ZMap_Any::Set(const Index_t& iIndex, const ZVal_Any& iVal) { map<string, ZVal_Any>::iterator theIndex = this->pTouch(iIndex); if (theIndex != this->End()) (*theIndex).second = iVal; + return *this; } -void ZMap_Any::Erase(const Index_t& iIndex) +ZMap_Any& ZMap_Any::Erase(const Index_t& iIndex) { map<string, ZVal_Any>::iterator theIndex = this->pTouch(iIndex); if (theIndex != this->End()) fRep->fMap.erase(theIndex); + return *this; } -void ZMap_Any::Erase(const string8& iName) +ZMap_Any& ZMap_Any::Erase(const string8& iName) { if (fRep) { this->pTouch(); fRep->fMap.erase(iName); } + return *this; } ZMap_Any::Index_t ZMap_Any::Begin() const Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -147,13 +147,13 @@ ZVal_Any DGet(const ZVal_Any& iDefault, size_t iIndex) const; ZVal_Any Get(size_t iIndex) const; - void Set(size_t iIndex, const ZVal_Any& iVal); + ZList_Any& Set(size_t iIndex, const ZVal_Any& iVal); - void Erase(size_t iIndex); + ZList_Any& Erase(size_t iIndex); - void Insert(size_t iIndex, const ZVal_Any& iVal); + ZList_Any& Insert(size_t iIndex, const ZVal_Any& iVal); - void Append(const ZVal_Any& iVal); + ZList_Any& Append(const ZVal_Any& iVal); private: void pTouch(); @@ -274,11 +274,11 @@ ZVal_Any Get(const string8& iName) const; ZVal_Any Get(const Index_t& iIndex) const; - void Set(const string8& iName, const ZVal_Any& iVal); - void Set(const Index_t& iIndex, const ZVal_Any& iVal); + ZMap_Any& Set(const string8& iName, const ZVal_Any& iVal); + ZMap_Any& Set(const Index_t& iIndex, const ZVal_Any& iVal); - void Erase(const string8& iName); - void Erase(const Index_t& iIndex); + ZMap_Any& Erase(const string8& iName); + ZMap_Any& Erase(const Index_t& iIndex); // Our protocol Index_t Begin() const; Modified: trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -560,13 +560,18 @@ return ZVal_AppleEvent(); } -void ZList_AppleEvent::Erase(size_t iIndex) - { ::AEDeleteItem(this, iIndex + 1); } +ZList_AppleEvent& ZList_AppleEvent::Erase(size_t iIndex) + {::AEDeleteItem(this, iIndex + 1); + return *this; + } -void ZList_AppleEvent::Set(size_t iIndex, const AEDesc& iVal) - { ::AEPutDesc(this, iIndex + 1, &iVal); } +ZList_AppleEvent& ZList_AppleEvent::Set(size_t iIndex, const AEDesc& iVal) + { + ::AEPutDesc(this, iIndex + 1, &iVal); + return *this; + } -void ZList_AppleEvent::Insert(size_t iIndex, const AEDesc& iVal) +ZList_AppleEvent& ZList_AppleEvent::Insert(size_t iIndex, const AEDesc& iVal) { long theCount; if (noErr == ::AECountItems(this, &theCount)) @@ -579,13 +584,20 @@ } ::AEPutDesc(this, iIndex + 1, &iVal); } + return *this; } -void ZList_AppleEvent::Append(const AEDesc& iVal) - { ::AEPutDesc(this, 0, &iVal); } +ZList_AppleEvent& ZList_AppleEvent::Append(const AEDesc& iVal) + { + ::AEPutDesc(this, 0, &iVal); + return *this; + } -void ZList_AppleEvent::Append(const ZVal_AppleEvent& iVal) - { ::AEPutDesc(this, 0, &iVal); } +ZList_AppleEvent& ZList_AppleEvent::Append(const ZVal_AppleEvent& iVal) + { + ::AEPutDesc(this, 0, &iVal); + return *this; + } // ================================================================================================= #pragma mark - @@ -717,23 +729,41 @@ ZVal_AppleEvent ZMap_AppleEvent::Get(Index_t iIndex) const { return this->DGet(ZVal_AppleEvent(), iIndex); } -void ZMap_AppleEvent::Set(AEKeyword iName, const AEDesc& iVal) - { ::AEPutKeyDesc(this, iName, &iVal); } +ZMap_AppleEvent& ZMap_AppleEvent::Set(AEKeyword iName, const AEDesc& iVal) + { + ::AEPutKeyDesc(this, iName, &iVal); + return *this; + } -void ZMap_AppleEvent::Set(const string& iName, const AEDesc& iVal) - { ::AEPutKeyDesc(this, spAsAEKeyword(iName), &iVal); } +ZMap_AppleEvent& ZMap_AppleEvent::Set(const string& iName, const AEDesc& iVal) + { + ::AEPutKeyDesc(this, spAsAEKeyword(iName), &iVal); + return *this; + } -void ZMap_AppleEvent::Set(Index_t iIndex, const AEDesc& iVal) - { ::AEPutDesc(this, iIndex.GetIndex() + 1, &iVal); } +ZMap_AppleEvent& ZMap_AppleEvent::Set(Index_t iIndex, const AEDesc& iVal) + { + ::AEPutDesc(this, iIndex.GetIndex() + 1, &iVal); + return *this; + } -void ZMap_AppleEvent::Erase(AEKeyword iName) - { ::AEDeleteKeyDesc(this, iName); } +ZMap_AppleEvent& ZMap_AppleEvent::Erase(AEKeyword iName) + { + ::AEDeleteKeyDesc(this, iName); + return *this; + } -void ZMap_AppleEvent::Erase(const string& iName) - { ::AEDeleteKeyDesc(this, spAsAEKeyword(iName)); } +ZMap_AppleEvent& ZMap_AppleEvent::Erase(const string& iName) + { + ::AEDeleteKeyDesc(this, spAsAEKeyword(iName)); + return *this; + } -void ZMap_AppleEvent::Erase(Index_t iIndex) - { ::AEDeleteItem(this, iIndex.GetIndex() + 1); } +ZMap_AppleEvent& ZMap_AppleEvent::Erase(Index_t iIndex) + { + ::AEDeleteItem(this, iIndex.GetIndex() + 1); + return *this; + } AEDesc& ZMap_AppleEvent::OParam() { Modified: trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -167,14 +167,14 @@ ZVal_AppleEvent DGet(const ZVal_AppleEvent& iDefault, size_t iIndex) const; ZVal_AppleEvent Get(size_t iIndex) const; - void Set(size_t iIndex, const AEDesc& iVal); + ZList_AppleEvent& Set(size_t iIndex, const AEDesc& iVal); - void Erase(size_t iIndex); + ZList_AppleEvent& Erase(size_t iIndex); - void Insert(size_t iIndex, const AEDesc& iVal); + ZList_AppleEvent& Insert(size_t iIndex, const AEDesc& iVal); - void Append(const AEDesc& iVal); - void Append(const ZVal_AppleEvent& iVal); + ZList_AppleEvent& Append(const AEDesc& iVal); + ZList_AppleEvent& Append(const ZVal_AppleEvent& iVal); }; // ================================================================================================= @@ -224,13 +224,13 @@ ZVal_AppleEvent Get(const std::string& iName) const; ZVal_AppleEvent Get(Index_t iIndex) const; - void Set(AEKeyword iName, const AEDesc& iVal); - void Set(const std::string& iName, const AEDesc& iVal); - void Set(Index_t iIndex, const AEDesc& iVal); + ZMap_AppleEvent& Set(AEKeyword iName, const AEDesc& iVal); + ZMap_AppleEvent& Set(const std::string& iName, const AEDesc& iVal); + ZMap_AppleEvent& Set(Index_t iIndex, const AEDesc& iVal); - void Erase(AEKeyword iName); - void Erase(const std::string& iName); - void Erase(Index_t iIndex); + ZMap_AppleEvent& Erase(AEKeyword iName); + ZMap_AppleEvent& Erase(const std::string& iName); + ZMap_AppleEvent& Erase(Index_t iIndex); // Our protocol AERecord& OParam(); Modified: trunk/zoolib/source/cxx/zoolib/ZVal_CFType.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_CFType.cpp 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZVal_CFType.cpp 2010-01-15 04:06:52 UTC (rev 1101) @@ -45,8 +45,10 @@ #pragma mark - #pragma mark * Helpers +namespace { + template <class S> -bool sGetNumber_T(CFTypeRef iTypeRef, CFNumberType iNumberType, S& oVal) +bool spGetNumber_T(CFTypeRef iTypeRef, CFNumberType iNumberType, S& oVal) { if (::CFGetTypeID(iTypeRef) == ::CFNumberGetTypeID()) { @@ -61,9 +63,11 @@ } template <class S> -ZRef<CFTypeRef> sNumber_T(CFNumberType iNumberType, const S& iVal) +ZRef<CFTypeRef> spNumber_T(CFNumberType iNumberType, const S& iVal) { return NoRetain(CFTypeRef(::CFNumberCreate(kCFAllocatorDefault, iNumberType, &iVal))); } +} // anonymous namespace + // ================================================================================================= #pragma mark - #pragma mark * ZVal_CFType @@ -109,23 +113,19 @@ {} ZVal_CFType::ZVal_CFType(int8 iVal) -: inherited( - NoRetain(CFTypeRef(::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt8Type, &iVal)))) +: inherited(spNumber_T(kCFNumberSInt8Type, iVal)) {} ZVal_CFType::ZVal_CFType(int16 iVal) -: inherited( - NoRetain(CFTypeRef(::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &iVal)))) +: inherited(spNumber_T(kCFNumberSInt16Type, iVal)) {} ZVal_CFType::ZVal_CFType(int32 iVal) -: inherited( - NoRetain(CFTypeRef(::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &iVal)))) +: inherited(spNumber_T(kCFNumberSInt32Type, iVal)) {} ZVal_CFType::ZVal_CFType(int64 iVal) -: inherited( - NoRetain(CFTypeRef(::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &iVal)))) +: inherited(spNumber_T(kCFNumberSInt64Type, iVal)) {} ZVal_CFType::ZVal_CFType(bool iVal) @@ -133,13 +133,11 @@ {} ZVal_CFType::ZVal_CFType(float iVal) -: inherited( - NoRetain(CFTypeRef(::CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat32Type, &iVal)))) +: inherited(spNumber_T(kCFNumberFloat32Type, iVal)) {} ZVal_CFType::ZVal_CFType(double iVal) -: inherited( - NoRetain(CFTypeRef(::CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat64Type, &iVal)))) +: inherited(spNumber_T(kCFNumberFloat64Type, iVal)) {} ZVal_CFType::ZVal_CFType(const char* iVal) @@ -198,9 +196,9 @@ template <> bool ZVal_CFType::QGet_T<int8>(int8& oVal) const { - if (sGetNumber_T(*this, kCFNumberSInt8Type, oVal)) + if (spGetNumber_T(*this, kCFNumberSInt8Type, oVal)) return true; - if (sGetNumber_T(*this, kCFNumberCharType, oVal)) + if (spGetNumber_T(*this, kCFNumberCharType, oVal)) return true; return false; } @@ -208,9 +206,9 @@ template <> bool ZVal_CFType::QGet_T<int16>(int16& oVal) const { - if (sGetNumber_T(*this, kCFNumberSInt16Type, oVal)) + if (spGetNumber_T(*this, kCFNumberSInt16Type, oVal)) return true; - if (sGetNumber_T(*this, kCFNumberShortType, oVal)) + if (spGetNumber_T(*this, kCFNumberShortType, oVal)) return true; return false; } @@ -218,13 +216,13 @@ template <> bool ZVal_CFType::QGet_T<int32>(int32& oVal) const { - if (sGetNumber_T(*this, kCFNumberSInt32Type, oVal)) + if (spGetNumber_T(*this, kCFNumberSInt32Type, oVal)) return true; - if (sGetNumber_T(*this, kCFNumberIntType, oVal)) + if (spGetNumber_T(*this, kCFNumberIntType, oVal)) return true; #if !ZCONFIG_Is64Bit - if (sGetNumber_T(*this, kCFNumberLongType, oVal)) + if (spGetNumber_T(*this, kCFNumberLongType, oVal)) return true; #endif @@ -234,13 +232,13 @@ template <> bool ZVal_CFType::QGet_T<int64>(int64& oVal) const { - if (sGetNumber_T(*this, kCFNumberSInt64Type, oVal)) + if (spGetNumber_T(*this, kCFNumberSInt64Type, oVal)) return true; - if (sGetNumber_T(*this, kCFNumberLongLongType, oVal)) + if (spGetNumber_T(*this, kCFNumberLongLongType, oVal)) return true; #if ZCONFIG_Is64Bit - if (sGetNumber_T(*this, kCFNumberLongType, oVal)) + if (spGetNumber_T(*this, kCFNumberLongType, oVal)) return true; #endif @@ -261,9 +259,9 @@ template <> bool ZVal_CFType::QGet_T<float>(float& oVal) const { - if (sGetNumber_T(*this, kCFNumberFloat32Type, oVal)) + if (spGetNumber_T(*this, kCFNumberFloat32Type, oVal)) return true; - if (sGetNumber_T(*this, kCFNumberFloatType, oVal)) + if (spGetNumber_T(*this, kCFNumberFloatType, oVal)) return true; return false; } @@ -271,9 +269,9 @@ template <> bool ZVal_CFType::QGet_T<double>(double& oVal) const { - if (sGetNumber_T(*this, kCFNumberFloat64Type, oVal)) + if (spGetNumber_T(*this, kCFNumberFloat64Type, oVal)) return true; - if (sGetNumber_T(*this, kCFNumberDoubleType, oVal)) + if (spGetNumber_T(*this, kCFNumberDoubleType, oVal)) return true; return false; } @@ -335,19 +333,19 @@ template <> void ZVal_CFType::Set_T<int8>(const int8& iVal) - { inherited::operator=(sNumber_T(kCFNumberSInt8Type, iVal)); } + { inherited::operator=(spNumber_T(kCFNumberSInt8Type, iVal)); } template <> void ZVal_CFType::Set_T<int16>(const int16& iVal) - { inherited::operator=(sNumber_T(kCFNumberSInt16Type, iVal)); } + { inherited::operator=(spNumber_T(kCFNumberSInt16Type, iVal)); } template <> void ZVal_CFType::Set_T<int32>(const int32& iVal) - { inherited::operator=(sNumber_T(kCFNumberSInt32Type, iVal)); } + { inherited::operator=(spNumber_T(kCFNumberSInt32Type, iVal)); } template <> void ZVal_CFType::Set_T<int64>(const int64& iVal) - { inherited::operator=(sNumber_T(kCFNumberSInt64Type, iVal)); } + { inherited::operator=(spNumber_T(kCFNumberSInt64Type, iVal)); } template <> void ZVal_CFType::Set_T<bool>(const bool& iVal) @@ -355,11 +353,11 @@ template <> void ZVal_CFType::Set_T<float>(const float& iVal) - { inherited::operator=(sNumber_T(kCFNumberFloat32Type, iVal)); } + { inherited::operator=(spNumber_T(kCFNumberFloat32Type, iVal)); } template <> void ZVal_CFType::Set_T<double>(const double& iVal) - { inherited::operator=(sNumber_T(kCFNumberFloat64Type, iVal)); } + { inherited::operator=(spNumber_T(kCFNumberFloat64Type, iVal)); } template <> void ZVal_CFType::Set_T<string8>(const string8& iVal) @@ -458,7 +456,7 @@ void ZList_CFType::Clear() { inherited::Clear(); } -bool ZList_CFType::QGet(size_t iIndex, ZVal_CFType& oVal) const +bool ZList_CFType::QGet(size_t iIndex, ZRef<CFTypeRef>& oVal) const { if (CFArrayRef theArray = this->pArray()) { @@ -485,10 +483,13 @@ ZVal_CFType ZList_CFType::Get(size_t iIndex) const { return this->DGet(ZVal_CFType(), iIndex); } -void ZList_CFType::Set(size_t iIndex, const ZVal_CFType& iVal) - { ::CFArraySetValueAtIndex(this->pTouch(), iIndex, iVal); } +ZList_CFType& ZList_CFType::Set(size_t iIndex, const ZVal_CFType& iVal) + { + ::CFArraySetValueAtIndex(this->pTouch(), iIndex, iVal); + return *this; + } -void ZList_CFType::Erase(size_t iIndex) +ZList_CFType& ZList_CFType::Erase(size_t iIndex) { CFMutableArrayRef theArray = this->pTouch(); if (const size_t theCount = ::CFArrayGetCount(theArray)) @@ -496,18 +497,23 @@ if (iIndex < theCount) ::CFArrayRemoveValueAtIndex(theArray, iIndex); } + return *this; } -void ZList_CFType::Insert(size_t iIndex, const ZVal_CFType& iVal) +ZList_CFType& ZList_CFType::Insert(size_t iIndex, const ZVal_CFType& iVal) { CFMutableArrayRef theArray = this->pTouch(); const size_t theCount = ::CFArrayGetCount(theArray); if (iIndex <= theCount) ::CFArrayInsertValueAtIndex(theArray, iIndex, iVal); + return *this; } -void ZList_CFType::Append(const ZVal_CFType& iVal) - { ::CFArrayAppendValue(this->pTouch(), iVal); } +ZList_CFType& ZList_CFType::Append(const ZVal_CFType& iVal) + { + ::CFArrayAppendValue(this->pTouch(), iVal); + return *this; + } CFArrayRef ZList_CFType::pArray() const { return inherited::Get(); } @@ -600,7 +606,7 @@ void ZMap_CFType::Clear() { inherited::Clear(); } -bool ZMap_CFType::QGet(const string8& iName, ZVal_CFType& oVal) const +bool ZMap_CFType::QGet(const string8& iName, ZRef<CFTypeRef>& oVal) const { if (CFDictionaryRef theDictionary = this->pDictionary()) { @@ -613,7 +619,7 @@ return false; } -bool ZMap_CFType::QGet(CFStringRef iName, ZVal_CFType& oVal) const +bool ZMap_CFType::QGet(CFStringRef iName, ZRef<CFTypeRef>& oVal) const { if (CFDictionaryRef theDictionary = this->pDictionary()) { @@ -648,17 +654,29 @@ ZVal_CFType ZMap_CFType::Get(CFStringRef iName) const { return this->DGet(ZVal_CFType(), iName); } -void ZMap_CFType::Set(const string8& iName, const ZVal_CFType& iVal) - { ::CFDictionarySetValue(this->pTouch(), sString(iName), iVal); } +ZMap_CFType& ZMap_CFType::Set(const string8& iName, const ZVal_CFType& iVal) + { + ::CFDictionarySetValue(this->pTouch(), sString(iName), iVal); + return *this; + } -void ZMap_CFType::Set(CFStringRef iName, const ZVal_CFType& iVal) - { ::CFDictionarySetValue(this->pTouch(), iName, iVal); } +ZMap_CFType& ZMap_CFType::Set(CFStringRef iName, const ZVal_CFType& iVal) + { + ::CFDictionarySetValue(this->pTouch(), iName, iVal); + return *this; + } -void ZMap_CFType::Erase(const string8& iName) - { ::CFDictionaryRemoveValue(this->pTouch(), sString(iName)); } +ZMap_CFType& ZMap_CFType::Erase(const string8& iName) + { + ::CFDictionaryRemoveValue(this->pTouch(), sString(iName)); + return *this; + } -void ZMap_CFType::Erase(CFStringRef iName) - { ::CFDictionaryRemoveValue(this->pTouch(), iName); } +ZMap_CFType& ZMap_CFType::Erase(CFStringRef iName) + { + ::CFDictionaryRemoveValue(this->pTouch(), iName); + return *this; + } CFDictionaryRef ZMap_CFType::pDictionary() const { return inherited::Get(); } Modified: trunk/zoolib/source/cxx/zoolib/ZVal_CFType.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_CFType.h 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZVal_CFType.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -146,17 +146,17 @@ void Clear(); - bool QGet(size_t iIndex, ZVal_CFType& oVal) const; + bool QGet(size_t iIndex, ZRef<CFTypeRef>& oVal) const; ZVal_CFType DGet(const ZVal_CFType& iDefault, size_t iIndex) const; ZVal_CFType Get(size_t iIndex) const; - void Set(size_t iIndex, const ZVal_CFType& iVal); + ZList_CFType& Set(size_t iIndex, const ZVal_CFType& iVal); - void Erase(size_t iIndex); + ZList_CFType& Erase(size_t iIndex); - void Insert(size_t iIndex, const ZVal_CFType& iVal); + ZList_CFType& Insert(size_t iIndex, const ZVal_CFType& iVal); - void Append(const ZVal_CFType& iVal); + ZList_CFType& Append(const ZVal_CFType& iVal); private: CFArrayRef pArray() const; @@ -193,8 +193,8 @@ // ZMap protocol void Clear(); - bool QGet(const string8& iName, ZVal_CFType& oVal) const; - bool QGet(CFStringRef iName, ZVal_CFType& oVal) const; + bool QGet(const string8& iName, ZRef<CFTypeRef>& oVal) const; + bool QGet(CFStringRef iName, ZRef<CFTypeRef>& oVal) const; ZVal_CFType DGet(const ZVal_CFType& iDefault, const string8& iName) const; ZVal_CFType DGet(const ZVal_CFType& iDefault, CFStringRef iName) const; @@ -202,11 +202,11 @@ ZVal_CFType Get(const string8& iName) const; ZVal_CFType Get(CFStringRef iName) const; - void Set(const string8& iName, const ZVal_CFType& iVal); - void Set(CFStringRef iName, const ZVal_CFType& iVal); + ZMap_CFType& Set(const string8& iName, const ZVal_CFType& iVal); + ZMap_CFType& Set(CFStringRef iName, const ZVal_CFType& iVal); - void Erase(const string8& iName); - void Erase(CFStringRef iName); + ZMap_CFType& Erase(const string8& iName); + ZMap_CFType& Erase(CFStringRef iName); private: CFDictionaryRef pDictionary() const; Modified: trunk/zoolib/source/cxx/zoolib/ZVal_NS.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_NS.h 2010-01-15 04:04:29 UTC (rev 1100) +++ trunk/zoolib/source/cxx/zoolib/ZVal_NS.h 2010-01-15 04:06:52 UTC (rev 1101) @@ -147,17 +147,17 @@ void Clear(); - bool QGet(size_t iIndex, ZVal_NS& oVal) const; + bool QGet(size_t iIndex, ZRef<NSObject>& oVal) const; ZVal_NS DGet(const ZVal_NS& iDefault, size_t iIndex) const; ZVal_NS Get(size_t iIndex) const; - void Set(size_t iIndex, const ZVal_NS& iVal); + ZList_NS& Set(size_t iIndex, const ZVal_NS& iVal); - void Erase(size_t iIndex); + ZList_NS& Erase(size_t iIndex); - void Insert(size_t iIndex, const ZVal_NS& iVal); + ZList_NS& Insert(size_t iIndex, const ZVal_NS& iVal); - void Append(const ZVal_NS& iVal); + ZList_NS& Append(const... [truncated message content] |
From: <ag...@us...> - 2010-04-03 18:22:50
|
Revision: 1232 http://zoolib.svn.sourceforge.net/zoolib/?rev=1232&view=rev Author: agreen Date: 2010-04-03 18:22:43 +0000 (Sat, 03 Apr 2010) Log Message: ----------- Add ZCompat_MSVCStaticLib.h, see that file for details. Add ZMACRO_MSVCStaticLib_Reference and ZMACRO_MSVCStaticLib_cpp to appropriate files (static factories used on windows). Modified Paths: -------------- trunk/zoolib/source/cxx/old/zoolib/ZDC_GDI.cpp trunk/zoolib/source/cxx/old/zoolib/ZDC_GDI.h trunk/zoolib/source/cxx/zoolib/ZFunctionChain.h trunk/zoolib/source/cxx/zoolib/ZGRgnRep_HRGN.cpp trunk/zoolib/source/cxx/zoolib/ZGRgnRep_HRGN.h trunk/zoolib/source/cxx/zoolib/ZNet_Internet_WinSock.cpp trunk/zoolib/source/cxx/zoolib/ZNet_Internet_WinSock.h trunk/zoolib/source/cxx/zoolib/ZStreamRWCon_SSL_Win.cpp trunk/zoolib/source/cxx/zoolib/ZStreamRWCon_SSL_Win.h trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.cpp trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.h trunk/zoolib/source/cxx/zoolib/ZUnicode_Normalize_Win.cpp trunk/zoolib/source/cxx/zoolib/ZUnicode_Normalize_Win.h Added Paths: ----------- trunk/zoolib/source/cxx/zoolib/ZCompat_MSVCStaticLib.h Modified: trunk/zoolib/source/cxx/old/zoolib/ZDC_GDI.cpp =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZDC_GDI.cpp 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/old/zoolib/ZDC_GDI.cpp 2010-04-03 18:22:43 UTC (rev 1232) @@ -22,6 +22,9 @@ #if ZCONFIG_API_Enabled(DC_GDI) +#include "zoolib/ZCompat_MSVCStaticLib.h" +ZMACRO_MSVCStaticLib_cpp(DC_GDI) + #include "zoolib/ZCompat_algorithm.h" // For min #include "zoolib/ZFunctionChain.h" #include "zoolib/ZMemory.h" Modified: trunk/zoolib/source/cxx/old/zoolib/ZDC_GDI.h =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZDC_GDI.h 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/old/zoolib/ZDC_GDI.h 2010-04-03 18:22:43 UTC (rev 1232) @@ -36,6 +36,9 @@ #if ZCONFIG_API_Enabled(DC_GDI) +#include "zoolib/ZCompat_MSVCStaticLib.h" +ZMACRO_MSVCStaticLib_Reference(DC_GDI) + #include "zoolib/ZCompat_Win.h" #include "zoolib/ZThreadOld.h" Added: trunk/zoolib/source/cxx/zoolib/ZCompat_MSVCStaticLib.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZCompat_MSVCStaticLib.h (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZCompat_MSVCStaticLib.h 2010-04-03 18:22:43 UTC (rev 1232) @@ -0,0 +1,112 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ +#ifndef __ZCompat_MSVCStaticLib__ +#define __ZCompat_MSVCStaticLib__ 1 +#include "zconfig.h" + +/** +\file +\sa ZFunctionChain.h +\section Background + +Static variables in a translation unit are initialized before any regular code in the +translation unit executes. In practice the initialization happens when the containing +executable or dynamic library is loaded. When your main() is called, or your call to +LoadLibrary/dlopen completes, any static variables will have been initialized. + +\section TheProblem The Problem +It can be convenient to place the object code from multiple translation units in a single +file, a static library conventionally named with a .lib or .a suffix. The MSVC linker does +dependency analysis on static libraries and will not include code that is not referenced +by the including entity. The common pattern of using a static variable to declare and cause +the registration of a factory object can fail in this circumstance -- the MSVC linker +deems the static as being unreachable and strips it from the result. + +\section Solutions +A useful google search: http://www.google.com/search?q=msvc+factory+static+library + +One solution is to set the /OPT:NOREF linker flag on the including entity. However, this is +an all or nothing setting, and will require that all included libraries be fully linkable. + +If something in the file containing the static is referenced (directly or indirectly) by +the including entity, then by the language rules the static itself must be preserved. + +The most basic approach is to put a dummy variable in the file, and reference it from +somewhere known to be considered reachable. + +Another approach is to use the /include linker flag to reference an entity in the problem file. +This can be done in the source itself. Assuming an entity named DummyForLinkProblem: +\code #pragma comment(linker, "/include:DummyForLinkProblem") \endcode + +\section ZooLibSolution ZooLib's Solution +ZooLib entities currently affected by this problem are those in ZFile_Win.cpp, ZGRgnRep_HRGN.cpp, +ZNet_Internet_WinSock.cpp, ZStreamRWCon_SSL_Win.cpp, ZTextCoder_Win.cpp +and ZUnicode_Normalize_Win.cpp. + +We #include ZCompat_MSVCStaticLib.h in the corresponding header files, and put in each a +ZMACRO_MSVCStaticLib_Reference(ModifiedFileName). In the cpp files we put a +ZMACRO_MSVCStaticLib_cpp(ModifiedFileName). The ModifiedFileName is generally the +filename with the leading Z and file extension removed, the same style of name is +used in ZCONFIG_API_XXX macros. + +To ensure that your executable or library does not strip these entities, simply #include +the appropriate header file from known referenced code in your including entity. This will +cause a non-executing reference to occur, and things will work as expected. +*/ + +// ================================================================================================= +#pragma mark - +#pragma mark * ZCompat_MSVCStaticLib + +#if ZCONFIG(Compiler, MSVC) + +#define ZMACRO_MSVCStaticLib_Reference(a) \ + namespace ZooLib { \ + namespace MSVCStaticLib { \ + namespace a { \ + extern const int DummyInteger; \ + namespace /* anonymous */ { \ + int ReferenceDummyInteger(); \ + int ReferenceDummyInteger() { return DummyInteger; } \ + } /* anonymous namespace*/ \ + } /* namespace a */ \ + } /* namespace MSVCStaticLib */ \ + } /* namespace ZooLib */ + +#define ZMACRO_MSVCStaticLib_cpp(a) \ + namespace ZooLib { \ + namespace MSVCStaticLib { \ + namespace a { \ + const int DummyInteger = 0; \ + } /* namespace a */ \ + } /* namespace MSVCStaticLib */ \ + } /* namespace ZooLib */ + +#endif // ZCONFIG(Compiler, MSVC) + +#if !defined(ZMACRO_MSVCStaticLib_Reference) + #define ZMACRO_MSVCStaticLib_Reference(a) +#endif + +#if !defined(ZMACRO_MSVCStaticLib_cpp) + #define ZMACRO_MSVCStaticLib_cpp(a) +#endif + +#endif // __ZCompat_MSVCStaticLib__ Modified: trunk/zoolib/source/cxx/zoolib/ZFunctionChain.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZFunctionChain.h 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZFunctionChain.h 2010-04-03 18:22:43 UTC (rev 1232) @@ -24,6 +24,14 @@ NAMESPACE_ZOOLIB_BEGIN +/** +\file +If you're using the MSVC linker and putting a factory in a static library, be aware that +the statically-initialized factory will not be considered active code unless some other +part of the containing translation unit is active. See ZCompat_MSVCStaticLib.h for +more discussion and suggested workarounds. +*/ + // ================================================================================================= #pragma mark - #pragma mark * ZFunctionChain_T Modified: trunk/zoolib/source/cxx/zoolib/ZGRgnRep_HRGN.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZGRgnRep_HRGN.cpp 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZGRgnRep_HRGN.cpp 2010-04-03 18:22:43 UTC (rev 1232) @@ -22,6 +22,8 @@ #if ZCONFIG_API_Enabled(GRgnRep_HRGN) +ZMACRO_MSVCStaticLib_cpp(GRgnRep_HRGN) + #include "zoolib/ZFunctionChain.h" #include <vector> Modified: trunk/zoolib/source/cxx/zoolib/ZGRgnRep_HRGN.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZGRgnRep_HRGN.h 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZGRgnRep_HRGN.h 2010-04-03 18:22:43 UTC (rev 1232) @@ -37,6 +37,9 @@ #if ZCONFIG_API_Enabled(GRgnRep_HRGN) +#include "zoolib/ZCompat_MSVCStaticLib.h" +ZMACRO_MSVCStaticLib_Reference(GRgnRep_HRGN) + #include "zoolib/ZCompat_Win.h" NAMESPACE_ZOOLIB_BEGIN Modified: trunk/zoolib/source/cxx/zoolib/ZNet_Internet_WinSock.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZNet_Internet_WinSock.cpp 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZNet_Internet_WinSock.cpp 2010-04-03 18:22:43 UTC (rev 1232) @@ -22,6 +22,8 @@ #if ZCONFIG_API_Enabled(Net_Internet_WinSock) +ZMACRO_MSVCStaticLib_cpp(Net_Internet_WinSock) + #include "zoolib/ZCompat_cmath.h" #include "zoolib/ZFunctionChain.h" #include "zoolib/ZMemory.h" @@ -73,6 +75,32 @@ // ================================================================================================= #pragma mark - +#pragma mark * InitializeWinSock + +namespace ZANONYMOUS { + +class InitializeWinSock + { +public: + InitializeWinSock() + { + // Low order byte is major version number, high order byte is minor version number. + int result = ::WSAStartup(0x0002, &fWSADATA); + if (result) + ZDebugLogf(2, ("WSAStartup got error %d", GetLastError())); + } + + ~InitializeWinSock() + { ::WSACleanup(); } + +private: + WSADATA fWSADATA; + } sInitializeWinSock; + +} // anonymous namespace + +// ================================================================================================= +#pragma mark - #pragma mark * ZNet_Internet_WinSock ZNet::Error ZNet_Internet_WinSock::sTranslateError(int inNativeError) @@ -93,33 +121,6 @@ // ================================================================================================= #pragma mark - -#pragma mark * ZNet_Internet_WinSock::InitHelper__ - -class ZNet_Internet_WinSock::InitHelper__ - { -public: - InitHelper__(); - ~InitHelper__(); -private: - WSADATA fWSADATA; - static InitHelper__ spInitHelper__; - }; - -ZNet_Internet_WinSock::InitHelper__ ZNet_Internet_WinSock::InitHelper__::spInitHelper__; - -ZNet_Internet_WinSock::InitHelper__::InitHelper__() - { - // Low order byte is major version number, high order byte is minor version number. - int result = ::WSAStartup(0x0002, &fWSADATA); - if (result) - ZDebugLogf(2, ("WSAStartup got error %d", GetLastError())); - } - -ZNet_Internet_WinSock::InitHelper__::~InitHelper__() - { ::WSACleanup(); } - -// ================================================================================================= -#pragma mark - #pragma mark * ZNetNameLookup_Internet_WinSock ZNetNameLookup_Internet_WinSock::ZNetNameLookup_Internet_WinSock( Modified: trunk/zoolib/source/cxx/zoolib/ZNet_Internet_WinSock.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZNet_Internet_WinSock.h 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZNet_Internet_WinSock.h 2010-04-03 18:22:43 UTC (rev 1232) @@ -36,6 +36,9 @@ #if ZCONFIG_API_Enabled(Net_Internet_WinSock) +#include "zoolib/ZCompat_MSVCStaticLib.h" +ZMACRO_MSVCStaticLib_Reference(Net_Internet_WinSock) + #include <vector> #include <winsock.h> @@ -50,8 +53,6 @@ { public: static ZNet::Error sTranslateError(int inNativeError); -private: - class InitHelper__; }; // ================================================================================================= Modified: trunk/zoolib/source/cxx/zoolib/ZStreamRWCon_SSL_Win.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStreamRWCon_SSL_Win.cpp 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZStreamRWCon_SSL_Win.cpp 2010-04-03 18:22:43 UTC (rev 1232) @@ -22,6 +22,8 @@ #if ZCONFIG_SPI_Enabled(Win) +ZMACRO_MSVCStaticLib_cpp(StreamRWCon_SSL_Win) + #include "zoolib/ZFunctionChain.h" #include "zoolib/ZMemory.h" #include "zoolib/ZStreamerRWCon_SSL.h" Modified: trunk/zoolib/source/cxx/zoolib/ZStreamRWCon_SSL_Win.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStreamRWCon_SSL_Win.h 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZStreamRWCon_SSL_Win.h 2010-04-03 18:22:43 UTC (rev 1232) @@ -27,6 +27,9 @@ #if ZCONFIG_SPI_Enabled(Win) +#include "zoolib/ZCompat_MSVCStaticLib.h" +ZMACRO_MSVCStaticLib_Reference(StreamRWCon_SSL_Win) + #include "zoolib/ZCompat_Win.h" #include <vector> Modified: trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.cpp 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.cpp 2010-04-03 18:22:43 UTC (rev 1232) @@ -22,6 +22,8 @@ #if ZCONFIG_API_Enabled(TextCoder_Win) +ZMACRO_MSVCStaticLib_cpp(TextCoder_Win) + #include "zoolib/ZFunctionChain.h" #include "zoolib/ZThread.h" #include "zoolib/ZUnicode.h" Modified: trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.h 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.h 2010-04-03 18:22:43 UTC (rev 1232) @@ -36,6 +36,9 @@ #if ZCONFIG_API_Enabled(TextCoder_Win) +#include "zoolib/ZCompat_MSVCStaticLib.h" +ZMACRO_MSVCStaticLib_Reference(TextCoder_Win) + #include "zoolib/ZCompat_Win.h" NAMESPACE_ZOOLIB_BEGIN Modified: trunk/zoolib/source/cxx/zoolib/ZUnicode_Normalize_Win.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUnicode_Normalize_Win.cpp 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZUnicode_Normalize_Win.cpp 2010-04-03 18:22:43 UTC (rev 1232) @@ -22,6 +22,8 @@ #if ZCONFIG_SPI_Enabled(Win) +ZMACRO_MSVCStaticLib_cpp(Unicode_Normalize_Win) + #include "zoolib/ZCompat_Win.h" #include "zoolib/ZFunctionChain.h" Modified: trunk/zoolib/source/cxx/zoolib/ZUnicode_Normalize_Win.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUnicode_Normalize_Win.h 2010-04-03 16:39:11 UTC (rev 1231) +++ trunk/zoolib/source/cxx/zoolib/ZUnicode_Normalize_Win.h 2010-04-03 18:22:43 UTC (rev 1232) @@ -23,4 +23,7 @@ #include "zconfig.h" #include "ZUnicode_Normalize.h" +#include "zoolib/ZCompat_MSVCStaticLib.h" +ZMACRO_MSVCStaticLib_Reference(Unicode_Normalize_Win) + #endif // __ZUnicode_Normalize_Win__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2010-04-06 19:12:55
|
Revision: 1244 http://zoolib.svn.sourceforge.net/zoolib/?rev=1244&view=rev Author: agreen Date: 2010-04-06 19:12:48 +0000 (Tue, 06 Apr 2010) Log Message: ----------- Whitespace -- get rid of extraneous double spaces. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTB.cpp trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTB.h trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTS.cpp trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTupleIndex_String.h trunk/zoolib/source/cxx/zoolib/ZAny.h trunk/zoolib/source/cxx/zoolib/ZAtomic.h trunk/zoolib/source/cxx/zoolib/ZBitStream.cpp trunk/zoolib/source/cxx/zoolib/ZDCPixmap.h trunk/zoolib/source/cxx/zoolib/ZDCPixmapCoder_GIF.cpp trunk/zoolib/source/cxx/zoolib/ZDCPixmapCoder_JPEGLib.cpp trunk/zoolib/source/cxx/zoolib/ZDCPixmapNS.h trunk/zoolib/source/cxx/zoolib/ZDList.h trunk/zoolib/source/cxx/zoolib/ZData_Any.h trunk/zoolib/source/cxx/zoolib/ZFile.cpp trunk/zoolib/source/cxx/zoolib/ZFile.h trunk/zoolib/source/cxx/zoolib/ZFile_Win.cpp trunk/zoolib/source/cxx/zoolib/ZGRgn.h trunk/zoolib/source/cxx/zoolib/ZGeom.h trunk/zoolib/source/cxx/zoolib/ZGeometry.h trunk/zoolib/source/cxx/zoolib/ZHTTP.cpp trunk/zoolib/source/cxx/zoolib/ZLog.h trunk/zoolib/source/cxx/zoolib/ZML.h trunk/zoolib/source/cxx/zoolib/ZNet_Internet_MacOT_OSX.cpp trunk/zoolib/source/cxx/zoolib/ZRegex.h trunk/zoolib/source/cxx/zoolib/ZStackCrawl.cpp trunk/zoolib/source/cxx/zoolib/ZStream_Buffered.cpp trunk/zoolib/source/cxx/zoolib/ZStream_LZW.h trunk/zoolib/source/cxx/zoolib/ZStream_POSIX.cpp trunk/zoolib/source/cxx/zoolib/ZStream_ZLib.cpp trunk/zoolib/source/cxx/zoolib/ZStrim.h trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.cpp trunk/zoolib/source/cxx/zoolib/ZTextCollator.h trunk/zoolib/source/cxx/zoolib/ZThread_Win.h trunk/zoolib/source/cxx/zoolib/ZTime.cpp trunk/zoolib/source/cxx/zoolib/ZTime.h trunk/zoolib/source/cxx/zoolib/ZTrail.h trunk/zoolib/source/cxx/zoolib/ZUtil_ATSUI.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_MacOSX.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_STL.h trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Tuple.h trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Val.cpp trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp trunk/zoolib/source/cxx/zoolib/zconfigl.h Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -341,7 +341,7 @@ { if (iName) { - theQ = sJoin(theQ, sAllID(sIDName, RelHead(*iName) | thePropName)); + theQ = sJoin(theQ, sAllID(sIDName, RelHead(*iName) | thePropName)); if (iVerbose) theQ = sProject(RelHead(*iName) | "$$Property_Name", theQ); else Modified: trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTB.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTB.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTB.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -294,7 +294,7 @@ We've already seen that a ZTBQuery can be initialized from a ZTBSpec, and a ZTBIter initialized from such a ZTBQuery will return all the tuples -that match the specification. The other simple instantiations of a ZTBQuery +that match the specification. The other simple instantiations of a ZTBQuery take an ID or a list of IDs in a \c vector, \c set or pointer and count. A ZTBIter initialized from one of the following queries would simply return the tuples with the specified IDs. Modified: trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTB.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTB.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTB.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -39,7 +39,7 @@ class ZTB { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTB, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTB, operator_bool_generator_type, operator_bool_type); public: ZTB() {} ZTB(ZRef<ZTBRep> iTBRep); @@ -127,7 +127,7 @@ class ZTBIter { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTBIter, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTBIter, operator_bool_generator_type, operator_bool_type); public: /** \name Constructors */ //@{ Modified: trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTS.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTS.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTS.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -34,7 +34,7 @@ needn't be physically stored. In addition a tuplestore allocates IDs, on demand it will return IDs that have never been -allocated before and never will again. This lets us add new data to a tuplestore without +allocated before and never will again. This lets us add new data to a tuplestore without overwriting IDs that have already been used. The class ZTS defines an API for reading and writing entries in a tuplestore. Generally though Modified: trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTupleIndex_String.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTupleIndex_String.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/more/zoolib/tuplebase/ZTupleIndex_String.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -63,11 +63,11 @@ class Compare { public: - typedef Key value_type; + typedef Key value_type; Compare(); - bool operator()(const value_type& iLeft, const value_type& iRight) const; + bool operator()(const value_type& iLeft, const value_type& iRight) const; ZTextCollator fTextCollator; }; Modified: trunk/zoolib/source/cxx/zoolib/ZAny.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZAny.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZAny.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -109,14 +109,14 @@ }; #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - public: // so ZAnyBaseCast can be non-friend + public: // so ZAnyBaseCast can be non-friend #else -private: - template<typename ValueType> - friend ValueType* ZAnyBaseCast(ZAnyBase*); + private: + template<typename ValueType> + friend ValueType* ZAnyBaseCast(ZAnyBase*); - template<typename ValueType> - friend const ValueType* ZAnyBaseCast(const ZAnyBase*); + template<typename ValueType> + friend const ValueType* ZAnyBaseCast(const ZAnyBase*); #endif placeholder* content; Modified: trunk/zoolib/source/cxx/zoolib/ZAtomic.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZAtomic.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZAtomic.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -136,7 +136,7 @@ "bne- 1b\n" "isync\n" : "=m" (iAtomic->fValue), "=&r" (oldValue) - : "r" (iAtomic), "r" (iOldValue), "r" (iNewValue) + : "r" (iAtomic), "r" (iOldValue), "r" (iNewValue) : "cc" ); return oldValue == iOldValue; Modified: trunk/zoolib/source/cxx/zoolib/ZBitStream.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZBitStream.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZBitStream.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -263,7 +263,7 @@ } if (oCountBytesWritten) - *oCountBytesWritten = localDest - static_cast<uint8*>(iDest); + *oCountBytesWritten = localDest - static_cast<uint8*>(iDest); } /// Flush the buffer by writing pending bits to \a iStream. @@ -362,7 +362,7 @@ } if (oCountBytesWritten) - *oCountBytesWritten = localDest - static_cast<uint8*>(iDest); + *oCountBytesWritten = localDest - static_cast<uint8*>(iDest); } /// Flush the buffer by writing pending bits to \a iStream. Modified: trunk/zoolib/source/cxx/zoolib/ZDCPixmap.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCPixmap.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZDCPixmap.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -45,7 +45,7 @@ class ZDCPixmap { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZDCPixmap, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZDCPixmap, operator_bool_generator_type, operator_bool_type); public: // The usual mantra: constructor, copy constructor, destructor, assignment Modified: trunk/zoolib/source/cxx/zoolib/ZDCPixmapCoder_GIF.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCPixmapCoder_GIF.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZDCPixmapCoder_GIF.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -440,7 +440,7 @@ // Skip any data blocks. StreamR_Chunk(iStream).SkipAll(); } - else if (blockType == ',') + else if (blockType == ',') { // It's an image. ZRect curBounds; Modified: trunk/zoolib/source/cxx/zoolib/ZDCPixmapCoder_JPEGLib.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCPixmapCoder_JPEGLib.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZDCPixmapCoder_JPEGLib.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -453,7 +453,7 @@ struct jpeg_decompress_struct theJDS; JPEGErrorMgr theEM(theJDS); - + theEM.BeforeCall(); ::jpeg_create_decompress(&theJDS); Modified: trunk/zoolib/source/cxx/zoolib/ZDCPixmapNS.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCPixmapNS.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZDCPixmapNS.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -376,7 +376,7 @@ static uint32 sConvert( uint32 iPixval, uint32 iMask, int32 iShift, uint32 iMultiplier, uint32 iAdd) { - return iAdd + (((iPixval & iMask) >> iShift) * iMultiplier); + return iAdd + (((iPixval & iMask) >> iShift) * iMultiplier); } void AsRGBA(uint32 iPixval, ZRGBA_POD& oColor) const @@ -422,7 +422,7 @@ static uint32 sConvert( uint32 iPixval, uint32 iMask, int32 iShift, uint32 iMultiplier, uint32 iAdd) { - return iAdd + (((iPixval & iMask) >> iShift) * iMultiplier); + return iAdd + (((iPixval & iMask) >> iShift) * iMultiplier); } void AsRGBA(uint32 iPixval, ZRGBA_POD& oColor) const Modified: trunk/zoolib/source/cxx/zoolib/ZDList.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDList.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZDList.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -37,8 +37,8 @@ template <typename L> struct DListHead { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T( - DListHead, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T( + DListHead, operator_bool_generator_type, operator_bool_type); DListHead() : fHeadL(nullptr), fSize(0) {} @@ -181,8 +181,8 @@ template <typename P, typename L> class DListIterator { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T( - DListIterator, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T( + DListIterator, operator_bool_generator_type, operator_bool_type); public: enum { kDebug = L::kDebug }; @@ -219,8 +219,8 @@ template <typename P, typename L> class DListIteratorEraseAll { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T( - DListIteratorEraseAll, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T( + DListIteratorEraseAll, operator_bool_generator_type, operator_bool_type); public: enum { kDebug = L::kDebug }; Modified: trunk/zoolib/source/cxx/zoolib/ZData_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZData_Any.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZData_Any.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -35,8 +35,8 @@ class ZData_Any { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZData_Any, - operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZData_Any, + operator_bool_generator_type, operator_bool_type); class Rep; public: Modified: trunk/zoolib/source/cxx/zoolib/ZFile.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZFile.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZFile.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -299,7 +299,7 @@ return string(); } -/** \brief Return a native textual representation of the path that would +/** \brief Return a native textual representation of the path that would be passed to the file system to access this node. */ /** The representation will be in the syntax used by the underlying API. @@ -498,7 +498,7 @@ return ZFileSpec(); } -/** \brief Move the entity in the file system referenced by +/** \brief Move the entity in the file system referenced by the file spec to the location referenced by \a iDest. */ ZFileSpec ZFileSpec::MoveTo(const ZFileSpec& iDest, ZFile::Error* oError) const { Modified: trunk/zoolib/source/cxx/zoolib/ZFile.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZFile.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZFile.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -75,7 +75,7 @@ class ZFileSpec { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZFileSpec, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZFileSpec, operator_bool_generator_type, operator_bool_type); public: typedef ZFile::Error Error; @@ -179,7 +179,7 @@ class ZFileIter { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZFileIter, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZFileIter, operator_bool_generator_type, operator_bool_type); public: ZFileIter(); ZFileIter(const ZFileIter& iOther); @@ -204,7 +204,7 @@ class ZFileTreeIter { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES( + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES( ZFileTreeIter, operator_bool_generator_type, operator_bool_type); public: ZFileTreeIter(); Modified: trunk/zoolib/source/cxx/zoolib/ZFile_Win.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZFile_Win.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZFile_Win.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -484,7 +484,7 @@ // Subtract the number of seconds between 1601 and 1970. result -= ZTime::kEpochDelta_1601_To_1970; - return result; + return result; } // ================================================================================================= Modified: trunk/zoolib/source/cxx/zoolib/ZGRgn.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZGRgn.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZGRgn.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -99,7 +99,7 @@ ZRef<ZGRgnRep> fRep; public: - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZGRgn, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZGRgn, operator_bool_generator_type, operator_bool_type); operator operator_bool_type() const { return operator_bool_generator_type::translate(fRep && !fRep->IsEmpty()); } Modified: trunk/zoolib/source/cxx/zoolib/ZGeom.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZGeom.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZGeom.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -50,8 +50,8 @@ class ZPoint_T { public: - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZPoint_T<T>, - operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZPoint_T<T>, + operator_bool_generator_type, operator_bool_type); operator operator_bool_type() const { return operator_bool_generator_type::translate(h || v); } @@ -219,8 +219,8 @@ class ZRect_T { public: - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZRect_T<T>, - operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZRect_T<T>, + operator_bool_generator_type, operator_bool_type); operator operator_bool_type() const { return operator_bool_generator_type::translate(left < right && top < bottom); } Modified: trunk/zoolib/source/cxx/zoolib/ZGeometry.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZGeometry.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZGeometry.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -69,8 +69,8 @@ class ZGPointPOD_T { public: - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZGPointPOD_T<T>, - operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZGPointPOD_T<T>, + operator_bool_generator_type, operator_bool_type); operator operator_bool_type() const { return operator_bool_generator_type::translate(x || y); } @@ -218,8 +218,8 @@ class ZGExtentPOD_T { public: - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZGExtentPOD_T<T>, - operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZGExtentPOD_T<T>, + operator_bool_generator_type, operator_bool_type); operator operator_bool_type() const { return operator_bool_generator_type::translate(h || v); } @@ -373,8 +373,8 @@ class ZGRectPOD_T { public: - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZGRectPOD_T<T>, - operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES_T(ZGRectPOD_T<T>, + operator_bool_generator_type, operator_bool_type); operator operator_bool_type() const { return operator_bool_generator_type::translate(extent); } Modified: trunk/zoolib/source/cxx/zoolib/ZHTTP.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZHTTP.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZHTTP.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -896,7 +896,7 @@ /* There are three basic forms for a range request, which we encode as a tuple with a form as follows: -bytes=x-y { begin = int64(x); end = int64(y); } // (x to y inclusive) +bytes=x-y { begin = int64(x); end = int64(y); } // (x to y inclusive) bytes=x- { begin = int64(x); } // (x to the end) bytes=-y { last = int64(y); } // (last y) */ Modified: trunk/zoolib/source/cxx/zoolib/ZLog.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZLog.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZLog.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -60,7 +60,7 @@ { ePriority_Emerg = 0, ///< System on fire? ePriority_Alert = 1, ///< action must be taken immediately - ePriority_Crit = 2, ///< critical conditions + ePriority_Crit = 2, ///< critical conditions ePriority_Err = 3, ///< error conditions ePriority_Warning = 4,///< warning conditions ePriority_Notice = 5, ///< normal but significant condition @@ -90,7 +90,7 @@ class StrimW : public ZStrimW { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(StrimW, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(StrimW, operator_bool_generator_type, operator_bool_type); public: StrimW(EPriority iPriority, const std::string& iName); StrimW(EPriority iPriority, const char* iName); Modified: trunk/zoolib/source/cxx/zoolib/ZML.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZML.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZML.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -66,7 +66,7 @@ : public ZStrimU , NonCopyable { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(StrimU, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(StrimU, operator_bool_generator_type, operator_bool_type); public: StrimU(const ZStrimU& iStrim); StrimU(const ZStrimU& iStrim, bool iRecognizeEntitiesInAttributeValues); Modified: trunk/zoolib/source/cxx/zoolib/ZNet_Internet_MacOT_OSX.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZNet_Internet_MacOT_OSX.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZNet_Internet_MacOT_OSX.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -496,7 +496,7 @@ OTResult look = ::OTLook(listener); // Only two async events should be able to cause Accept to "look", namely - // T_LISTEN and T_DISCONNECT. However, the "tilisten" module prevents + // T_LISTEN and T_DISCONNECT. However, the "tilisten" module prevents // further connection attempts coming up while we're still thinking about // this one, so the only event that should come up is T_DISCONNECT. @@ -504,8 +504,8 @@ if (look == T_DISCONNECT) { // If we get a T_DISCONNECT, it should be for the current pending - // connection attempt. We receive the disconnect info and check - // the sequence number against that in the call. If they match, + // connection attempt. We receive the disconnect info and check + // the sequence number against that in the call. If they match, // the connection attempt disappeared and we return kOTNoDataErr. // If they don't match, that's weird. Modified: trunk/zoolib/source/cxx/zoolib/ZRegex.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZRegex.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZRegex.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -48,7 +48,7 @@ class ZRegex { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZRegex, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZRegex, operator_bool_generator_type, operator_bool_type); public: ZRegex(); ZRegex(const ZRegex& iOther); Modified: trunk/zoolib/source/cxx/zoolib/ZStackCrawl.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStackCrawl.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZStackCrawl.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -180,11 +180,11 @@ bool inited2 = ::SymLoadModule( currentProcess, // process handle - nullptr, // file handle + nullptr, // file handle moduleFileName, // path to exe - nullptr, // module name - 0, // load address - 0); // module size + nullptr, // module name + 0, // load address + 0); // module size spInited = true; } Modified: trunk/zoolib/source/cxx/zoolib/ZStream_Buffered.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStream_Buffered.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZStream_Buffered.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -98,7 +98,7 @@ else { // We're asking for less data than the stream guarantees it could provide without - // blocking, in which case we fill up as much of our buffer as we can, so some + // blocking, in which case we fill up as much of our buffer as we can, so some // later request will be able to be satisfied straight from our buffer. size_t countToRead = min(fBufferSize, countReadable); size_t countRead; Modified: trunk/zoolib/source/cxx/zoolib/ZStream_LZW.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStream_LZW.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZStream_LZW.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -163,7 +163,7 @@ uint16 fPendingPrefix; - bool fFresh; + bool fFresh; ZBitWriterBE fBitWriter; }; Modified: trunk/zoolib/source/cxx/zoolib/ZStream_POSIX.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStream_POSIX.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZStream_POSIX.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -45,7 +45,7 @@ { while (iCount) { - size_t countRead = fread(localDest, 1, iCount, iFILE); + size_t countRead = fread(localDest, 1, iCount, iFILE); if (countRead == 0) break; iCount -= countRead; Modified: trunk/zoolib/source/cxx/zoolib/ZStream_ZLib.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStream_ZLib.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZStream_ZLib.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -145,7 +145,7 @@ case ZStream_ZLib::eFormatR_Raw: windowBits = -15; break; } - int error = inflateInit2(&fState, windowBits); + int error = inflateInit2(&fState, windowBits); if (Z_OK != error) throw runtime_error("ZStreamR_ZLibDecode problem"); } Modified: trunk/zoolib/source/cxx/zoolib/ZStrim.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZStrim.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZStrim.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -360,7 +360,7 @@ /** A derivation of ZStrimW that provides implementations of ZStrimW::Imp_WriteUTF16 and ZStrimW::Imp_WriteUTF8 that call through to ZStrimW::Imp_WriteUTF32, which must be implemented -by subclasses. We redeclare ZStrimW::Imp_WriteUTF32 as pure virtual for emphasis. +by subclasses. We redeclare ZStrimW::Imp_WriteUTF32 as pure virtual for emphasis. */ class ZStrimW_NativeUTF32 : public ZStrimW @@ -378,7 +378,7 @@ /** A derivation of ZStrimW that provides implementations of ZStrimW::Imp_WriteUTF32 and ZStrimW::Imp_WriteUTF8 that call through to ZStrimW::Imp_WriteUTF16, which must be implemented -by subclasses. We redeclare ZStrimW::Imp_WriteUTF16 as pure virtual for emphasis. +by subclasses. We redeclare ZStrimW::Imp_WriteUTF16 as pure virtual for emphasis. */ class ZStrimW_NativeUTF16 : public ZStrimW @@ -396,7 +396,7 @@ /** A derivation of ZStrimW that provides implementations of ZStrimW::Imp_WriteUTF32 and ZStrimW::Imp_WriteUTF16 that call through to ZStrimW::Imp_WriteUTF8, which must be implemented -by subclasses. We redeclare ZStrimW::Imp_WriteUTF8 as pure virtual for emphasis. +by subclasses. We redeclare ZStrimW::Imp_WriteUTF8 as pure virtual for emphasis. */ class ZStrimW_NativeUTF8 : public ZStrimW Modified: trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZTextCoder_Win.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -149,7 +149,7 @@ { "ibm870", 870, 2055 }, // IBM EBCDIC - Multilingual/ROECE (Latin-2) // { "ibm874", 874, -1 }, // ANSI/OEM - Thai (same as CP28605, ISO 8859-15) <--- Not true? { "ibm949", 949, -1 }, // ANSI/OEM - Korean (Unified Hangeul Code) - { "ibm950", 950, -1 }, // ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC) + { "ibm950", 950, -1 }, // ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC) { "macintosh", 10000, 2027 }, // MAC - Roman { "x-mac-japanese", 10001, -1 }, Modified: trunk/zoolib/source/cxx/zoolib/ZTextCollator.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTextCollator.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZTextCollator.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -38,8 +38,8 @@ class ZTextCollator { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTextCollator, - operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTextCollator, + operator_bool_generator_type, operator_bool_type); public: ZTextCollator(); ZTextCollator(const ZTextCollator& iOther); @@ -105,8 +105,8 @@ class ZTextCollationKey { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTextCollationKey, - operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTextCollationKey, + operator_bool_generator_type, operator_bool_type); public: ZTextCollationKey(); ZTextCollationKey(const ZTextCollationKey& iOther); Modified: trunk/zoolib/source/cxx/zoolib/ZThread_Win.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZThread_Win.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZThread_Win.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -92,10 +92,10 @@ { void* DebugInfo; long LockCount; - long RecursionCount; - void* OwningThread; - void* LockSemaphore; - void* SpinCount; + long RecursionCount; + void* OwningThread; + void* LockSemaphore; + void* SpinCount; }; Dummy_CRITICAL_SECTION fCRITICAL_SECTION; Modified: trunk/zoolib/source/cxx/zoolib/ZTime.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTime.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZTime.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -155,7 +155,7 @@ // Subtract the number of seconds between 1601 and 1970. result -= kEpochDelta_1601_To_1970; - return result; + return result; #else Modified: trunk/zoolib/source/cxx/zoolib/ZTime.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTime.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZTime.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -34,7 +34,7 @@ class ZTime { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTime, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTime, operator_bool_generator_type, operator_bool_type); public: ZTime(); Modified: trunk/zoolib/source/cxx/zoolib/ZTrail.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTrail.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZTrail.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -36,7 +36,7 @@ class ZTrail { - ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTrail, operator_bool_generator_type, operator_bool_type); + ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTrail, operator_bool_generator_type, operator_bool_type); public: operator operator_bool_type() const; Modified: trunk/zoolib/source/cxx/zoolib/ZUtil_ATSUI.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_ATSUI.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_ATSUI.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -44,7 +44,7 @@ if (iFontSize > 0) atsuSize = iFontSize * 65536.0; - ATSUFontID theATSUFontID; + ATSUFontID theATSUFontID; string fontName = iFont.GetName(); if (noErr != ::ATSUFindFontFromName((char*)fontName.data(), fontName.size(), kFontFullName, kFontMacintoshPlatform, @@ -108,11 +108,11 @@ if (!iStyle) return nullptr; - if (!iTextLength) - return nullptr; + if (!iTextLength) + return nullptr; UniCharCount runLengths = kATSUToTextEnd; - ATSUTextLayout theLayout = nullptr; + ATSUTextLayout theLayout = nullptr; ::ATSUCreateTextLayoutWithTextPtr((ConstUniCharArrayPtr)iText, kATSUFromTextBeginning, kATSUToTextEnd, iTextLength, Modified: trunk/zoolib/source/cxx/zoolib/ZUtil_MacOSX.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_MacOSX.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_MacOSX.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -64,7 +64,7 @@ *localFuncs = localDest++; } - ::MakeDataExecutable(&ioStorage[0], ioStorage.size()); + ::MakeDataExecutable(&ioStorage[0], ioStorage.size()); } NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/zoolib/ZUtil_STL.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_STL.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_STL.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -142,7 +142,7 @@ } -/** If ioSet contains iElement then it is removed and true returned. +/** If ioSet contains iElement then it is removed and true returned. Otherwise no change is made to ioSet and false is returned. */ template <typename T> bool sEraseIfContains(std::set<T>& ioSet, T iElement) Modified: trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Tuple.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Tuple.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_Tuple.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -46,7 +46,7 @@ bool sFromStrim(const ZStrimU& iStrimU, ZTValue& oTV); -} // namespace ZUtil_Strim_Tuple +} // namespace ZUtil_Strim_Tuple // ================================================================================================= #pragma mark - Modified: trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -1330,7 +1330,7 @@ case eZType_Int32: return sCompare_T(fData.fAs_Int32, iOther.fData.fAs_Int32); case eZType_Int64: return sCompare_T(fData.fAs_Int64, iOther.fData.fAs_Int64); case eZType_Bool: return sCompare_T(fData.fAs_Bool, iOther.fData.fAs_Bool); - case eZType_Float: return sCompare_T(fData.fAs_Float, iOther.fData.fAs_Float); + case eZType_Float: return sCompare_T(fData.fAs_Float, iOther.fData.fAs_Float); case eZType_Double: return sCompare_T(fData.fAs_Double, iOther.fData.fAs_Double); case eZType_Time: return sCompare_T(fData.fAs_Time, iOther.fData.fAs_Time); case eZType_Pointer: return sCompare_T(fData.fAs_Pointer, iOther.fData.fAs_Pointer); Modified: trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Val.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Val.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Val.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -46,7 +46,7 @@ nullptr, // lpReserved, oCountKeys, oMaxLengthKeyName, - nullptr, // lpcMaxClassLen, + nullptr, // lpcMaxClassLen, oCountValues, oMaxLengthValueName, nullptr, // lpcMaxValueLen, Modified: trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp 2010-04-06 19:12:48 UTC (rev 1244) @@ -35,42 +35,42 @@ ZMap is isomorphic to JSON's object, ZSeq to JSON's array, and strings, booleans and null translate back and forth without trouble. JSON's only other primitive is -the number, whereas ZVal_ZooLib explicitly stores and retrieves integers of different sizes, +the number, whereas ZVal explicitly stores and retrieves integers of different sizes, floats and doubles, raw bytes and other composite types. -ZYad_JSON writes all ZVal_ZooLib number types as JSON numbers. When reading, JSON numbers +ZYad_JSON writes all ZVal number types as JSON numbers. When reading, JSON numbers are stored as int64s, unless the mantissa has a fractional component or exceeds 2^64, or if there is an exponent,in which case a double is used. The mappings are as follows: - + <pre> -JSON ZVal_ZooLib +JSON ZVal ---- ------- null null -object ZMap_ZooLib -array ZSeq_ZooLib +object ZMap +array ZSeq boolean bool string string number int64 or double -ZVal_ZooLib JSON -------- ---- -null null -ZMap_ZooLib object -ZSeq_ZooLib array -bool boolean -string string -int8 number -int16 number -int32 number -int64 number -float number -double number -uint64 (ID) number -time number +ZVal JSON +---- ---- +null null +ZMap object +ZSeq array +bool boolean +string string +int8 number +int16 number +int32 number +int64 number +float number +double number +uint64 (ID) number +time number all other types are written as nulls in maps and lists if the appropriate preserve flag is passed, otherwise they are skipped. Modified: trunk/zoolib/source/cxx/zoolib/zconfigl.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/zconfigl.h 2010-04-06 18:12:39 UTC (rev 1243) +++ trunk/zoolib/source/cxx/zoolib/zconfigl.h 2010-04-06 19:12:48 UTC (rev 1244) @@ -156,7 +156,7 @@ #endif // The second define is ZCONFIG_Debug, which takes its value from ZCONFIG_DebugLevel if we're doing -// a SYM build, otherwise it is set to 0. You can override ZCONFIG_Debug by setting its value in +// a SYM build, otherwise it is set to 0. You can override ZCONFIG_Debug by setting its value in // your zconfig.h before including this file. // With XCode we could base debug off !__OPTIMIZE__ #ifndef ZCONFIG_Debug This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2010-04-07 21:34:57
|
Revision: 1254 http://zoolib.svn.sourceforge.net/zoolib/?rev=1254&view=rev Author: agreen Date: 2010-04-07 21:34:51 +0000 (Wed, 07 Apr 2010) Log Message: ----------- Change sMakeYadR return type to be an RPos if possible. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Yad.cpp trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Yad.h trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.cpp trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.h trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Concrete.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Concrete.h trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Yad.cpp trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Yad.h trunk/zoolib/source/cxx/zoolib/ZYad_Any.cpp trunk/zoolib/source/cxx/zoolib/ZYad_Any.h trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.cpp trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.h trunk/zoolib/source/cxx/zoolib/ZYad_CFType.cpp trunk/zoolib/source/cxx/zoolib/ZYad_CFType.h trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp trunk/zoolib/source/cxx/zoolib/ZYad_NS.h trunk/zoolib/source/cxx/zoolib/ZYad_NS.mm trunk/zoolib/source/cxx/zoolib/ZYad_Simple.cpp trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.cpp trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.h Modified: trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Yad.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Yad.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Yad.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -125,10 +125,10 @@ return new ZYadPrimR_Any(iVal.AsAny()); } -ZRef<ZYadSeqR> sMakeYadR(const Seq& iSeq) +ZRef<ZYadSeqRPos> sMakeYadR(const Seq& iSeq) { return new YadSeqRPos(iSeq); } -ZRef<ZYadMapR> sMakeYadR(const Map& iMap) +ZRef<ZYadMapRPos> sMakeYadR(const Map& iMap) { return new YadMapRPos(iMap); } } // namespace ZPhotoshop Modified: trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Yad.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Yad.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Yad.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -37,9 +37,9 @@ ZRef<ZYadR> sMakeYadR(const Val& iVal); -ZRef<ZYadSeqR> sMakeYadR(const Seq& iSeq); +ZRef<ZYadSeqRPos> sMakeYadR(const Seq& iSeq); -ZRef<ZYadMapR> sMakeYadR(const Map& iMap); +ZRef<ZYadMapRPos> sMakeYadR(const Map& iMap); } // namespace ZPhotoshop Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -460,12 +460,13 @@ s2.Append(aMap); } - ZRef<ZYadSeqR> yad1 = sMakeYadR(s1).DynamicCast<ZYadSeqR>(); - ZRef<ZYadSeqR> yad2 = sMakeYadR(s2).DynamicCast<ZYadSeqR>(); + ZRef<ZYadSeqR> yad1 = sMakeYadR(s1); + ZRef<ZYadSeqR> yad2 = sMakeYadR(s2); - Expr_Relation thePhys1 = ZValBase_YadSeqR::sRelation(yad1); - Expr_Relation thePhys2 = ZValBase_YadSeqR::sRelation(yad2); + Expr_Concrete thePhys1 = ZValBase_YadSeqR::sConcrete(yad1); + Expr_Concrete thePhys2 = ZValBase_YadSeqR::sConcrete(yad2); +// Expr_Relation sect = sJoin(thePhys1, thePhys2); Expr_Relation sect = thePhys1 * thePhys2; ZRef<ZQE::Iterator> theIterator = ZValBase_YadSeqR::sIterator(sect); @@ -528,9 +529,7 @@ s.Writef("\nElapsed, read: %gms\n", 1000.0 * (ZTime::sNow() - start)); start = ZTime::sNow(); - Expr_Relation thePhys = ZValBase_YadSeqR::sRelation(theYadSeqR); -// Expr_Relation thePhys(new ZValBase_YadSeqRPos::ExprRep_Concrete(sMakeYadR(theSeq).DynamicCast<ZYadSeqRPos>())); -// Expr_Relation thePhys(new ZValBase_Any::ExprRep_Concrete(theSeq)); + Expr_Relation thePhys = ZValBase_YadSeqR::sConcrete(theYadSeqR); thePhys = thePhys & theCondition; thePhys = thePhys & thePhys; @@ -568,23 +567,6 @@ theYadSeqR->SkipAll(); // ZYad_ZooLibStrim::sToStrim(0, theYadOptions, theYadSeqR, s); } -#elif 0 - if (theYadSeqR) - { - for (;;) - { - ZRef<ZYadR> inner = theYadSeqR->ReadInc(); - if (!inner) - break; - ZVal_Any theVal = sFromYadR(ZVal_Any(), inner); - - if (sMatches(theCondition, theVal)) - { -// ZYad_ZooLibStrim::sToStrim(0, theYadOptions, sMakeYadR(theVal), s); -// s << "\n"; - } - } - } #endif s.Writef("\nElapsed: %gms\n", 1000.0 * (ZTime::sNow() - start)); } Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -166,11 +166,11 @@ #pragma mark - #pragma mark * ZValBase_YadSeqR pseudo constructors -ZQL::Expr_Relation sRelation(ZRef<ZYadSeqR> iYadSeqR) +ZQL::Expr_Concrete sConcrete(ZRef<ZYadSeqR> iYadSeqR) { // Could do a dynamic cast on iYadSeqR to see if it's really a ZYadSeqRPos, // in which case returning a ZValBase_YadSeqRPos::Iterator would be a win. - return ZQL::Expr_Relation(new ExprRep_Concrete(iYadSeqR)); + return ZQL::Expr_Concrete(new ExprRep_Concrete(iYadSeqR)); } ZRef<ZQE::Iterator> sIterator(ZRef<ZQL::ExprRep_Relation> iExprRep) Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -24,7 +24,7 @@ #include "zoolib/ZYad.h" #include "zoolib/zqe/ZQE_Iterator.h" -#include "zoolib/zql/ZQL_Expr_Relation.h" +#include "zoolib/zql/ZQL_Expr_Concrete.h" NAMESPACE_ZOOLIB_BEGIN namespace ZValBase_YadSeqR { @@ -33,7 +33,8 @@ #pragma mark - #pragma mark * ZValBase_YadSeqR pseudo constructors -ZQL::Expr_Relation sRelation(ZRef<ZYadSeqR> iYadSeqR); +ZQL::Expr_Concrete sConcrete(ZRef<ZYadSeqR> iYadSeqR); + ZRef<ZQE::Iterator> sIterator(ZRef<ZQL::ExprRep_Relation> iExprRep); } // namespace ZValBase_YadSeqR Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -145,8 +145,8 @@ #pragma mark - #pragma mark * ZValBase_YadSeqRPos pseudo constructors -ZQL::Expr_Relation sRelation(ZRef<ZYadSeqRPos> iYadSeqRPos) - { return ZQL::Expr_Relation(new ExprRep_Concrete(iYadSeqRPos)); } +ZQL::Expr_Concrete sConcrete(ZRef<ZYadSeqRPos> iYadSeqRPos) + { return ZQL::Expr_Concrete(new ExprRep_Concrete(iYadSeqRPos)); } ZRef<ZQE::Iterator> sIterator(ZRef<ZQL::ExprRep_Relation> iExprRep) { return Visitor_ExprRep_Concrete_MakeIterator().MakeIterator(iExprRep); } Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -24,7 +24,7 @@ #include "zoolib/ZYad.h" #include "zoolib/zqe/ZQE_Iterator.h" -#include "zoolib/zql/ZQL_Expr_Relation.h" +#include "zoolib/zql/ZQL_Expr_Concrete.h" NAMESPACE_ZOOLIB_BEGIN namespace ZValBase_YadSeqRPos { @@ -33,7 +33,8 @@ #pragma mark - #pragma mark * ZValBase_YadSeqRPos pseudo constructors -ZQL::Expr_Relation sRelation(ZRef<ZYadSeqRPos> iYadSeqRPos); +ZQL::Expr_Concrete sConcrete(ZRef<ZYadSeqRPos> iYadSeqRPos); + ZRef<ZQE::Iterator> sIterator(ZRef<ZQL::ExprRep_Relation> iExprRep); } // namespace ZValBase_YadSeqRPos Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Concrete.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Concrete.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Concrete.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -53,5 +53,32 @@ bool Visitor_ExprRep_Concrete::Visit_Concrete(ZRef<ExprRep_Concrete> iRep) { return Visitor_ExprRep_Relation::Visit_ExprRep(iRep); } +// ================================================================================================= +#pragma mark - +#pragma mark * Expr_Concrete + +Expr_Concrete::Expr_Concrete() + {} + +Expr_Concrete::Expr_Concrete(const Expr_Concrete& iOther) +: inherited(iOther) + {} + +Expr_Concrete::~Expr_Concrete() + {} + +Expr_Concrete& Expr_Concrete::operator=(const Expr_Concrete& iOther) + { + inherited::operator=(iOther); + return *this; + } + +Expr_Concrete::Expr_Concrete(const ZRef<ExprRep_Concrete>& iRep) +: inherited(iRep) + {} + +Expr_Concrete::operator ZRef<ExprRep_Concrete>() const + { return this->StaticCast<ExprRep_Concrete>(); } + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Concrete.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Concrete.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Concrete.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -53,6 +53,28 @@ virtual bool Visit_Concrete(ZRef<ExprRep_Concrete> iRep); }; +// ================================================================================================= +#pragma mark - +#pragma mark * Expr_Concrete + +class Expr_Concrete : public Expr_Relation + { + typedef Expr_Relation inherited; + + Expr_Concrete operator=(const Expr_Relation&); + Expr_Concrete operator=(const ZRef<ExprRep_Relation>&); + +public: + Expr_Concrete(); + Expr_Concrete(const Expr_Concrete& iOther); + ~Expr_Concrete(); + Expr_Concrete& operator=(const Expr_Concrete& iOther); + + Expr_Concrete(const ZRef<ExprRep_Concrete>& iRep); + + operator ZRef<ExprRep_Concrete>() const; + }; + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Yad.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Yad.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Yad.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -40,12 +40,12 @@ return sMakeYadR(*theVal); if (const string16* theVal = iVal.PGet_T<string16>()) - return sMakeYadR(ZAny(ZUnicode::sAsUTF8(*theVal))); + return sMakeYadR(ZUnicode::sAsUTF8(*theVal)); return sMakeYadR(iVal.AsAny()); } -ZRef<ZYadMapR> sMakeYadR(const KeyRef& iKeyRef) +ZRef<ZYadMapRPos> sMakeYadR(const KeyRef& iKeyRef) { return new ZYadMapRPos_Val_T<KeyRef>(iKeyRef); } } // namespace ZWinRegistry Modified: trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Yad.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Yad.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Yad.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -39,7 +39,7 @@ ZRef<ZYadR> sMakeYadR(const Val& iVal); -ZRef<ZYadMapR> sMakeYadR(const KeyRef& iKeyRef); +ZRef<ZYadMapRPos> sMakeYadR(const KeyRef& iKeyRef); } // namespace ZWinRegistry Modified: trunk/zoolib/source/cxx/zoolib/ZYad_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_Any.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_Any.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -35,7 +35,7 @@ return sMakeYadR(*theVal); if (const ZData_Any* theVal = iVal.PGet_T<ZData_Any>()) - return new ZYadStreamRPos_Any(*theVal); + return sMakeYadR(*theVal); if (const ZSeq_Any* theVal = iVal.PGet_T<ZSeq_Any>()) return sMakeYadR(*theVal); @@ -49,10 +49,10 @@ ZRef<ZYadStreamR> sMakeYadR(const ZData_Any& iData) { return new ZYadStreamRPos_Any(iData); } -ZRef<ZYadSeqR> sMakeYadR(const ZSeq_Any& iSeq) +ZRef<ZYadSeqRPos> sMakeYadR(const ZSeq_Any& iSeq) { return new ZYadSeqRPos_Any(iSeq); } -ZRef<ZYadMapR> sMakeYadR(const ZMap_Any& iMap) +ZRef<ZYadMapRPos> sMakeYadR(const ZMap_Any& iMap) { return new ZYadMapRPos_Any(iMap); } // ================================================================================================= @@ -73,6 +73,10 @@ virtual bool Visit_YadSeqR(ZRef<ZYadSeqR> iYadSeqR); virtual bool Visit_YadMapR(ZRef<ZYadMapR> iYadMapR); +// Our protocol + ZVal_Any GetVal(ZRef<ZYadR> iYadR); + +private: bool fRepeatedPropsAsSeq; const ZVal_Any& fDefault; ZVal_Any fOutput; @@ -100,9 +104,7 @@ if (ZRef<ZYadSeqRPos_Any> asSeq = iYadR.DynamicCast<ZYadSeqRPos_Any>()) return asSeq->GetSeq(); - Visitor_Yad_GetVal_Any theVisitor(iRepeatedPropsAsSeq, iDefault); - iYadR->Accept(theVisitor); - return theVisitor.fOutput; + return Visitor_Yad_GetVal_Any(iRepeatedPropsAsSeq, iDefault).GetVal(iYadR); } Visitor_Yad_GetVal_Any::Visitor_Yad_GetVal_Any(bool iRepeatedPropsAsSeq, const ZVal_Any& iDefault) @@ -133,7 +135,7 @@ ZSeq_Any theSeq; while (ZRef<ZYadR> theChild = iYadSeqR->ReadInc()) - theSeq.Append(sFromYadR(fDefault, theChild)); + theSeq.Append(this->GetVal(theChild)); fOutput = theSeq; return true; @@ -146,7 +148,7 @@ string theName; while (ZRef<ZYadR> theChild = iYadMapR->ReadInc(theName)) { - ZVal_Any theVal = sFromYadR(fRepeatedPropsAsSeq, fDefault, theChild); + ZVal_Any theVal = this->GetVal(theChild); if (fRepeatedPropsAsSeq) { if (ZVal_Any* prior = theMap.PGet(theName)) @@ -169,4 +171,15 @@ return true; } +ZVal_Any Visitor_Yad_GetVal_Any::GetVal(ZRef<ZYadR> iYadR) + { + ZVal_Any result; + if (iYadR) + { + iYadR->Accept(*this); + std::swap(result, fOutput); + } + return result; + } + NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/zoolib/ZYad_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_Any.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_Any.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -39,9 +39,9 @@ ZRef<ZYadStreamR> sMakeYadR(const ZData_Any& iData); -ZRef<ZYadSeqR> sMakeYadR(const ZSeq_Any& iSeq); +ZRef<ZYadSeqRPos> sMakeYadR(const ZSeq_Any& iSeq); -ZRef<ZYadMapR> sMakeYadR(const ZMap_Any& iMap); +ZRef<ZYadMapRPos> sMakeYadR(const ZMap_Any& iMap); // ================================================================================================= #pragma mark - Modified: trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -70,10 +70,10 @@ return new ZYadMapRPos_Any(spAsMap(iVal)); } -ZRef<ZYadSeqR> sMakeYadR(const ZSeq_AppleEvent& iSeq) +ZRef<ZYadSeqRPos> sMakeYadR(const ZSeq_AppleEvent& iSeq) { return new ZYadSeqRPos_AppleEvent(iSeq); } -ZRef<ZYadMapR> sMakeYadR(const ZMap_AppleEvent& iMap) +ZRef<ZYadMapRPos> sMakeYadR(const ZMap_AppleEvent& iMap) { return new ZYadMapRPos_AppleEvent(iMap); } NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -40,9 +40,9 @@ ZRef<ZYadR> sMakeYadR(const ZVal_AppleEvent& iVal); -ZRef<ZYadSeqR> sMakeYadR(const ZSeq_AppleEvent& iSeq); +ZRef<ZYadSeqRPos> sMakeYadR(const ZSeq_AppleEvent& iSeq); -ZRef<ZYadMapR> sMakeYadR(const ZMap_AppleEvent& iMap); +ZRef<ZYadMapRPos> sMakeYadR(const ZMap_AppleEvent& iMap); NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/zoolib/ZYad_CFType.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_CFType.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_CFType.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -188,16 +188,16 @@ ZRef<ZYadStreamR> sMakeYadR(const ZRef<CFDataRef>& iData) { return new ZYadStreamRPos_CFType(iData); } -ZRef<ZYadSeqR> sMakeYadR(const ZRef<CFMutableArrayRef>& iArray) +ZRef<ZYadSeqRPos> sMakeYadR(const ZRef<CFMutableArrayRef>& iArray) { return new ZYadSeqRPos_CFType(iArray); } -ZRef<ZYadSeqR> sMakeYadR(const ZRef<CFArrayRef>& iArray) +ZRef<ZYadSeqRPos> sMakeYadR(const ZRef<CFArrayRef>& iArray) { return new ZYadSeqRPos_CFType(iArray); } -ZRef<ZYadMapR> sMakeYadR(const ZRef<CFMutableDictionaryRef>& iDictionary) +ZRef<ZYadMapRPos> sMakeYadR(const ZRef<CFMutableDictionaryRef>& iDictionary) { return new ZYadMapRPos_CFType(iDictionary); } -ZRef<ZYadMapR> sMakeYadR(const ZRef<CFDictionaryRef>& iDictionary) +ZRef<ZYadMapRPos> sMakeYadR(const ZRef<CFDictionaryRef>& iDictionary) { return new ZYadMapRPos_CFType(iDictionary); } // ================================================================================================= @@ -218,6 +218,10 @@ virtual bool Visit_YadSeqR(ZRef<ZYadSeqR> iYadSeqR); virtual bool Visit_YadMapR(ZRef<ZYadMapR> iYadMapR); +// Our protocol + ZRef<CFTypeRef> GetCFTypeRef(ZRef<ZYadR> iYadR); + +private: ZRef<CFTypeRef> fDefault; ZRef<CFTypeRef> fOutput; }; @@ -229,9 +233,7 @@ if (ZRef<ZYadR_CFType> theYadR = ZRefDynamicCast<ZYadR_CFType>(iYadR)) return theYadR->GetVal(); - Visitor_Yad_GetVal_CFType theVisitor(iDefault); - iYadR->Accept(theVisitor); - return theVisitor.fOutput; + return Visitor_Yad_GetVal_CFType(iDefault).GetCFTypeRef(iYadR); } Visitor_Yad_GetVal_CFType::Visitor_Yad_GetVal_CFType(ZRef<CFTypeRef> iDefault) @@ -263,7 +265,7 @@ ZSeq_CFType theSeq; while (ZRef<ZYadR> theChild = iYadSeqR->ReadInc()) - theSeq.Append(sFromYadR(fDefault, theChild)); + theSeq.Append(this->GetCFTypeRef(theChild)); fOutput = theSeq; return true; @@ -275,12 +277,23 @@ string theName; while (ZRef<ZYadR> theChild = iYadMapR->ReadInc(theName)) - theMap.Set(theName, sFromYadR(fDefault, theChild)); + theMap.Set(theName, this->GetCFTypeRef(theChild)); fOutput = theMap; return true; } +ZRef<CFTypeRef> Visitor_Yad_GetVal_CFType::GetCFTypeRef(ZRef<ZYadR> iYadR) + { + ZRef<CFTypeRef> result; + if (iYadR) + { + iYadR->Accept(*this); + std::swap(result, fOutput); + } + return result; + } + NAMESPACE_ZOOLIB_END #endif // ZCONFIG_SPI_Enabled(CFType) Modified: trunk/zoolib/source/cxx/zoolib/ZYad_CFType.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_CFType.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_CFType.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -146,11 +146,11 @@ ZRef<ZYadStreamR> sMakeYadR(const ZRef<CFMutableDataRef>& iData); ZRef<ZYadStreamR> sMakeYadR(const ZRef<CFDataRef>& iData); -ZRef<ZYadSeqR> sMakeYadR(const ZRef<CFMutableArrayRef>& iArray); -ZRef<ZYadSeqR> sMakeYadR(const ZRef<CFArrayRef>& iArray); +ZRef<ZYadSeqRPos> sMakeYadR(const ZRef<CFMutableArrayRef>& iArray); +ZRef<ZYadSeqRPos> sMakeYadR(const ZRef<CFArrayRef>& iArray); -ZRef<ZYadMapR> sMakeYadR(const ZRef<CFMutableDictionaryRef>& iDictionary); -ZRef<ZYadMapR> sMakeYadR(const ZRef<CFDictionaryRef>& iDictionary); +ZRef<ZYadMapRPos> sMakeYadR(const ZRef<CFMutableDictionaryRef>& iDictionary); +ZRef<ZYadMapRPos> sMakeYadR(const ZRef<CFDictionaryRef>& iDictionary); // ================================================================================================= #pragma mark - Modified: trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_JSON.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -623,9 +623,7 @@ { return spMakeYadR_JSON(iStrimmerU); } void ZYad_JSON::sToStrim(ZRef<ZYadR> iYadR, const ZStrimW& s) - { - sToStrim(0, ZYadOptions(), iYadR, s); - } + { sToStrim(0, ZYadOptions(), iYadR, s); } void ZYad_JSON::sToStrim(size_t iInitialIndent, const ZYadOptions& iOptions, ZRef<ZYadR> iYadR, const ZStrimW& s) Modified: trunk/zoolib/source/cxx/zoolib/ZYad_NS.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_NS.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_NS.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -146,11 +146,11 @@ ZRef<ZYadStreamR> sMakeYadR(const ZRef<NSMutableData>& iData); ZRef<ZYadStreamR> sMakeYadR(const ZRef<NSData>& iData); -ZRef<ZYadSeqR> sMakeYadR(const ZRef<NSMutableArray>& iArray); -ZRef<ZYadSeqR> sMakeYadR(const ZRef<NSArray>& iArray); +ZRef<ZYadSeqRPos> sMakeYadR(const ZRef<NSMutableArray>& iArray); +ZRef<ZYadSeqRPos> sMakeYadR(const ZRef<NSArray>& iArray); -ZRef<ZYadMapR> sMakeYadR(const ZRef<NSMutableDictionary>& iDictionary); -ZRef<ZYadMapR> sMakeYadR(const ZRef<NSDictionary>& iDictionary); +ZRef<ZYadMapRPos> sMakeYadR(const ZRef<NSMutableDictionary>& iDictionary); +ZRef<ZYadMapRPos> sMakeYadR(const ZRef<NSDictionary>& iDictionary); // ================================================================================================= #pragma mark - Modified: trunk/zoolib/source/cxx/zoolib/ZYad_NS.mm =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_NS.mm 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_NS.mm 2010-04-07 21:34:51 UTC (rev 1254) @@ -168,16 +168,16 @@ ZRef<ZYadStreamR> sMakeYadR(const ZRef<NSData>& iData) { return new ZYadStreamRPos_NS(iData); } -ZRef<ZYadSeqR> sMakeYadR(const ZRef<NSMutableArray>& iArray) +ZRef<ZYadSeqRPos> sMakeYadR(const ZRef<NSMutableArray>& iArray) { return new ZYadSeqRPos_NS(iArray); } -ZRef<ZYadSeqR> sMakeYadR(const ZRef<NSArray>& iArray) +ZRef<ZYadSeqRPos> sMakeYadR(const ZRef<NSArray>& iArray) { return new ZYadSeqRPos_NS(iArray); } -ZRef<ZYadMapR> sMakeYadR(const ZRef<NSMutableDictionary>& iDictionary) +ZRef<ZYadMapRPos> sMakeYadR(const ZRef<NSMutableDictionary>& iDictionary) { return new ZYadMapRPos_NS(iDictionary); } -ZRef<ZYadMapR> sMakeYadR(const ZRef<NSDictionary>& iDictionary) +ZRef<ZYadMapRPos> sMakeYadR(const ZRef<NSDictionary>& iDictionary) { return new ZYadMapRPos_NS(iDictionary); } // ================================================================================================= @@ -198,6 +198,10 @@ virtual bool Visit_YadSeqR(ZRef<ZYadSeqR> iYadSeqR); virtual bool Visit_YadMapR(ZRef<ZYadMapR> iYadMapR); +// Our protocol + ZRef<NSObject> GetNSObject(ZRef<ZYadR> iYadR); + +private: ZRef<NSObject> fDefault; ZRef<NSObject> fOutput; }; @@ -209,9 +213,7 @@ if (ZRef<ZYadR_NS> theYadR = iYadR.DynamicCast<ZYadR_NS>()) return theYadR->GetVal(); - Visitor_Yad_GetVal_NS theVisitor(iDefault); - iYadR->Accept(theVisitor); - return theVisitor.fOutput; + return Visitor_Yad_GetVal_NS(iDefault).GetNSObject(iYadR); } Visitor_Yad_GetVal_NS::Visitor_Yad_GetVal_NS(ZRef<NSObject> iDefault) @@ -243,7 +245,7 @@ ZSeq_NS theSeq; while (ZRef<ZYadR> theChild = iYadSeqR->ReadInc()) - theSeq.Append(sFromYadR(fDefault, theChild)); + theSeq.Append(this->GetNSObject(theChild)); fOutput = theSeq; return true; @@ -255,12 +257,23 @@ string theName; while (ZRef<ZYadR> theChild = iYadMapR->ReadInc(theName)) - theMap.Set(theName, sFromYadR(fDefault, theChild)); + theMap.Set(theName, this->GetNSObject(theChild)); fOutput = theMap; return true; } +ZRef<NSObject> Visitor_Yad_GetVal_NS::GetNSObject(ZRef<ZYadR> iYadR) + { + ZRef<NSObject> result; + if (iYadR) + { + iYadR->Accept(*this); + std::swap(result, fOutput); + } + return result; + } + NAMESPACE_ZOOLIB_END #endif // ZCONFIG_SPI_Enabled(Cocoa) Modified: trunk/zoolib/source/cxx/zoolib/ZYad_Simple.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_Simple.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_Simple.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -32,8 +32,7 @@ static void spThrowParseException(const string& iMessage) { throw ZYadParseException_Simple(iMessage); } -bool spRead_Until( - const ZStrimU& iStrimU, UTF32 iTerminator, string& oString) +bool spRead_Until(const ZStrimU& iStrimU, UTF32 iTerminator, string& oString) { oString.clear(); return ZUtil_Strim::sCopy_Until(iStrimU, iTerminator, ZStrimW_String(oString)); Modified: trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.cpp 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.cpp 2010-04-07 21:34:51 UTC (rev 1254) @@ -166,10 +166,10 @@ return new ZYadPrimR_ZooLib(iVal); } -ZRef<ZYadSeqR> sMakeYadR(const ZSeq_ZooLib& iSeq) +ZRef<ZYadSeqRPos> sMakeYadR(const ZSeq_ZooLib& iSeq) { return new ZYadSeqRPos_ZooLib(iSeq); } -ZRef<ZYadMapR> sMakeYadR(const ZMap_ZooLib& iMap) +ZRef<ZYadMapRPos> sMakeYadR(const ZMap_ZooLib& iMap) { return new ZYadMapRPos_ZooLib(iMap); } // ================================================================================================= Modified: trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.h 2010-04-07 20:29:36 UTC (rev 1253) +++ trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.h 2010-04-07 21:34:51 UTC (rev 1254) @@ -102,9 +102,9 @@ ZRef<ZYadR> sMakeYadR(const ZVal_ZooLib& iVal); -ZRef<ZYadSeqR> sMakeYadR(const ZSeq_ZooLib& iSeq); +ZRef<ZYadSeqRPos> sMakeYadR(const ZSeq_ZooLib& iSeq); -ZRef<ZYadMapR> sMakeYadR(const ZMap_ZooLib& iMap); +ZRef<ZYadMapRPos> sMakeYadR(const ZMap_ZooLib& iMap); // ================================================================================================= #pragma mark - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2010-04-09 17:35:41
|
Revision: 1279 http://zoolib.svn.sourceforge.net/zoolib/?rev=1279&view=rev Author: agreen Date: 2010-04-09 17:35:34 +0000 (Fri, 09 Apr 2010) Log Message: ----------- Move operators and pseudo constructors into their associated relation expr's file. Add ZQL_RelOps which pulls in a bunch of headers, making the suite of relational operators available. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.cpp trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Restrict.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Restrict_T.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Util_Strim_Query.cpp trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition_T.h trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h Added Paths: ----------- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelOps.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelOps.h Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -1,11 +1,11 @@ #include "zoolib/tql/ZTQL_Optimize.h" -#include "zoolib/zql/ZQL_Expr_Rel_Unary_Restrict.h" -#include "zoolib/zql/ZQL_Expr_Rel_Unary_Select.h" +//#include "zoolib/zql/ZQL_Expr_Rel_Unary_Restrict.h" +//#include "zoolib/zql/ZQL_Expr_Rel_Unary_Select.h" #include "zoolib/zql/ZQL_Util_Strim_Query.h" #include "zoolib/tql/ZUtil_TQLConvert.h" -#include "zoolib/ZExpr_Logic_ValCondition.h" +//#include "zoolib/ZExpr_Logic_ValCondition.h" #include "zoolib/ZUtil_Strim_Tuple.h" @@ -33,6 +33,8 @@ #include "zoolib/ZYadSeq_Expr_Logic.h" #include "zoolib/zqe/ZQE_Result_Any.h" +#include "zoolib/zql/ZQL_RelOps.h" + NAMESPACE_ZOOLIB_USING using namespace ZQL; @@ -41,19 +43,19 @@ using std::string; typedef ZRef<ZExpr_Logic> Spec; -typedef ZRef<Expr_Rel> Query; +typedef Rel Query; typedef ZMap_Expr Map; typedef ZRelHead RelHead; typedef ZVal_Expr Val; typedef ZValCondition Condition; -ZRef<Expr_Rel> sAll(const ZRelHead& iRelHead) +Query sAll(const ZRelHead& iRelHead) { return ZValBase::sConcrete(iRelHead); } -ZRef<Expr_Rel> sAllID(const std::string& iIDName) +Query sAllID(const std::string& iIDName) { return ZValBase::sConcrete(ZRelHead(true) | iIDName); } -ZRef<Expr_Rel> sAllID(const std::string& iIDName, const ZRelHead& iRelHead) +Query sAllID(const std::string& iIDName, const ZRelHead& iRelHead) { return ZValBase::sConcrete(iRelHead | iIDName); } // ================================================================================================= @@ -81,16 +83,14 @@ static Query J(const Query& iQuery1, const Query& iQuery2) { return sJoin(iQuery1, iQuery2); } -//static Query P(const string& iPropName0, const Query& iQuery) -// { return sProject(iQuery, iPropName0); } -static Query P(const RelHead& iRelHead, const Query& iQuery) - { return sProject(iRelHead, iQuery); } +static Query P(const Query& iQuery, const RelHead& iRelHead) + { return sProject(iQuery, iRelHead); } -static Query R(const string& iOldPropName, const string& iNewPropName, const Query& iQuery) - { return sRename(iOldPropName, iNewPropName, iQuery); } +static Query R(const Query& iQuery, const string& iNewPropName, const string& iOldPropName) + { return sRename(iQuery, iNewPropName, iOldPropName); } -static Query S(const Spec& iSpec, const Query& iQuery) - { return sSelect(iSpec, iQuery); } +static Query S(const Query& iQuery, const Spec& iSpec) + { return sSelect(iQuery, iSpec); } static Query U(const Query& iQuery1, const Query& iQuery2) { return sUnion(iQuery1, iQuery2); } @@ -152,21 +152,20 @@ | CName("pass") == CName("unam") ); */ - return new ZExpr_Logic_ValCondition(theSpec); + return true & theSpec; } static Query badPassword() { return A("authorID") & sBadAuthors(); - return P(RelHead("authorID"), - A("authorID") & sBadAuthors()); + return P(A("authorID") & sBadAuthors(), RelHead("authorID")); } static Query badPassword2() { // return (A("authorID") & sBadAuthors()).Project("authorID"); - return sProject(string("authorID"), A("authorID") & sBadAuthors()); + return sProject(A("authorID") & sBadAuthors(), string("authorID")); } // S(A(@authorID), @Object == "author" & (@fnam == @pass | @lnam == @pass | @unam == @pass)); @@ -193,7 +192,7 @@ { if (iIgnore.Contains(*i)) continue; - iQuery = sRename(*i, iPrefix + *i, iQuery); + iQuery = sRename(iQuery, iPrefix + *i, *i); } return iQuery; } @@ -212,7 +211,7 @@ { RelHead theRelHead = iQuery->GetRelHead(); if (theRelHead.Contains(iTName)) - return sProject(theRelHead - iTName, iQuery); + return sProject(iQuery, theRelHead - iTName); return iQuery; } @@ -253,16 +252,16 @@ static Query sQueryNoHead() { - Query allViews = sRename("$ID$", "from", sAllViewsNoHead()); - Query allNotes = sRename("$ID$", "to", sAllNotesNoHead()); + Query allViews = sRename(sAllViewsNoHead(), "from", "$ID$"); + Query allNotes = sRename(sAllNotesNoHead(), "to", "$ID$"); Query allContains = sAllContains(); return allViews * (allContains * allNotes); } static Query sQuery() { - Query allViews = sRename("$ID$", "from", sAllViews()); - Query allNotes = sRename("$ID$", "to", sAllNotes()); + Query allViews = sRename(sAllViews(), "from", "$ID$"); + Query allNotes = sRename(sAllNotes(), "to", "$ID$"); Query allContains = sAllContains(); return sPrefix("view.", RelHead("from"), allViews) @@ -283,7 +282,7 @@ // % // ^ - return sRename("$ID$", "from", sAllViews()) * sRename("to", "$ID$", sAllContains()) * sRename("titl", "noteTitle", sAllNotes()); + return sRename(sAllViews(), "from", "$ID$") * sRename(sAllContains(), "$ID$", "to") * sRename(sAllNotes(), "noteTitle", "titl"); } static void sDumpQuery(const ZStrimW& s, Query iQuery) @@ -363,7 +362,7 @@ // ZExpr_ValCondition theSpec1 = CVal() > CConst(10); // Spec theSpec = Spec(false) | (CVal() > CConst(10)); // Spec theSpec = (); - Spec theSpec = new ZExpr_Logic_ValCondition(CTrail("inner/field") < CConst(10)); + Spec theSpec = true & CTrail("inner/field") < CConst(10); thePhys = thePhys & theSpec; Util_Strim_Query::sToStrim(thePhys, s); @@ -394,7 +393,7 @@ return; Spec theSpec = CVar("TestVar1") == CConst(1) | CVar("TestVar2") == CConst(2); - Query theExp = sSelect(theSpec, sAll(ZRelHead(true))); + Query theExp = sSelect(sAll(ZRelHead(true)), theSpec); sDumpQuery(s, theExp); @@ -404,12 +403,12 @@ theMap.Set("name", ZMap_Expr().Set("last", string("fred"))); // Spec theSpec = CTrail("name/last") < CConst("fred1"); - if (sMatches(new ZExpr_Logic_ValCondition(CTrail("name/last") < CConst("fred1")), theMap)) + if (sMatches(true & (CTrail("name/last") < CConst("fred1")), theMap)) s << "Matches\n"; else s << "Doesn't\n"; - if (sMatches(new ZExpr_Logic_ValCondition(CTrail("name/last") >= CConst("fred1")), theMap)) + if (sMatches(true & (CTrail("name/last") >= CConst("fred1")), theMap)) s << "Matches\n"; else s << "Doesn't\n"; Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -176,6 +176,10 @@ } // anonymous namespace +// ================================================================================================= +#pragma mark - +#pragma mark * ZQL::sOptimize + namespace ZQL { ZRef<Expr_Rel> sOptimize(ZRef<Expr_Rel> iRep) Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -19,8 +19,7 @@ ------------------------------------------------------------------------------------------------- */ #include "zoolib/tql/ZUtil_TQLConvert.h" -#include "zoolib/zql/ZQL_Expr_Rel_Unary_Select.h" -#include "zoolib/ZExpr_Logic_ValCondition.h" +#include "zoolib/zql/ZQL_RelOps.h" #include "zoolib/valbase/ZValBase.h" NAMESPACE_ZOOLIB_BEGIN @@ -137,19 +136,19 @@ Query theQ; if (iName) { - theQ = sSelect(*iFilter, sAll(filterRelHead | *iName)); + theQ = sSelect(sAll(filterRelHead | *iName), *iFilter); if (iVerbose) - theQ = sProject(RelHead(*iName) | "$$All_Name$$", theQ); + theQ = sProject(theQ, RelHead(*iName) | "$$All_Name$$"); else - theQ = sProject(*iName, theQ); + theQ = sProject(theQ, *iName); } else { - theQ = sSelect(*iFilter, sAllID(sIDName, filterRelHead)); + theQ = sSelect(sAllID(sIDName, filterRelHead), *iFilter); if (iVerbose) - theQ = sProject(RelHead(sIDName) | "$$All$$", theQ); + theQ = sProject(theQ, RelHead(sIDName) | "$$All$$"); else - theQ = sProject(sIDName, theQ); + theQ = sProject(theQ, sIDName); } return theQ; } @@ -211,14 +210,14 @@ if (iName) { if (iVerbose) - return sProject(RelHead(*iName) | "$$ComboReturn_Name$$", outerQ); + return sProject(outerQ, RelHead(*iName) | "$$ComboReturn_Name$$"); else return outerQ;//.Project(*iName); } else { if (iVerbose) - return sProject(RelHead(sIDName) | "$$ComboReturn$$", outerQ); + return sProject(outerQ, RelHead(sIDName) | "$$ComboReturn$$"); else return outerQ;//.Project(sIDName); } @@ -250,7 +249,7 @@ Query theQ = spConvert(sourceNode, &sourcePropName, nullptr, iVerbose); // Rename it to sIDName. - theQ = sRename(sourcePropName, sIDName, theQ); + theQ = sRename(theQ, sIDName, sourcePropName); // Get the referenced tuples and filter them if (iFilter) @@ -258,19 +257,19 @@ const RelHead filterRelHead = sGetRelHead(*iFilter); if (iName) { - theQ = sJoin(theQ, sSelect(*iFilter, sAllID(sIDName, filterRelHead | *iName))); + theQ = sJoin(theQ, sSelect(sAllID(sIDName, filterRelHead | *iName), *iFilter)); if (iVerbose) - theQ = sProject(RelHead(*iName) | "$$FromSource_Name_Filter$$", theQ); + theQ = sProject(theQ, RelHead(*iName) | "$$FromSource_Name_Filter$$"); else - theQ = sProject(*iName, theQ); + theQ = sProject(theQ, *iName); } else { - theQ = sJoin(theQ, sSelect(*iFilter, sAllID(sIDName, filterRelHead))); + theQ = sJoin(theQ, sSelect(sAllID(sIDName, filterRelHead), *iFilter)); if (iVerbose) - theQ = sProject(RelHead(sIDName) | "$$FromSource_Filter$$", theQ); + theQ = sProject(theQ, RelHead(sIDName) | "$$FromSource_Filter$$"); else - theQ = sProject(sIDName, theQ); + theQ = sProject(theQ, sIDName); } } else @@ -279,15 +278,15 @@ { theQ = sJoin(theQ, sAllID(sIDName, *iName)); if (iVerbose) - theQ = sProject(RelHead(*iName) | "$$FromSource_Name$$", theQ); + theQ = sProject(theQ, RelHead(*iName) | "$$FromSource_Name$$"); else - theQ = sProject(*iName, theQ); + theQ = sProject(theQ, *iName); } else { // Do nothing -- already have the IDs. if (iVerbose) - theQ = sProject("$$FromSource$$", theQ); + theQ = sProject(theQ, "$$FromSource$$"); } } return theQ; @@ -302,7 +301,7 @@ Query theQ = spConvert(sourceNode, nullptr, nullptr, iVerbose); // Renamed to thePropName; - theQ = sRename(sIDName, thePropName, theQ); + theQ = sRename(theQ, thePropName, sIDName); // Get tuples whose property 'thePropName' match the IDs and filter them if (iFilter) @@ -311,22 +310,22 @@ if (iName) { theQ = sJoin(theQ, sAllID(sIDName, filterRelHead | *iName | thePropName)); - theQ = sProject(filterRelHead | *iName, theQ); - theQ = sSelect(*iFilter, theQ); + theQ = sProject(theQ, filterRelHead | *iName); + theQ = sSelect(theQ, *iFilter); if (iVerbose) - theQ = sProject(RelHead(*iName) | "$$Property_Name_Filter$$", theQ); + theQ = sProject(theQ, RelHead(*iName) | "$$Property_Name_Filter$$"); else - theQ = sProject(*iName, theQ); + theQ = sProject(theQ, *iName); } else { theQ = sJoin(theQ, sAllID(sIDName, filterRelHead | thePropName)); - theQ = sProject(filterRelHead, theQ); - theQ = sSelect(*iFilter, theQ); + theQ = sProject(theQ, filterRelHead); + theQ = sSelect(theQ, *iFilter); if (iVerbose) - theQ = sProject(RelHead(sIDName) | "$$Property_Filter$$", theQ); + theQ = sProject(theQ, RelHead(sIDName) | "$$Property_Filter$$"); else - theQ = sProject(sIDName, theQ); + theQ = sProject(theQ, sIDName); } } else @@ -335,17 +334,17 @@ { theQ = sJoin(theQ, sAllID(sIDName, RelHead(*iName) | thePropName)); if (iVerbose) - theQ = sProject(RelHead(*iName) | "$$Property_Name", theQ); + theQ = sProject(theQ, RelHead(*iName) | "$$Property_Name"); else - theQ = sProject(*iName, theQ); + theQ = sProject(theQ, *iName); } else { theQ = sJoin(theQ, sAllID(sIDName, thePropName)); if (iVerbose) - theQ = sProject(RelHead(sIDName) | "$$Property", theQ); + theQ = sProject(theQ, RelHead(sIDName) | "$$Property"); else - theQ = sProject(sIDName, theQ); + theQ = sProject(theQ, sIDName); } } return theQ; Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -19,14 +19,7 @@ ------------------------------------------------------------------------------------------------- */ #include "zoolib/zql/ZQL_Expr_Rel.h" -#include "zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h" -#include "zoolib/zql/ZQL_Expr_Rel_Binary_Join.h" -#include "zoolib/zql/ZQL_Expr_Rel_Binary_Union.h" -#include "zoolib/zql/ZQL_Expr_Rel_Unary_Project.h" -#include "zoolib/zql/ZQL_Expr_Rel_Unary_Rename.h" -using std::string; - NAMESPACE_ZOOLIB_BEGIN namespace ZQL { @@ -60,40 +53,5 @@ void Visitor_Expr_Rel::Visit_Expr_Rel(ZRef<Expr_Rel> iRep) { ZVisitor_Expr::Visit_Expr(iRep); } -// ================================================================================================= -#pragma mark - -#pragma mark * Relational operators - -ZRef<Expr_Rel> sIntersect( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) - { return new Expr_Rel_Binary_Intersect(iLHS, iRHS); } - -ZRef<Expr_Rel> sJoin( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) - { return new Expr_Rel_Binary_Join(iLHS, iRHS); } - -ZRef<Expr_Rel> sProject(const ZRelHead& iRelHead, const ZRef<Expr_Rel>& iExpr) - { return new Expr_Rel_Unary_Project(iExpr, iRelHead); } - -ZRef<Expr_Rel> sRename(const string& iOldPropName, const string& iNewPropName, - const ZRef<Expr_Rel>& iExpr) - { return new Expr_Rel_Unary_Rename(iExpr, iOldPropName, iNewPropName); } - -ZRef<Expr_Rel> sUnion( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) - { return new Expr_Rel_Binary_Union(iLHS, iRHS); } - -ZRef<Expr_Rel> operator&( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) - { return new Expr_Rel_Binary_Intersect(iLHS, iRHS); } - -ZRef<Expr_Rel> operator*( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) - { return new Expr_Rel_Binary_Join(iLHS, iRHS); } - -ZRef<Expr_Rel> operator|( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) - { return new Expr_Rel_Binary_Union(iLHS, iRHS); } - } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -63,34 +63,11 @@ // ================================================================================================= #pragma mark - -#pragma mark * Relational operators +#pragma mark * Rel -ZRef<Expr_Rel> sIntersect( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); +// A useful typedef. +typedef ZRef<Expr_Rel> Rel; -ZRef<Expr_Rel> sJoin( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); - -ZRef<Expr_Rel> sProject(const ZRelHead& iRelHead, const ZRef<Expr_Rel>& iExpr); - -ZRef<Expr_Rel> sRename(const std::string& iOldPropName, const std::string& iNewPropName, - const ZRef<Expr_Rel>& iExpr); - -ZRef<Expr_Rel> sUnion( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); - -ZRef<Expr_Rel> operator&( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); - -ZRef<Expr_Rel> operator&( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); - -ZRef<Expr_Rel> operator*( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); - -ZRef<Expr_Rel> operator|( - const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); - } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -67,5 +67,17 @@ ZRef<Expr_Rel_Binary_Intersect> iRep) { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iRep); } +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Binary_Intersect> sIntersect( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) + { return new Expr_Rel_Binary_Intersect(iLHS, iRHS); } + +ZRef<Expr_Rel_Binary_Intersect> operator&( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) + { return new Expr_Rel_Binary_Intersect(iLHS, iRHS); } + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -64,6 +64,16 @@ ZRef<Expr_Rel_Binary_Intersect> iRep); }; +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Binary_Intersect> sIntersect( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); + +ZRef<Expr_Rel_Binary_Intersect> operator&( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -70,5 +70,17 @@ ZRef<Expr_Rel_Binary_Join> iRep) { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iRep); } +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Binary_Join> sJoin( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) + { return new Expr_Rel_Binary_Join(iLHS, iRHS); } + +ZRef<Expr_Rel_Binary_Join> operator*( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) + { return new Expr_Rel_Binary_Join(iLHS, iRHS); } + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -63,6 +63,16 @@ virtual void Visit_Expr_Rel_Binary_Join(ZRef<Expr_Rel_Binary_Join> iRep); }; +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Binary_Join> sJoin( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); + +ZRef<Expr_Rel_Binary_Join> operator*( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -70,5 +70,17 @@ ZRef<Expr_Rel_Binary_Union> iRep) { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iRep); } +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Binary_Union> sUnion( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) + { return new Expr_Rel_Binary_Union(iLHS, iRHS); } + +ZRef<Expr_Rel_Binary_Union> operator|( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS) + { return new Expr_Rel_Binary_Union(iLHS, iRHS); } + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -63,6 +63,16 @@ virtual void Visit_Expr_Rel_Binary_Union(ZRef<Expr_Rel_Binary_Union> iRep); }; +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Binary_Union> sUnion( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); + +ZRef<Expr_Rel_Binary_Union> operator|( + const ZRef<Expr_Rel>& iLHS, const ZRef<Expr_Rel>& iRHS); + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -74,5 +74,12 @@ ZRef<Expr_Rel_Unary_Project> iRep) { Visitor_Expr_Rel_Unary::Visit_Expr_Rel_Unary(iRep); } +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Unary_Project> sProject(const ZRef<Expr_Rel>& iExpr, const ZRelHead& iRelHead) + { return new Expr_Rel_Unary_Project(iExpr, iRelHead); } + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -69,6 +69,12 @@ virtual void Visit_Expr_Rel_Unary_Project(ZRef<Expr_Rel_Unary_Project> iRep); }; +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Unary_Project> sProject(const ZRef<Expr_Rel>& iExpr, const ZRelHead& iRelHead); + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -29,11 +29,11 @@ #pragma mark - #pragma mark * Expr_Rel_Unary_Rename -Expr_Rel_Unary_Rename::Expr_Rel_Unary_Rename( - ZRef<Expr_Rel> iExpr_Rel, const std::string& iOld, const std::string& iNew) +Expr_Rel_Unary_Rename::Expr_Rel_Unary_Rename(ZRef<Expr_Rel> iExpr_Rel, + const std::string& iNew, const std::string& iOld) : Expr_Rel_Unary(iExpr_Rel) +, fNew(iNew) , fOld(iOld) -, fNew(iNew) {} Expr_Rel_Unary_Rename::~Expr_Rel_Unary_Rename() @@ -66,18 +66,18 @@ ZRef<Expr_Rel_Unary> Expr_Rel_Unary_Rename::Clone( ZRef<Expr_Rel> iExpr_Rel) - { return new Expr_Rel_Unary_Rename(iExpr_Rel, fOld, fNew); } + { return new Expr_Rel_Unary_Rename(iExpr_Rel, fNew, fOld); } void Expr_Rel_Unary_Rename::Accept_Expr_Rel_Unary_Rename( Visitor_Expr_Rel_Unary_Rename& iVisitor) { iVisitor.Visit_Expr_Rel_Unary_Rename(this); } +const string& Expr_Rel_Unary_Rename::GetNew() + { return fNew; } + const string& Expr_Rel_Unary_Rename::GetOld() { return fOld; } -const string& Expr_Rel_Unary_Rename::GetNew() - { return fNew; } - // ================================================================================================= #pragma mark - #pragma mark * Visitor_Expr_Rel_Unary_Rename @@ -86,5 +86,13 @@ ZRef<Expr_Rel_Unary_Rename> iRep) { Visitor_Expr_Rel_Unary::Visit_Expr_Rel_Unary(iRep); } +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Unary_Rename> sRename(const ZRef<Expr_Rel>& iExpr, + const string& iNewPropName, const string& iOldPropName) + { return new Expr_Rel_Unary_Rename(iExpr, iNewPropName, iOldPropName); } + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -37,7 +37,7 @@ { public: Expr_Rel_Unary_Rename(ZRef<Expr_Rel> iExpr_Rel, - const std::string& iOld, const std::string& iNew); + const std::string& iNew, const std::string& iOld); virtual ~Expr_Rel_Unary_Rename(); @@ -53,12 +53,12 @@ virtual void Accept_Expr_Rel_Unary_Rename( Visitor_Expr_Rel_Unary_Rename& iVisitor); + const std::string& GetNew(); const std::string& GetOld(); - const std::string& GetNew(); private: + const std::string fNew; const std::string fOld; - const std::string fNew; }; // ================================================================================================= @@ -71,6 +71,13 @@ virtual void Visit_Expr_Rel_Unary_Rename(ZRef<Expr_Rel_Unary_Rename> iRep); }; +// ================================================================================================= +#pragma mark - +#pragma mark * Relational operators + +ZRef<Expr_Rel_Unary_Rename> sRename(const ZRef<Expr_Rel>& iExpr, + const std::string& iNewPropName, const std::string& iOldPropName); + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Restrict.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Restrict.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Restrict.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -22,8 +22,8 @@ #define __ZQL_Expr_Rel_Unary_Restrict__ 1 #include "zconfig.h" -#include "zoolib/zql/ZQL_Expr_Rel_Unary_Restrict_T.h" #include "zoolib/ZValCondition.h" +#include "zoolib/zql/ZQL_Expr_Rel_Unary_Restrict_T.h" NAMESPACE_ZOOLIB_BEGIN namespace ZQL { @@ -34,8 +34,7 @@ typedef Expr_Rel_Unary_Restrict_T<ZVal_Expr> Expr_Rel_Unary_Restrict; -typedef Visitor_Expr_Rel_Unary_Restrict_T<ZVal_Expr> - Visitor_Expr_Rel_Unary_Restrict; +typedef Visitor_Expr_Rel_Unary_Restrict_T<ZVal_Expr> Visitor_Expr_Rel_Unary_Restrict; } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Restrict_T.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Restrict_T.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Restrict_T.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -22,8 +22,8 @@ #define __ZQL_Expr_Rel_Unary_Restrict_T__ 1 #include "zconfig.h" +#include "zoolib/ZValCondition_T.h" #include "zoolib/zql/ZQL_Expr_Rel_Unary.h" -#include "zoolib/ZValCondition_T.h" NAMESPACE_ZOOLIB_BEGIN namespace ZQL { Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -84,18 +84,18 @@ // ================================================================================================= #pragma mark - -#pragma mark * +#pragma mark * Relational operators ZRef<Expr_Rel_Unary_Select> sSelect( - const ZRef<ZExpr_Logic>& iExpr_Logic, const ZRef<Expr_Rel>& iExpr_Rel) + const ZRef<Expr_Rel>& iExpr_Rel, const ZRef<ZExpr_Logic>& iExpr_Logic) { return new Expr_Rel_Unary_Select(iExpr_Rel, iExpr_Logic); } ZRef<Expr_Rel_Unary_Select> operator&( - const ZRef<ZExpr_Logic>& iExpr_Logic, const ZRef<Expr_Rel>& iExpr_Rel) + const ZRef<Expr_Rel>& iExpr_Rel, const ZRef<ZExpr_Logic>& iExpr_Logic) { return new Expr_Rel_Unary_Select(iExpr_Rel, iExpr_Logic); } ZRef<Expr_Rel_Unary_Select> operator&( - const ZRef<Expr_Rel>& iExpr_Rel, const ZRef<ZExpr_Logic>& iExpr_Logic) + const ZRef<ZExpr_Logic>& iExpr_Logic, const ZRef<Expr_Rel>& iExpr_Rel) { return new Expr_Rel_Unary_Select(iExpr_Rel, iExpr_Logic); } } // namespace ZQL Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -73,16 +73,16 @@ // ================================================================================================= #pragma mark - -#pragma mark * Query operators +#pragma mark * Relational operators ZRef<Expr_Rel_Unary_Select> sSelect( - const ZRef<ZExpr_Logic>& iExpr_Logic, const ZRef<Expr_Rel>& iExpr_Rel); + const ZRef<Expr_Rel>& iExpr_Rel, const ZRef<ZExpr_Logic>& iExpr_Logic); ZRef<Expr_Rel_Unary_Select> operator&( - const ZRef<ZExpr_Logic>& iExpr_Logic, const ZRef<Expr_Rel>& iExpr_Rel); + const ZRef<Expr_Rel>& iExpr_Rel, const ZRef<ZExpr_Logic>& iExpr_Logic); ZRef<Expr_Rel_Unary_Select> operator&( - const ZRef<Expr_Rel>& iExpr_Rel, const ZRef<ZExpr_Logic>& iExpr_Logic); + const ZRef<ZExpr_Logic>& iExpr_Logic, const ZRef<Expr_Rel>& iExpr_Rel); } // namespace ZQL NAMESPACE_ZOOLIB_END Added: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelOps.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelOps.cpp (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelOps.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -0,0 +1,21 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/zql/ZQL_RelOps.h" Added: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelOps.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelOps.h (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelOps.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -0,0 +1,36 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZQL_RelOps__ +#define __ZQL_RelOps__ 1 +#include "zconfig.h" + +#include "zoolib/ZExpr_Logic.h" +#include "zoolib/ZExpr_Logic_ValCondition.h" // For ValCondition/Logic operators +#include "zoolib/zql/ZQL_Expr_Rel.h" +#include "zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h" +#include "zoolib/zql/ZQL_Expr_Rel_Binary_Join.h" +#include "zoolib/zql/ZQL_Expr_Rel_Binary_Union.h" +#include "zoolib/zql/ZQL_Expr_Rel_Unary_Project.h" +#include "zoolib/zql/ZQL_Expr_Rel_Unary_Restrict.h" // For restrict templated operators +#include "zoolib/zql/ZQL_Expr_Rel_Unary_Rename.h" +#include "zoolib/zql/ZQL_Expr_Rel_Unary_Select.h" + +#endif // __ZQL_RelOps__ Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Util_Strim_Query.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Util_Strim_Query.cpp 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Util_Strim_Query.cpp 2010-04-09 17:35:34 UTC (rev 1279) @@ -196,9 +196,9 @@ spWrite("(", w); this->pWriteLFIndent(); + spWrite_PropName(iRep->GetNew(), w); + spWrite("<--", w); spWrite_PropName(iRep->GetOld(), w); - spWrite("-->", w); - spWrite_PropName(iRep->GetNew(), w); spWrite(",", w); this->pWriteLFIndent(); Modified: trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition_T.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition_T.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition_T.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -106,40 +106,66 @@ #pragma mark * Operators template <class Val> -ZRef<ZExpr_Logic> operator&( - const ZValCondition_T<Val>& iLHS, - const ZValCondition_T<Val>& iRHS) +ZRef<ZExpr_Logic> operator!(const ZValCondition_T<Val>& iValCondition) + { return new ZExpr_Logic_Not(new ZExpr_Logic_ValCondition_T<Val>(iValCondition)); } + +template <class Val> +ZRef<ZExpr_Logic> operator&(bool iBool, const ZValCondition_T<Val>& iValCondition) { + if (iBool) + return new ZExpr_Logic_ValCondition_T<Val>(iValCondition); + return new ZExpr_Logic_False; + } + +template <class Val> +ZRef<ZExpr_Logic> operator&(const ZValCondition_T<Val>& iValCondition, bool iBool) + { + if (iBool) + return new ZExpr_Logic_ValCondition_T<Val>(iValCondition); + return new ZExpr_Logic_False; + } + +template <class Val> +ZRef<ZExpr_Logic> operator|(bool iBool, const ZValCondition_T<Val>& iValCondition) + { + if (iBool) + return new ZExpr_Logic_True; + return new ZExpr_Logic_ValCondition_T<Val>(iValCondition); + } + +template <class Val> +ZRef<ZExpr_Logic> operator|(const ZValCondition_T<Val>& iValCondition, bool iBool) + { + if (iBool) + return new ZExpr_Logic_True; + return new ZExpr_Logic_ValCondition_T<Val>(iValCondition); + } + +template <class Val> +ZRef<ZExpr_Logic> operator&(const ZValCondition_T<Val>& iLHS, const ZValCondition_T<Val>& iRHS) + { return new ZExpr_Logic_And( new ZExpr_Logic_ValCondition_T<Val>(iLHS), new ZExpr_Logic_ValCondition_T<Val>(iRHS)); } template <class Val> -ZRef<ZExpr_Logic> operator&( - const ZValCondition_T<Val>& iLHS, - const ZRef<ZExpr_Logic>& iRHS) +ZRef<ZExpr_Logic> operator&(const ZValCondition_T<Val>& iLHS, const ZRef<ZExpr_Logic>& iRHS) { return new ZExpr_Logic_And(new ZExpr_Logic_ValCondition_T<Val>(iLHS), iRHS); } template <class Val> -ZRef<ZExpr_Logic> operator&( - const ZRef<ZExpr_Logic>& iLHS, - const ZValCondition_T<Val>& iRHS) +ZRef<ZExpr_Logic> operator&(const ZRef<ZExpr_Logic>& iLHS, const ZValCondition_T<Val>& iRHS) { return new ZExpr_Logic_And(new ZExpr_Logic_ValCondition_T<Val>(iRHS), iLHS); } template <class Val> -ZRef<ZExpr_Logic>& operator&=( - ZRef<ZExpr_Logic>& iLHS, - const ZValCondition_T<Val>& iRHS) +ZRef<ZExpr_Logic>& operator&=(ZRef<ZExpr_Logic>& iLHS, const ZValCondition_T<Val>& iRHS) { iLHS = iLHS & iRHS; return iLHS; } template <class Val> -ZRef<ZExpr_Logic> operator|( - const ZValCondition_T<Val>& iLHS, - const ZValCondition_T<Val>& iRHS) +ZRef<ZExpr_Logic> operator|(const ZValCondition_T<Val>& iLHS, const ZValCondition_T<Val>& iRHS) { return new ZExpr_Logic_Or( new ZExpr_Logic_ValCondition_T<Val>(iLHS), @@ -147,23 +173,15 @@ } template <class Val> -ZRef<ZExpr_Logic> operator|( - const ZValCondition_T<Val>& iLHS, - const ZRef<ZExpr_Logic>& iRHS) +ZRef<ZExpr_Logic> operator|(const ZValCondition_T<Val>& iLHS, const ZRef<ZExpr_Logic>& iRHS) { return new ZExpr_Logic_Or(new ZExpr_Logic_ValCondition_T<Val>(iLHS), iRHS); } template <class Val> -ZRef<ZExpr_Logic> operator|( - const ZRef<ZExpr_Logic>& iLHS, - const ZValCondition_T<Val>& iRHS) - { - return new ZExpr_Logic_Or(new ZExpr_Logic_ValCondition_T<Val>(iRHS), iLHS); - } +ZRef<ZExpr_Logic> operator|(const ZRef<ZExpr_Logic>& iLHS, const ZValCondition_T<Val>& iRHS) + { return new ZExpr_Logic_Or(new ZExpr_Logic_ValCondition_T<Val>(iRHS), iLHS); } template <class Val> -ZRef<ZExpr_Logic>& operator|=( - ZRef<ZExpr_Logic>& iLHS, - const ZValCondition_T<Val>& iRHS) +ZRef<ZExpr_Logic>& operator|=(ZRef<ZExpr_Logic>& iLHS, const ZValCondition_T<Val>& iRHS) { iLHS = iLHS | iRHS; return iLHS; @@ -216,14 +234,14 @@ #pragma mark * Matches template <class Val> -class ZVisitor_Expr_Logic_ValCondition_Matches_T +class ZVisitor_Expr_Logic_ValCondition_DoEval_Matches_T : public virtual ZVisitor_Expr_Logic_DoEval , public virtual ZVisitor_Expr_Logic_ValCondition_T<Val> { typedef ZVisitor_Expr_Logic_ValCondition_T<Val> inherited; public: - ZVisitor_Expr_Logic_ValCondition_Matches_T(const Val& iVal); + ZVisitor_Expr_Logic_ValCondition_DoEval_Matches_T(const Val& iVal); // From ZVisitor_Expr_Logic_ValCondition_T virtual void Visit_Logic_ValCondition(ZRef<ZExpr_Logic_ValCondition_T<Val> > iRep); @@ -234,13 +252,13 @@ }; template <class Val> -ZVisitor_Expr_Logic_ValCondition_Matches_T<Val>::ZVisitor_Expr_Logic_ValCondition_Matches_T( - const Val& iVal) +ZVisitor_Expr_Logic_ValCondition_DoEval_Matches_T<Val>:: +ZVisitor_Expr_Logic_ValCondition_DoEval_Matches_T(const Val& iVal) : fVal(iVal) {} template <class Val> -void ZVisitor_Expr_Logic_ValCondition_Matches_T<Val>::Visit_Logic_ValCondition( +void ZVisitor_Expr_Logic_ValCondition_DoEval_Matches_T<Val>::Visit_Logic_ValCondition( ZRef<ZExpr_Logic_ValCondition_T<Val> > iRep) { fResult = iRep->GetValCondition().Matches(fValContext, fVal); } @@ -248,7 +266,7 @@ bool sMatches_T(const ZRef<ZExpr_Logic>& iRep, const Val& iVal) { if (iRep) - return ZVisitor_Expr_Logic_ValCondition_Matches_T<Val>(iVal).DoEval(iRep); + return ZVisitor_Expr_Logic_ValCondition_DoEval_Matches_T<Val>(iVal).DoEval(iRep); return false; } Modified: trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h 2010-04-09 17:16:55 UTC (rev 1278) +++ trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h 2010-04-09 17:35:34 UTC (rev 1279) @@ -598,22 +598,22 @@ template <class Val> ZValComparand_T<Val> CConst_T(const char* iVal) - { return ZValComparand_T<Val>( new ZValComparandRep_Const_T<Val>(std::string(iVal))); } + { return ZValComparand_T<Val>(new ZValComparandRep_Const_T<Val>(std::string(iVal))); } template <class Val> ZValComparand_T<Val> CConst_T(const Val& iVal) - { return ZValComparand_T<Val>( new ZValComparandRep_Const_T<Val>(iVal)); } + { return ZValComparand_T<Val>(new ZValComparandRep_Const_T<Val>(iVal)); } template <class Val> ZValComparand_T<Val> CName_T(const std::string& iName) - { return ZValComparand_T<Val>( new ZValComparandRep_Trail_T<Val>(ZTrail(&iName, &iName + 1))); } + { return ZValComparand_T<Val>(new ZValComparandRep_Trail_T<Val>(ZTrail(&iName, &iName + 1))); } template <class Val> ZValComparand_T<Val> CTrail_T(const ZTrail& iTrail) - { return ZValComparand_T<Val>( new ZValComparandRep_Trail_T<Val>(iTrail)); } + { return ZValComparand_T<Val>(new ZValComparandRep_Trail_T<Val>(iTrail)); } template <class Val> ZValComparand_T<Val> @@ -628,7 +628,7 @@ template <class Val> ZValComparand_T<Val> CVar_T(const std::string& iVarName) - { return ZValComparand_T<Val>( new ZValComparandRep_Var_T<Val>(iVarName)); } + { return ZValComparand_T<Val>(new ZValComparandRep_Var_T<Val>(iVarName)); } NAMESPACE_ZOOLIB_END This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2010-04-12 04:24:07
|
Revision: 1295 http://zoolib.svn.sourceforge.net/zoolib/?rev=1295&view=rev Author: agreen Date: 2010-04-12 04:23:59 +0000 (Mon, 12 Apr 2010) Log Message: ----------- Move ZRelHead out of main directory, intl zql. Implement GetRelHead by running a visitor over a tree, rather than as calls against virtual methods. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.cpp trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.h trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase.cpp trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase.h trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_Any.cpp trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_SQLite.cpp trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.cpp trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Iterator.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Iterator.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Difference.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Difference.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Concrete.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Concrete.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Restrict_T.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Select.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Util_Strim_Rel.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Visitor_Expr_Rel_Binary_DoTransform.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Visitor_Expr_Rel_Binary_DoTransform.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Visitor_Expr_Rel_Unary_DoTransform.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Visitor_Expr_Rel_Unary_DoTransform.h trunk/zoolib/source/cxx/zoolib/ZExpr.cpp trunk/zoolib/source/cxx/zoolib/ZExpr.h trunk/zoolib/source/cxx/zoolib/ZExpr_Logic.cpp trunk/zoolib/source/cxx/zoolib/ZExpr_Logic.h trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition.h trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition_T.h trunk/zoolib/source/cxx/zoolib/ZUniSet_T.h trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValCondition.cpp trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h Added Paths: ----------- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Visitor_Expr_Rel_DoGetRelHead.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Visitor_Expr_Rel_DoGetRelHead.h Removed Paths: ------------- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.h trunk/zoolib/source/cxx/zoolib/ZRelHead.cpp trunk/zoolib/source/cxx/zoolib/ZRelHead.h trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_RelHead.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_RelHead.h Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -37,6 +37,7 @@ #include "zoolib/valbase/ZValBase_SQLite.h" #include "zoolib/sqlite/ZSQLite.h" #include "zoolib/sqlite/ZSQLite_YadSeqR_Iter.h" +#include "zoolib/zql/ZQL_Visitor_Expr_Rel_DoGetRelHead.h" NAMESPACE_ZOOLIB_USING @@ -48,19 +49,21 @@ typedef ZRef<ZExpr_Logic> Spec; typedef Rel Query; typedef ZMap_Expr Map; -typedef ZRelHead RelHead; typedef ZVal_Expr Val; typedef ZValCondition Condition; static ZYadOptions theYadOptions(true); -Query sAll(const ZRelHead& iRelHead) +RelHead spGetRelHead(ZRef<Expr_Rel> iExpr) + { return Visitor_Expr_Rel_DoGetRelHead().DoGetRelHead(iExpr); } + +Query sAll(const RelHead& iRelHead) { return ZValBase::sConcrete(iRelHead); } Query sAllID(const std::string& iIDName) - { return ZValBase::sConcrete(ZRelHead(true) | iIDName); } + { return ZValBase::sConcrete(RelHead(true) | iIDName); } -Query sAllID(const std::string& iIDName, const ZRelHead& iRelHead) +Query sAllID(const std::string& iIDName, const RelHead& iRelHead) { return ZValBase::sConcrete(iRelHead | iIDName); } // ================================================================================================= @@ -177,7 +180,7 @@ static Query badPassword2() { // return (A("authorID") & sBadAuthors()).Project("authorID"); - return A("authorID") & sBadAuthors() & ZRelHead("authorID"); + return A("authorID") & sBadAuthors() & RelHead("authorID"); } // S(A(@authorID), @Object == "author" & (@fnam == @pass | @lnam == @pass | @unam == @pass)); @@ -199,7 +202,7 @@ bool universal; set<string> theNames; - iQuery->GetRelHead().GetElems(universal, theNames); + spGetRelHead(iQuery).GetElems(universal, theNames); for (set<string>::iterator i = theNames.begin(); i != theNames.end(); ++i) { if (iIgnore.Contains(*i)) @@ -221,7 +224,7 @@ static Query sDrop(Query iQuery, const string& iTName) { - return iQuery & (ZRelHead(true) - iTName); + return iQuery & (RelHead(true) - iTName); // RelHead theRelHead = iQuery->GetRelHead(); // return iQuery & (theRelHead - iTName); // if (theRelHead.Contains(iTName)) @@ -301,7 +304,7 @@ static void sDumpQuery(const ZStrimW& s, Query iQuery) { Util_Strim_Rel::Options theOptions; -//## theOptions.fDebuggingOutput = true; + theOptions.fDebuggingOutput = true; Util_Strim_Rel::sToStrim(iQuery, theOptions, s); s << "\n"; @@ -394,7 +397,7 @@ return; Spec theSpec = CVar("TestVar1") == CConst(1) | CVar("TestVar2") == CConst(2); - Query theExp = sSelect(sAll(ZRelHead(true)), theSpec); + Query theExp = sSelect(sAll(RelHead(true)), theSpec); sDumpQuery(s, theExp); Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -59,7 +59,7 @@ } } -void spGather(ZRef<ZExpr_Logic> iRep, CondUnion& oResult); +void spGather(ZRef<ZExpr_Logic> iExpr, CondUnion& oResult); class Gather : public virtual ZVisitor_Expr_Logic_DoTransform @@ -69,14 +69,14 @@ Gather(CondUnion& oResult); // From ZVisitor_Expr_Logic_DoTransform - virtual void Visit_Logic_True(ZRef<ZExpr_Logic_True> iRep); - virtual void Visit_Logic_False(ZRef<ZExpr_Logic_False> iRep); - virtual void Visit_Logic_Not(ZRef<ZExpr_Logic_Not> iRep); - virtual void Visit_Logic_And(ZRef<ZExpr_Logic_And> iRep); - virtual void Visit_Logic_Or(ZRef<ZExpr_Logic_Or> iRep); + virtual void Visit_Logic_True(ZRef<ZExpr_Logic_True> iExpr); + virtual void Visit_Logic_False(ZRef<ZExpr_Logic_False> iExpr); + virtual void Visit_Logic_Not(ZRef<ZExpr_Logic_Not> iExpr); + virtual void Visit_Logic_And(ZRef<ZExpr_Logic_And> iExpr); + virtual void Visit_Logic_Or(ZRef<ZExpr_Logic_Or> iExpr); // From ZVisitor_Expr_Logic_ValCondition - virtual void Visit_Logic_ValCondition(ZRef<ZExpr_Logic_ValCondition> iRep); + virtual void Visit_Logic_ValCondition(ZRef<ZExpr_Logic_ValCondition> iExpr); private: CondUnion& fResult; @@ -86,48 +86,48 @@ : fResult(oResult) {} -void Gather::Visit_Logic_True(ZRef<ZExpr_Logic_True> iRep) +void Gather::Visit_Logic_True(ZRef<ZExpr_Logic_True> iExpr) { fResult.resize(1); } -void Gather::Visit_Logic_False(ZRef<ZExpr_Logic_False> iRep) +void Gather::Visit_Logic_False(ZRef<ZExpr_Logic_False> iExpr) { ZAssert(fResult.empty()); // fResult.clear(); } -void Gather::Visit_Logic_Not(ZRef<ZExpr_Logic_Not> iRep) +void Gather::Visit_Logic_Not(ZRef<ZExpr_Logic_Not> iExpr) { ZUnimplemented(); } -void Gather::Visit_Logic_And(ZRef<ZExpr_Logic_And> iRep) +void Gather::Visit_Logic_And(ZRef<ZExpr_Logic_And> iExpr) { CondUnion left; - spGather(iRep->GetLHS(), left); + spGather(iExpr->GetLHS(), left); CondUnion right; - spGather(iRep->GetRHS(), right); + spGather(iExpr->GetRHS(), right); spCrossMultiply(left, right, fResult); } -void Gather::Visit_Logic_Or(ZRef<ZExpr_Logic_Or> iRep) +void Gather::Visit_Logic_Or(ZRef<ZExpr_Logic_Or> iExpr) { CondUnion left; - spGather(iRep->GetLHS(), left); + spGather(iExpr->GetLHS(), left); CondUnion right; - spGather(iRep->GetRHS(), right); + spGather(iExpr->GetRHS(), right); fResult.swap(left); fResult.insert(fResult.end(), right.begin(), right.end()); } -void Gather::Visit_Logic_ValCondition(ZRef<ZExpr_Logic_ValCondition> iRep) +void Gather::Visit_Logic_ValCondition(ZRef<ZExpr_Logic_ValCondition> iExpr) { fResult.resize(1); - fResult[0].push_back(iRep->GetValCondition()); + fResult[0].push_back(iExpr->GetValCondition()); } -void spGather(ZRef<ZExpr_Logic> iRep, CondUnion& oResult) +void spGather(ZRef<ZExpr_Logic> iExpr, CondUnion& oResult) { ZAssert(oResult.empty()); Gather theGather(oResult); - iRep->Accept(theGather); + iExpr->Accept(theGather); } ZRef<Expr_Rel> spConvertSelect( @@ -166,21 +166,21 @@ { public: // From Visitor_Expr_Rel_Concrete - virtual void Visit_Expr_Rel_Concrete(ZRef<Expr_Rel_Concrete> iRep); + virtual void Visit_Expr_Rel_Concrete(ZRef<Expr_Rel_Concrete> iExpr); // From Visitor_Expr_Rel_Unary_Select - virtual void Visit_Expr_Rel_Unary_Select(ZRef<Expr_Rel_Unary_Select> iRep); + virtual void Visit_Expr_Rel_Unary_Select(ZRef<Expr_Rel_Unary_Select> iExpr); }; -void Optimize::Visit_Expr_Rel_Concrete(ZRef<Expr_Rel_Concrete> iRep) - { fResult = iRep; } +void Optimize::Visit_Expr_Rel_Concrete(ZRef<Expr_Rel_Concrete> iExpr) + { fResult = iExpr; } -void Optimize::Visit_Expr_Rel_Unary_Select(ZRef<Expr_Rel_Unary_Select> iRep) +void Optimize::Visit_Expr_Rel_Unary_Select(ZRef<Expr_Rel_Unary_Select> iExpr) { - ZRef<Expr_Rel> newRep = - this->DoTransform(iRep->GetExpr_Rel()).DynamicCast<Expr_Rel>(); + ZRef<Expr_Rel> newExpr = + this->DoTransform(iExpr->GetExpr_Rel()).DynamicCast<Expr_Rel>(); - fResult = spConvertSelect(newRep, iRep->GetExpr_Logic()); + fResult = spConvertSelect(newExpr, iExpr->GetExpr_Logic()); } } // anonymous namespace @@ -191,8 +191,8 @@ namespace ZQL { -ZRef<Expr_Rel> sOptimize(ZRef<Expr_Rel> iRep) - { return Optimize().DoTransform(iRep).DynamicCast<Expr_Rel>(); } +ZRef<Expr_Rel> sOptimize(ZRef<Expr_Rel> iExpr) + { return Optimize().DoTransform(iExpr).DynamicCast<Expr_Rel>(); } } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZTQL_Optimize.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -32,7 +32,7 @@ namespace ZQL { -ZRef<Expr_Rel> sOptimize(ZRef<Expr_Rel> iRep); +ZRef<Expr_Rel> sOptimize(ZRef<Expr_Rel> iExpr); } // namespace ZTQL Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZUtil_TQLConvert.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -30,19 +30,18 @@ using std::vector; using namespace ZQL; -ZRef<Expr_Rel> sAll(const ZRelHead& iRelHead) +ZRef<Expr_Rel> sAll(const RelHead& iRelHead) { return ZValBase::sConcrete(); } ZRef<Expr_Rel> sAllID(const std::string& iIDName) { return ZValBase::sConcrete(); } -ZRef<Expr_Rel> sAllID(const std::string& iIDName, const ZRelHead& iRelHead) +ZRef<Expr_Rel> sAllID(const std::string& iIDName, const RelHead& iRelHead) { return ZValBase::sConcrete(); } typedef ZRef<ZExpr_Logic> Spec; typedef ZRef<Expr_Rel> Query; typedef ZMap_Expr Map; -typedef ZRelHead RelHead; typedef ZVal_Expr Val; typedef ZValCondition Condition; @@ -131,7 +130,7 @@ // except as a clause in a combo with a filter. ZAssert(iFilter); - const RelHead filterRelHead = sGetRelHead(*iFilter); + const RelHead filterRelHead = sGetNames(*iFilter); Query theQ; if (iName) @@ -254,7 +253,7 @@ // Get the referenced tuples and filter them if (iFilter) { - const RelHead filterRelHead = sGetRelHead(*iFilter); + const RelHead filterRelHead = sGetNames(*iFilter); if (iName) { theQ = sJoin(theQ, sSelect(sAllID(sIDName, filterRelHead | *iName), *iFilter)); @@ -286,7 +285,7 @@ { // Do nothing -- already have the IDs. if (iVerbose) - theQ = sProject(theQ, ZRelHead("$$FromSource$$")); + theQ = sProject(theQ, RelHead("$$FromSource$$")); } } return theQ; @@ -306,7 +305,7 @@ // Get tuples whose property 'thePropName' match the IDs and filter them if (iFilter) { - const RelHead filterRelHead = sGetRelHead(*iFilter); + const RelHead filterRelHead = sGetNames(*iFilter); if (iName) { theQ = sJoin(theQ, sAllID(sIDName, filterRelHead | *iName | thePropName)); Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -21,7 +21,7 @@ #include "zoolib/valbase/ZValBase.h" #include "zoolib/zqe/ZQE_Iterator_Any.h" #include "zoolib/zqe/ZQE_Result_Any.h" -#include "zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.h" +#include "zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.h" #include "zoolib/zql/ZQL_Expr_Rel_Concrete.h" #include "zoolib/zql/ZQL_Expr_Rel_Unary_Restrict.h" @@ -35,9 +35,6 @@ Expr_Rel_Concrete::Expr_Rel_Concrete() {} -ZRelHead Expr_Rel_Concrete::GetRelHead() - { return ZRelHead(true); } - // ================================================================================================= #pragma mark - #pragma mark * Visitor_DoMakeIterator @@ -45,42 +42,42 @@ namespace ZANONYMOUS { class Visitor_DoMakeIterator -: public virtual ZQE::Visitor_Expr_DoMakeIterator +: public virtual ZQE::Visitor_Expr_Rel_DoMakeIterator , public virtual ZQL::Visitor_Expr_Rel_Unary_Restrict , public virtual ZQL::Visitor_Expr_Rel_Concrete { public: -// Via ZQE::Visitor_Expr_DoMakeIterator +// Via ZQE::Visitor_Expr_Rel_DoMakeIterator virtual void Visit_Expr_Rel_Unary_Select( - ZRef<ZQL::Expr_Rel_Unary_Select> iRep); + ZRef<ZQL::Expr_Rel_Unary_Select> iExpr); // From ZQL::Visitor_Expr_Rel_Unary_Restrict virtual void Visit_Expr_Rel_Unary_Restrict( - ZRef<ZQL::Expr_Rel_Unary_Restrict> iRep); + ZRef<ZQL::Expr_Rel_Unary_Restrict> iExpr); // From ZQL::Visitor_Expr_Rel_Concrete - virtual void Visit_Expr_Rel_Concrete(ZRef<ZQL::Expr_Rel_Concrete> iRep); + virtual void Visit_Expr_Rel_Concrete(ZRef<ZQL::Expr_Rel_Concrete> iExpr); }; void Visitor_DoMakeIterator::Visit_Expr_Rel_Unary_Select( - ZRef<ZQL::Expr_Rel_Unary_Select> iRep) + ZRef<ZQL::Expr_Rel_Unary_Select> iExpr) { - if (ZRef<ZQE::Iterator> theIterator = this->DoMakeIterator(iRep->GetExpr_Rel())) - fIterator = new ZQE::Iterator_Any_Select(iRep->GetExpr_Logic(), theIterator); + if (ZRef<ZQE::Iterator> theIterator = this->DoMakeIterator(iExpr->GetExpr_Rel())) + fIterator = new ZQE::Iterator_Any_Select(iExpr->GetExpr_Logic(), theIterator); } void Visitor_DoMakeIterator::Visit_Expr_Rel_Unary_Restrict( - ZRef<ZQL::Expr_Rel_Unary_Restrict> iRep) + ZRef<ZQL::Expr_Rel_Unary_Restrict> iExpr) { - if (ZRef<ZQE::Iterator> theIterator = this->DoMakeIterator(iRep->GetExpr_Rel())) - fIterator = new ZQE::Iterator_Any_Restrict(iRep->GetValCondition(), theIterator); + if (ZRef<ZQE::Iterator> theIterator = this->DoMakeIterator(iExpr->GetExpr_Rel())) + fIterator = new ZQE::Iterator_Any_Restrict(iExpr->GetValCondition(), theIterator); } void Visitor_DoMakeIterator::Visit_Expr_Rel_Concrete( - ZRef<ZQL::Expr_Rel_Concrete> iRep) + ZRef<ZQL::Expr_Rel_Concrete> iExpr) { - if (ZRef<Expr_Rel_Concrete> theRep = iRep.DynamicCast<Expr_Rel_Concrete>()) - fIterator = theRep->MakeIterator(); + if (ZRef<Expr_Rel_Concrete> theExpr = iExpr.DynamicCast<Expr_Rel_Concrete>()) + fIterator = theExpr->MakeIterator(); } } // anonymous namespace @@ -92,20 +89,20 @@ class Expr_Rel_Concrete_Dummy : public ZQL::Expr_Rel_Concrete { public: - Expr_Rel_Concrete_Dummy(const ZRelHead& iRelHead); + Expr_Rel_Concrete_Dummy(const ZQL::RelHead& iRelHead); -// From Expr_Rel via Expr_Rel_Concrete - virtual ZRelHead GetRelHead(); +// From ZQL::Expr_Rel_Concrete + virtual ZQL::RelHead GetRelHead(); private: - ZRelHead fRelHead; + const ZQL::RelHead fRelHead; }; -Expr_Rel_Concrete_Dummy::Expr_Rel_Concrete_Dummy(const ZRelHead& iRelHead) +Expr_Rel_Concrete_Dummy::Expr_Rel_Concrete_Dummy(const ZQL::RelHead& iRelHead) : fRelHead(iRelHead) {} -ZRelHead Expr_Rel_Concrete_Dummy::GetRelHead() +ZQL::RelHead Expr_Rel_Concrete_Dummy::GetRelHead() { return fRelHead; } // ================================================================================================= @@ -115,10 +112,10 @@ ZRef<ZQL::Expr_Rel> sConcrete() { // Put this outside of ZValBase? Perhaps over in ZQL? - return sConcrete(ZRelHead(true)); + return sConcrete(ZQL::RelHead(true)); } -ZRef<ZQL::Expr_Rel> sConcrete(const ZRelHead& iRelHead) +ZRef<ZQL::Expr_Rel> sConcrete(const ZQL::RelHead& iRelHead) { return new Expr_Rel_Concrete_Dummy(iRelHead); } ZRef<ZQE::Iterator> sIterator(ZRef<ZQL::Expr_Rel> iExpr) Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -38,9 +38,6 @@ Expr_Rel_Concrete(); public: -// From Expr_Rel via Expr_Rel_Concrete - virtual ZRelHead GetRelHead(); - // Our protocol virtual ZRef<ZQE::Iterator> MakeIterator() = 0; }; @@ -50,7 +47,7 @@ #pragma mark * ZValBase pseudo constructors ZRef<ZQL::Expr_Rel> sConcrete(); -ZRef<ZQL::Expr_Rel> sConcrete(const ZRelHead& iRelHead); +ZRef<ZQL::Expr_Rel> sConcrete(const ZQL::RelHead& iRelHead); ZRef<ZQE::Iterator> sIterator(ZRef<ZQL::Expr_Rel> iExpr); Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_Any.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_Any.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -79,6 +79,9 @@ public: Expr_Rel_Concrete(const ZSeq_Any& iSeq); +// From ZQL::Expr_Rel_Concrete via ZValBase::Expr_Rel_Concrete + virtual ZQL::RelHead GetRelHead(); + // From ZValBase::Expr_Rel_Concrete virtual ZRef<ZQE::Iterator> MakeIterator(); @@ -90,6 +93,9 @@ : fSeq(iSeq) {} +ZQL::RelHead Expr_Rel_Concrete::GetRelHead() + { return ZQL::RelHead(true); } + ZRef<ZQE::Iterator> Expr_Rel_Concrete::MakeIterator() { return new Iterator(fSeq); } Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_SQLite.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_SQLite.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_SQLite.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -83,8 +83,8 @@ public: Expr_Rel_Concrete(ZRef<ConcreteDomain> iConcreteDomain, ZRef<Iter> iIter); -// From ExprRel via ZValBase::Expr_Rel_Concrete - virtual ZRelHead GetRelHead(); +// From ZQL::Expr_Rel_Concrete via ZValBase::Expr_Rel_Concrete + virtual ZQL::RelHead GetRelHead(); // From ZValBase::Expr_Rel_Concrete virtual ZRef<ZQE::Iterator> MakeIterator(); @@ -99,9 +99,9 @@ , fIter(iIter) {} -ZRelHead Expr_Rel_Concrete::GetRelHead() +ZQL::RelHead Expr_Rel_Concrete::GetRelHead() { - ZRelHead result; + ZQL::RelHead result; for (size_t x = 0; x < fIter->Count(); ++x) result.Insert(fIter->NameOf(x)); return result; Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqR.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -37,6 +37,9 @@ public: Expr_Rel_Concrete(ZRef<ZYadSeqR> iYadSeqR); +// From ZQL::Expr_Rel_Concrete via ZValBase::Expr_Rel_Concrete + virtual ZQL::RelHead GetRelHead(); + // From ZValBase::Expr_Rel_Concrete virtual ZRef<ZQE::Iterator> MakeIterator(); @@ -90,6 +93,9 @@ : fYadSeqR(iYadSeqR) {} +ZQL::RelHead Expr_Rel_Concrete::GetRelHead() + { return ZQL::RelHead(true); } + ZRef<ZQE::Iterator> Expr_Rel_Concrete::MakeIterator() { return new Iterator(this, 0); } Modified: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -70,6 +70,9 @@ public: Expr_Rel_Concrete(ZRef<ZYadSeqRPos> iYadSeqRPos); +// From ZQL::Expr_Rel_Concrete via ZValBase::Expr_Rel_Concrete + virtual ZQL::RelHead GetRelHead(); + // From ZValBase::Expr_Rel_Concrete virtual ZRef<ZQE::Iterator> MakeIterator(); @@ -81,6 +84,9 @@ : fYadSeqRPos(iYadSeqRPos) {} +ZQL::RelHead Expr_Rel_Concrete::GetRelHead() + { return ZQL::RelHead(true); } + ZRef<ZQE::Iterator> Expr_Rel_Concrete::MakeIterator() { return new Iterator(fYadSeqRPos); } Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Iterator.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Iterator.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Iterator.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -90,8 +90,8 @@ } } -Iterator_Intersect::Iterator_Intersect(ZRef<Iterator> iIterator_LHS, - ZRef<Iterator> iIterator_RHS, ZRef<Iterator> iIterator_RHS_Model) +Iterator_Intersect::Iterator_Intersect(ZRef<Iterator> iIterator_LHS, ZRef<Iterator> iIterator_RHS, + ZRef<Iterator> iIterator_RHS_Model) : fIterator_LHS(iIterator_LHS) , fIterator_RHS(iIterator_RHS) , fIterator_RHS_Model(iIterator_RHS_Model) @@ -148,8 +148,8 @@ } } -Iterator_Join::Iterator_Join(ZRef<Iterator> iIterator_LHS, - ZRef<Iterator> iIterator_RHS, ZRef<Iterator> iIterator_RHS_Model) +Iterator_Join::Iterator_Join(ZRef<Iterator> iIterator_LHS, ZRef<Iterator> iIterator_RHS, + ZRef<Iterator> iIterator_RHS_Model) : fIterator_LHS(iIterator_LHS) , fIterator_RHS(iIterator_RHS) , fIterator_RHS_Model(iIterator_RHS_Model) Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Iterator.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Iterator.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Iterator.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -58,8 +58,8 @@ virtual ZRef<Result> ReadInc(); private: - Iterator_Intersect(ZRef<Iterator> iIterator_LHS, - ZRef<Iterator> iIterator_RHS, ZRef<Iterator> iIterator_RHS_Model); + Iterator_Intersect(ZRef<Iterator> iIterator_LHS, ZRef<Iterator> iIterator_RHS, + ZRef<Iterator> iIterator_RHS_Model); ZRef<Iterator> fIterator_LHS; ZRef<Iterator> fIterator_RHS; @@ -80,8 +80,8 @@ virtual ZRef<Result> ReadInc(); private: - Iterator_Join(ZRef<Iterator> iIterator_LHS, - ZRef<Iterator> iIterator_RHS, ZRef<Iterator> iIterator_RHS_Model); + Iterator_Join(ZRef<Iterator> iIterator_LHS, ZRef<Iterator> iIterator_RHS, + ZRef<Iterator> iIterator_RHS_Model); ZRef<Iterator> fIterator_LHS; ZRef<Iterator> fIterator_RHS; Deleted: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -1,93 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.h" - -NAMESPACE_ZOOLIB_BEGIN -namespace ZQE { - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_DoMakeIterator - -void Visitor_Expr_DoMakeIterator::Visit_Expr_Rel_Binary_Difference( - ZRef<ZQL::Expr_Rel_Binary_Difference> iRep) - {} - -void Visitor_Expr_DoMakeIterator::Visit_Expr_Rel_Binary_Intersect( - ZRef<ZQL::Expr_Rel_Binary_Intersect> iRep) - { - if (ZRef<Iterator> lhs = this->DoMakeIterator(iRep->GetLHS())) - { - if (ZRef<Iterator> rhs = this->DoMakeIterator(iRep->GetRHS())) - fIterator = new Iterator_Intersect(lhs, rhs); - } - } - -void Visitor_Expr_DoMakeIterator::Visit_Expr_Rel_Binary_Join(ZRef<ZQL::Expr_Rel_Binary_Join> iRep) - { - if (ZRef<Iterator> lhs = this->DoMakeIterator(iRep->GetLHS())) - { - if (ZRef<Iterator> rhs = this->DoMakeIterator(iRep->GetRHS())) - fIterator = new Iterator_Join(lhs, rhs); - } - } - -void Visitor_Expr_DoMakeIterator::Visit_Expr_Rel_Binary_Union( - ZRef<ZQL::Expr_Rel_Binary_Union> iRep) - { - if (ZRef<Iterator> lhs = this->DoMakeIterator(iRep->GetLHS())) - { - if (ZRef<Iterator> rhs = this->DoMakeIterator(iRep->GetRHS())) - fIterator = new Iterator_Union(lhs, rhs); - else - fIterator = lhs; - } - } - -void Visitor_Expr_DoMakeIterator::Visit_Expr_Rel_Unary_Project( - ZRef<ZQL::Expr_Rel_Unary_Project> iRep) - { - ZUnimplemented(); - } - -void Visitor_Expr_DoMakeIterator::Visit_Expr_Rel_Unary_Rename(ZRef<ZQL::Expr_Rel_Unary_Rename> iRep) - { - ZUnimplemented(); - } - -void Visitor_Expr_DoMakeIterator::Visit_Expr_Rel_Unary_Select(ZRef<ZQL::Expr_Rel_Unary_Select> iRep) - { - ZUnimplemented(); - } - -ZRef<Iterator> Visitor_Expr_DoMakeIterator::DoMakeIterator(ZRef<ZExpr> iExpr) - { - ZRef<Iterator> theIterator; - if (iExpr) - { - iExpr->Accept(*this); - theIterator.swap(fIterator); - } - return theIterator; - } - -} // namespace ZQE -NAMESPACE_ZOOLIB_END Deleted: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_DoMakeIterator.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -1,70 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZQE_Visitor_Expr_DoMakeIterator__ -#define __ZQE_Visitor_Expr_DoMakeIterator__ 1 -#include "zconfig.h" - -#include "zoolib/zqe/ZQE_Iterator.h" -#include "zoolib/zql/ZQL_Expr_Rel_Binary_Difference.h" -#include "zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h" -#include "zoolib/zql/ZQL_Expr_Rel_Binary_Join.h" -#include "zoolib/zql/ZQL_Expr_Rel_Binary_Union.h" -#include "zoolib/zql/ZQL_Expr_Rel_Unary_Project.h" -#include "zoolib/zql/ZQL_Expr_Rel_Unary_Rename.h" -#include "zoolib/zql/ZQL_Expr_Rel_Unary_Select.h" - -NAMESPACE_ZOOLIB_BEGIN -namespace ZQE { - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_DoMakeIterator - -class Visitor_Expr_DoMakeIterator -: public virtual ZQL::Visitor_Expr_Rel_Binary_Difference -, public virtual ZQL::Visitor_Expr_Rel_Binary_Intersect -, public virtual ZQL::Visitor_Expr_Rel_Binary_Join -, public virtual ZQL::Visitor_Expr_Rel_Binary_Union -, public virtual ZQL::Visitor_Expr_Rel_Unary_Project -, public virtual ZQL::Visitor_Expr_Rel_Unary_Rename -, public virtual ZQL::Visitor_Expr_Rel_Unary_Select - { -public: - virtual void Visit_Expr_Rel_Binary_Difference(ZRef<ZQL::Expr_Rel_Binary_Difference> iRep); - virtual void Visit_Expr_Rel_Binary_Intersect(ZRef<ZQL::Expr_Rel_Binary_Intersect> iRep); - virtual void Visit_Expr_Rel_Binary_Join(ZRef<ZQL::Expr_Rel_Binary_Join> iRep); - virtual void Visit_Expr_Rel_Binary_Union(ZRef<ZQL::Expr_Rel_Binary_Union> iRep); - - virtual void Visit_Expr_Rel_Unary_Project(ZRef<ZQL::Expr_Rel_Unary_Project> iRep); - virtual void Visit_Expr_Rel_Unary_Rename(ZRef<ZQL::Expr_Rel_Unary_Rename> iRep); - virtual void Visit_Expr_Rel_Unary_Select(ZRef<ZQL::Expr_Rel_Unary_Select> iRep); - -// Our protocol - ZRef<Iterator> DoMakeIterator(ZRef<ZExpr> iExpr); - -protected: - ZRef<Iterator> fIterator; - }; - -} // namespace ZQE -NAMESPACE_ZOOLIB_END - -#endif // __ZQE_Visitor_Expr_DoMakeIterator__ Added: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.cpp (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -0,0 +1,96 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.h" + +NAMESPACE_ZOOLIB_BEGIN +namespace ZQE { + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Rel_DoMakeIterator + +void Visitor_Expr_Rel_DoMakeIterator::Visit_Expr_Rel_Binary_Difference( + ZRef<ZQL::Expr_Rel_Binary_Difference> iExpr) + {} + +void Visitor_Expr_Rel_DoMakeIterator::Visit_Expr_Rel_Binary_Intersect( + ZRef<ZQL::Expr_Rel_Binary_Intersect> iExpr) + { + if (ZRef<Iterator> lhs = this->DoMakeIterator(iExpr->GetLHS())) + { + if (ZRef<Iterator> rhs = this->DoMakeIterator(iExpr->GetRHS())) + fIterator = new Iterator_Intersect(lhs, rhs); + } + } + +void Visitor_Expr_Rel_DoMakeIterator::Visit_Expr_Rel_Binary_Join( + ZRef<ZQL::Expr_Rel_Binary_Join> iExpr) + { + if (ZRef<Iterator> lhs = this->DoMakeIterator(iExpr->GetLHS())) + { + if (ZRef<Iterator> rhs = this->DoMakeIterator(iExpr->GetRHS())) + fIterator = new Iterator_Join(lhs, rhs); + } + } + +void Visitor_Expr_Rel_DoMakeIterator::Visit_Expr_Rel_Binary_Union( + ZRef<ZQL::Expr_Rel_Binary_Union> iExpr) + { + if (ZRef<Iterator> lhs = this->DoMakeIterator(iExpr->GetLHS())) + { + if (ZRef<Iterator> rhs = this->DoMakeIterator(iExpr->GetRHS())) + fIterator = new Iterator_Union(lhs, rhs); + else + fIterator = lhs; + } + } + +void Visitor_Expr_Rel_DoMakeIterator::Visit_Expr_Rel_Unary_Project( + ZRef<ZQL::Expr_Rel_Unary_Project> iExpr) + { + ZUnimplemented(); + } + +void Visitor_Expr_Rel_DoMakeIterator::Visit_Expr_Rel_Unary_Rename( + ZRef<ZQL::Expr_Rel_Unary_Rename> iExpr) + { + ZUnimplemented(); + } + +void Visitor_Expr_Rel_DoMakeIterator::Visit_Expr_Rel_Unary_Select( + ZRef<ZQL::Expr_Rel_Unary_Select> iExpr) + { + ZUnimplemented(); + } + +ZRef<Iterator> Visitor_Expr_Rel_DoMakeIterator::DoMakeIterator(ZRef<ZQL::Expr_Rel> iExpr) + { + ZRef<Iterator> theIterator; + if (iExpr) + { + iExpr->Accept(*this); + theIterator.swap(fIterator); + } + return theIterator; + } + +} // namespace ZQE +NAMESPACE_ZOOLIB_END Added: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.h (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -0,0 +1,70 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZQE_Visitor_Expr_Rel_DoMakeIterator__ +#define __ZQE_Visitor_Expr_Rel_DoMakeIterator__ 1 +#include "zconfig.h" + +#include "zoolib/zqe/ZQE_Iterator.h" +#include "zoolib/zql/ZQL_Expr_Rel_Binary_Difference.h" +#include "zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h" +#include "zoolib/zql/ZQL_Expr_Rel_Binary_Join.h" +#include "zoolib/zql/ZQL_Expr_Rel_Binary_Union.h" +#include "zoolib/zql/ZQL_Expr_Rel_Unary_Project.h" +#include "zoolib/zql/ZQL_Expr_Rel_Unary_Rename.h" +#include "zoolib/zql/ZQL_Expr_Rel_Unary_Select.h" + +NAMESPACE_ZOOLIB_BEGIN +namespace ZQE { + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Rel_DoMakeIterator + +class Visitor_Expr_Rel_DoMakeIterator +: public virtual ZQL::Visitor_Expr_Rel_Binary_Difference +, public virtual ZQL::Visitor_Expr_Rel_Binary_Intersect +, public virtual ZQL::Visitor_Expr_Rel_Binary_Join +, public virtual ZQL::Visitor_Expr_Rel_Binary_Union +, public virtual ZQL::Visitor_Expr_Rel_Unary_Project +, public virtual ZQL::Visitor_Expr_Rel_Unary_Rename +, public virtual ZQL::Visitor_Expr_Rel_Unary_Select + { +public: + virtual void Visit_Expr_Rel_Binary_Difference(ZRef<ZQL::Expr_Rel_Binary_Difference> iExpr); + virtual void Visit_Expr_Rel_Binary_Intersect(ZRef<ZQL::Expr_Rel_Binary_Intersect> iExpr); + virtual void Visit_Expr_Rel_Binary_Join(ZRef<ZQL::Expr_Rel_Binary_Join> iExpr); + virtual void Visit_Expr_Rel_Binary_Union(ZRef<ZQL::Expr_Rel_Binary_Union> iExpr); + + virtual void Visit_Expr_Rel_Unary_Project(ZRef<ZQL::Expr_Rel_Unary_Project> iExpr); + virtual void Visit_Expr_Rel_Unary_Rename(ZRef<ZQL::Expr_Rel_Unary_Rename> iExpr); + virtual void Visit_Expr_Rel_Unary_Select(ZRef<ZQL::Expr_Rel_Unary_Select> iExpr); + +// Our protocol + ZRef<Iterator> DoMakeIterator(ZRef<ZQL::Expr_Rel> iExpr); + +protected: + ZRef<Iterator> fIterator; + }; + +} // namespace ZQE +NAMESPACE_ZOOLIB_END + +#endif // __ZQE_Visitor_Expr_Rel_DoMakeIterator__ Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -50,8 +50,8 @@ #pragma mark - #pragma mark * Visitor_Expr_Rel -void Visitor_Expr_Rel::Visit_Expr_Rel(ZRef<Expr_Rel> iRep) - { ZVisitor_Expr::Visit_Expr(iRep); } +void Visitor_Expr_Rel::Visit_Expr_Rel(ZRef<Expr_Rel> iExpr) + { ZVisitor_Expr::Visit_Expr(iExpr); } } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -23,7 +23,6 @@ #include "zconfig.h" #include "zoolib/ZExpr.h" -#include "zoolib/ZRelHead.h" #include <string> @@ -47,8 +46,6 @@ // Our protocol virtual void Accept_Expr_Rel(Visitor_Expr_Rel& iVisitor); - - virtual ZRelHead GetRelHead() = 0; }; // ================================================================================================= @@ -58,7 +55,7 @@ class Visitor_Expr_Rel : public virtual ZVisitor_Expr { public: - virtual void Visit_Expr_Rel(ZRef<Expr_Rel> iRep); + virtual void Visit_Expr_Rel(ZRef<Expr_Rel> iExpr); }; // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -66,12 +66,12 @@ #pragma mark * Visitor_Expr_Rel_Binary void Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary( - ZRef<Expr_Rel_Binary> iRep) + ZRef<Expr_Rel_Binary> iExpr) { - if (ZRef<Expr_Rel> theRelation = iRep->GetLHS()) + if (ZRef<Expr_Rel> theRelation = iExpr->GetLHS()) theRelation->Accept(*this); - if (ZRef<Expr_Rel> theRelation = iRep->GetRHS()) + if (ZRef<Expr_Rel> theRelation = iExpr->GetRHS()) theRelation->Accept(*this); } Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -65,7 +65,7 @@ class Visitor_Expr_Rel_Binary : public virtual Visitor_Expr_Rel { public: - virtual void Visit_Expr_Rel_Binary(ZRef<Expr_Rel_Binary> iRep); + virtual void Visit_Expr_Rel_Binary(ZRef<Expr_Rel_Binary> iExpr); }; } // namespace ZQL Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Difference.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Difference.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Difference.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -34,9 +34,6 @@ : Expr_Rel_Binary(iLHS, iRHS) {} -ZRelHead Expr_Rel_Binary_Difference::GetRelHead() - { return this->GetLHS()->GetRelHead() | this->GetRHS()->GetRelHead(); } - void Expr_Rel_Binary_Difference::Accept_Expr_Rel_Binary( Visitor_Expr_Rel_Binary& iVisitor) { @@ -64,8 +61,8 @@ #pragma mark * Visitor_Expr_Rel_Binary_Difference void Visitor_Expr_Rel_Binary_Difference::Visit_Expr_Rel_Binary_Difference( - ZRef<Expr_Rel_Binary_Difference> iRep) - { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iRep); } + ZRef<Expr_Rel_Binary_Difference> iExpr) + { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iExpr); } } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Difference.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Difference.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Difference.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -39,9 +39,6 @@ Expr_Rel_Binary_Difference(ZRef<Expr_Rel> iLHS, ZRef<Expr_Rel> iRHS); virtual ~Expr_Rel_Binary_Difference(); -// From Expr_Rel via Expr_Rel_Binary - virtual ZRelHead GetRelHead(); - // From Expr_Rel_Binary virtual void Accept_Expr_Rel_Binary(Visitor_Expr_Rel_Binary& iVisitor); @@ -61,7 +58,7 @@ { public: virtual void Visit_Expr_Rel_Binary_Difference( - ZRef<Expr_Rel_Binary_Difference> iRep); + ZRef<Expr_Rel_Binary_Difference> iExpr); }; } // namespace ZQL Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -34,9 +34,6 @@ : Expr_Rel_Binary(iLHS, iRHS) {} -ZRelHead Expr_Rel_Binary_Intersect::GetRelHead() - { return this->GetLHS()->GetRelHead() | this->GetRHS()->GetRelHead(); } - void Expr_Rel_Binary_Intersect::Accept_Expr_Rel_Binary( Visitor_Expr_Rel_Binary& iVisitor) { @@ -64,8 +61,8 @@ #pragma mark * Visitor_Expr_Rel_Binary_Intersect void Visitor_Expr_Rel_Binary_Intersect::Visit_Expr_Rel_Binary_Intersect( - ZRef<Expr_Rel_Binary_Intersect> iRep) - { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iRep); } + ZRef<Expr_Rel_Binary_Intersect> iExpr) + { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iExpr); } // ================================================================================================= #pragma mark - Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Intersect.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -39,9 +39,6 @@ Expr_Rel_Binary_Intersect(ZRef<Expr_Rel> iLHS, ZRef<Expr_Rel> iRHS); virtual ~Expr_Rel_Binary_Intersect(); -// From Expr_Rel via Expr_Rel_Binary - virtual ZRelHead GetRelHead(); - // From Expr_Rel_Binary virtual void Accept_Expr_Rel_Binary(Visitor_Expr_Rel_Binary& iVisitor); @@ -61,7 +58,7 @@ { public: virtual void Visit_Expr_Rel_Binary_Intersect( - ZRef<Expr_Rel_Binary_Intersect> iRep); + ZRef<Expr_Rel_Binary_Intersect> iExpr); }; // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -37,9 +37,6 @@ Expr_Rel_Binary_Join::~Expr_Rel_Binary_Join() {} -ZRelHead Expr_Rel_Binary_Join::GetRelHead() - { return this->GetLHS()->GetRelHead() | this->GetRHS()->GetRelHead(); } - void Expr_Rel_Binary_Join::Accept_Expr_Rel_Binary( Visitor_Expr_Rel_Binary& iVisitor) { @@ -67,8 +64,8 @@ #pragma mark * Visitor_Expr_Rel_Binary_Join void Visitor_Expr_Rel_Binary_Join::Visit_Expr_Rel_Binary_Join( - ZRef<Expr_Rel_Binary_Join> iRep) - { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iRep); } + ZRef<Expr_Rel_Binary_Join> iExpr) + { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iExpr); } // ================================================================================================= #pragma mark - Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Join.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -39,9 +39,6 @@ Expr_Rel_Binary_Join(ZRef<Expr_Rel> iLHS, ZRef<Expr_Rel> iRHS); virtual ~Expr_Rel_Binary_Join(); -// From Expr_Rel via Expr_Rel_Binary - virtual ZRelHead GetRelHead(); - // From Expr_Rel_Binary virtual void Accept_Expr_Rel_Binary(Visitor_Expr_Rel_Binary& iVisitor); @@ -60,7 +57,7 @@ class Visitor_Expr_Rel_Binary_Join : public virtual Visitor_Expr_Rel_Binary { public: - virtual void Visit_Expr_Rel_Binary_Join(ZRef<Expr_Rel_Binary_Join> iRep); + virtual void Visit_Expr_Rel_Binary_Join(ZRef<Expr_Rel_Binary_Join> iExpr); }; // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -37,9 +37,6 @@ Expr_Rel_Binary_Union::~Expr_Rel_Binary_Union() {} -ZRelHead Expr_Rel_Binary_Union::GetRelHead() - { return this->GetLHS()->GetRelHead() | this->GetRHS()->GetRelHead(); } - void Expr_Rel_Binary_Union::Accept_Expr_Rel_Binary( Visitor_Expr_Rel_Binary& iVisitor) { @@ -67,8 +64,8 @@ #pragma mark * Visitor_Expr_Rel_Binary_Union void Visitor_Expr_Rel_Binary_Union::Visit_Expr_Rel_Binary_Union( - ZRef<Expr_Rel_Binary_Union> iRep) - { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iRep); } + ZRef<Expr_Rel_Binary_Union> iExpr) + { Visitor_Expr_Rel_Binary::Visit_Expr_Rel_Binary(iExpr); } // ================================================================================================= #pragma mark - Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Binary_Union.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -39,9 +39,6 @@ Expr_Rel_Binary_Union(ZRef<Expr_Rel> iLHS, ZRef<Expr_Rel> iRHS); virtual ~Expr_Rel_Binary_Union(); -// From Expr_Rel via Expr_Rel_Binary - virtual ZRelHead GetRelHead(); - // From Expr_Rel_Binary virtual void Accept_Expr_Rel_Binary(Visitor_Expr_Rel_Binary& iVisitor); @@ -60,7 +57,7 @@ class Visitor_Expr_Rel_Binary_Union : public virtual Visitor_Expr_Rel_Binary { public: - virtual void Visit_Expr_Rel_Binary_Union(ZRef<Expr_Rel_Binary_Union> iRep); + virtual void Visit_Expr_Rel_Binary_Union(ZRef<Expr_Rel_Binary_Union> iExpr); }; // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Concrete.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Concrete.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Concrete.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -68,8 +68,8 @@ #pragma mark * Visitor_Expr_Rel_Concrete void Visitor_Expr_Rel_Concrete::Visit_Expr_Rel_Concrete( - ZRef<Expr_Rel_Concrete> iRep) - { ZVisitor_Expr::Visit_Expr(iRep); } + ZRef<Expr_Rel_Concrete> iExpr) + { ZVisitor_Expr::Visit_Expr(iExpr); } } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Concrete.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Concrete.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Concrete.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -23,6 +23,7 @@ #include "zconfig.h" #include "zoolib/zql/ZQL_Expr_Rel.h" +#include "zoolib/zql/ZQL_RelHead.h" NAMESPACE_ZOOLIB_BEGIN namespace ZQL { @@ -58,6 +59,7 @@ // Our protocol virtual void Accept_Expr_Rel_Concrete(Visitor_Expr_Rel_Concrete& iVisitor); + virtual RelHead GetRelHead() = 0; virtual ZRef<ConcreteDomain> GetConcreteDomain(); }; @@ -68,7 +70,7 @@ class Visitor_Expr_Rel_Concrete : public virtual Visitor_Expr_Rel { public: - virtual void Visit_Expr_Rel_Concrete(ZRef<Expr_Rel_Concrete> iRep); + virtual void Visit_Expr_Rel_Concrete(ZRef<Expr_Rel_Concrete> iExpr); }; } // namespace ZQL Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -59,9 +59,9 @@ #pragma mark - #pragma mark * Visitor_Expr_Rel_Unary -void Visitor_Expr_Rel_Unary::Visit_Expr_Rel_Unary(ZRef<Expr_Rel_Unary> iRep) +void Visitor_Expr_Rel_Unary::Visit_Expr_Rel_Unary(ZRef<Expr_Rel_Unary> iExpr) { - if (ZRef<Expr_Rel> theRelation = iRep->GetExpr_Rel()) + if (ZRef<Expr_Rel> theRelation = iExpr->GetExpr_Rel()) theRelation->Accept(*this); } Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -62,7 +62,7 @@ class Visitor_Expr_Rel_Unary : public virtual Visitor_Expr_Rel { public: - virtual void Visit_Expr_Rel_Unary(ZRef<Expr_Rel_Unary> iRep); + virtual void Visit_Expr_Rel_Unary(ZRef<Expr_Rel_Unary> iExpr); }; } // namespace ZQL Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -30,7 +30,7 @@ #pragma mark * Expr_Rel_Unary_Project Expr_Rel_Unary_Project::Expr_Rel_Unary_Project( - const ZRef<Expr_Rel>& iExpr_Rel, const ZRelHead& iRelHead) + const ZRef<Expr_Rel>& iExpr_Rel, const RelHead& iRelHead) : Expr_Rel_Unary(iExpr_Rel) , fRelHead(iRelHead) {} @@ -38,9 +38,6 @@ Expr_Rel_Unary_Project::~Expr_Rel_Unary_Project() {} -ZRelHead Expr_Rel_Unary_Project::GetRelHead() - { return this->GetExpr_Rel()->GetRelHead() & fRelHead; } - void Expr_Rel_Unary_Project::Accept_Expr_Rel_Unary( Visitor_Expr_Rel_Unary& iVisitor) { @@ -63,7 +60,7 @@ Visitor_Expr_Rel_Unary_Project& iVisitor) { iVisitor.Visit_Expr_Rel_Unary_Project(this); } -ZRelHead Expr_Rel_Unary_Project::GetProjectRelHead() +RelHead Expr_Rel_Unary_Project::GetRelHead() { return fRelHead; } // ================================================================================================= @@ -71,20 +68,20 @@ #pragma mark * Visitor_Expr_Rel_Unary_Project void Visitor_Expr_Rel_Unary_Project::Visit_Expr_Rel_Unary_Project( - ZRef<Expr_Rel_Unary_Project> iRep) - { Visitor_Expr_Rel_Unary::Visit_Expr_Rel_Unary(iRep); } + ZRef<Expr_Rel_Unary_Project> iExpr) + { Visitor_Expr_Rel_Unary::Visit_Expr_Rel_Unary(iExpr); } // ================================================================================================= #pragma mark - #pragma mark * Relational operators -ZRef<Expr_Rel_Unary_Project> sProject(const ZRef<Expr_Rel>& iExpr, const ZRelHead& iRelHead) +ZRef<Expr_Rel_Unary_Project> sProject(const ZRef<Expr_Rel>& iExpr, const RelHead& iRelHead) { return new Expr_Rel_Unary_Project(iExpr, iRelHead); } -ZRef<Expr_Rel_Unary_Project> operator&(const ZRef<Expr_Rel>& iExpr, const ZRelHead& iRelHead) +ZRef<Expr_Rel_Unary_Project> operator&(const ZRef<Expr_Rel>& iExpr, const RelHead& iRelHead) { return new Expr_Rel_Unary_Project(iExpr, iRelHead); } -ZRef<Expr_Rel_Unary_Project> operator&(const ZRelHead& iRelHead, const ZRef<Expr_Rel>& iExpr) +ZRef<Expr_Rel_Unary_Project> operator&(const RelHead& iRelHead, const ZRef<Expr_Rel>& iExpr) { return new Expr_Rel_Unary_Project(iExpr, iRelHead); } } // namespace ZQL Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.h 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Project.h 2010-04-12 04:23:59 UTC (rev 1295) @@ -23,6 +23,7 @@ #include "zconfig.h" #include "zoolib/zql/ZQL_Expr_Rel_Unary.h" +#include "zoolib/zql/ZQL_RelHead.h" NAMESPACE_ZOOLIB_BEGIN namespace ZQL { @@ -37,13 +38,10 @@ { public: Expr_Rel_Unary_Project( - const ZRef<Expr_Rel>& iExpr_Rel, const ZRelHead& iRelHead); + const ZRef<Expr_Rel>& iExpr_Rel, const RelHead& iRelHead); virtual ~Expr_Rel_Unary_Project(); -// From Expr_Rel via Expr_Rel_Unary - virtual ZRelHead GetRelHead(); - // From Expr_Rel_Unary virtual void Accept_Expr_Rel_Unary(Visitor_Expr_Rel_Unary& iVisitor); @@ -53,10 +51,10 @@ virtual void Accept_Expr_Rel_Unary_Project( Visitor_Expr_Rel_Unary_Project& iVisitor); - ZRelHead GetProjectRelHead(); + RelHead GetRelHead(); private: - const ZRelHead fRelHead; + const RelHead fRelHead; }; // ================================================================================================= @@ -66,18 +64,18 @@ class Visitor_Expr_Rel_Unary_Project : public virtual Visitor_Expr_Rel_Unary { public: - virtual void Visit_Expr_Rel_Unary_Project(ZRef<Expr_Rel_Unary_Project> iRep); + virtual void Visit_Expr_Rel_Unary_Project(ZRef<Expr_Rel_Unary_Project> iExpr); }; // ================================================================================================= #pragma mark - #pragma mark * Relational operators -ZRef<Expr_Rel_Unary_Project> sProject(const ZRef<Expr_Rel>& iExpr, const ZRelHead& iRelHead); +ZRef<Expr_Rel_Unary_Project> sProject(const ZRef<Expr_Rel>& iExpr, const RelHead& iRelHead); -ZRef<Expr_Rel_Unary_Project> operator&(const ZRef<Expr_Rel>& iExpr, const ZRelHead& iRelHead); +ZRef<Expr_Rel_Unary_Project> operator&(const ZRef<Expr_Rel>& iExpr, const RelHead& iRelHead); -ZRef<Expr_Rel_Unary_Project> operator&(const ZRelHead& iRelHead, const ZRef<Expr_Rel>& iExpr); +ZRef<Expr_Rel_Unary_Project> operator&(const RelHead& iRelHead, const ZRef<Expr_Rel>& iExpr); } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.cpp 2010-04-11 20:12:03 UTC (rev 1294) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_Expr_Rel_Unary_Rename.cpp 2010-04-12 04:23:59 UTC (rev 1295) @@ -39,17 +39,6 @@ Expr_Rel_Unary_Rename::~Expr_Rel_Unary_Rename() {} -ZRelHead Expr_Rel_Unary_Rename::GetRelHead() - { - ZRelHead theRelHead = this->GetExpr_Rel()->GetRelHead(); - if (theRelHead.Contains(fOld)) - { - theRelHead -= fOld; - theRelHead |= fNew; - } - return theRelHead; - } - void Expr_Rel_Unary_Rename::Accept_Expr_Rel_Unary( Visitor_Expr_Rel_Unary& iVisitor) { @@ -83,8 +72,8 @@ #pragma mark * Visitor_Expr_Rel_Unary_Rename void Visitor_Expr_Rel_Unary_Rename::Visit_Expr_Rel_Unary_Rename( - ZRef<Expr_Rel_Unary_Rename> iRep) - { Visitor_Expr_Rel_Unary::Visit_Expr_Rel_Unary(iRep); } + ZRef<Expr_Rel_Unary_Rename> iExpr) + { Visitor_E... [truncated message content] |
From: <ag...@us...> - 2010-04-23 14:53:04
|
Revision: 1332 http://zoolib.svn.sourceforge.net/zoolib/?rev=1332&view=rev Author: agreen Date: 2010-04-23 14:52:57 +0000 (Fri, 23 Apr 2010) Log Message: ----------- Use Rename_t rather than map<string, string>. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.h trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_SQL.cpp trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_SQL.h trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h Modified: trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp 2010-04-23 14:51:53 UTC (rev 1331) +++ trunk/zoolib/source/cxx/more/zoolib/tql/ZTQLTest.cpp 2010-04-23 14:52:57 UTC (rev 1332) @@ -46,9 +46,9 @@ ZVisitor_DoToStrim::Options theOptions; theOptions.fInitialIndent = 1; - const map<string8, string8>& theMap = iExpr->GetRenameMap(); + const Rename_t& theRename = iExpr->GetRename(); s << "Renames:\n"; - for (map<string8, string8>::const_iterator i = theMap.begin(); i != theMap.end(); ++i) + for (Rename_t::const_iterator i = theRename.begin(); i != theRename.end(); ++i) s << " " << (*i).second << "<--" << (*i).first << "\n" ; s << "Relhead:\n "; Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.cpp 2010-04-23 14:51:53 UTC (rev 1331) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_Expr_Rel_DoMakeIterator.cpp 2010-04-23 14:52:57 UTC (rev 1332) @@ -29,7 +29,9 @@ void Visitor_Expr_Rel_DoMakeIterator::Visit_Expr_Rel_Difference( ZRef<ZQL::Expr_Rel_Difference> iExpr) - {} + { + ZUnimplemented(); + } void Visitor_Expr_Rel_DoMakeIterator::Visit_Expr_Rel_Intersect(ZRef<ZQL::Expr_Rel_Intersect> iExpr) { Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.cpp 2010-04-23 14:51:53 UTC (rev 1331) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.cpp 2010-04-23 14:52:57 UTC (rev 1332) @@ -23,7 +23,19 @@ NAMESPACE_ZOOLIB_BEGIN namespace ZQL { +// ================================================================================================= +#pragma mark - +#pragma mark * Rename_t +Rename_t sInvert(const Rename_t& iRename) + { + Rename_t result; + for (Rename_t::const_iterator i = iRename.begin(); i != iRename.end(); ++i) + result[(*i).second] = (*i).first; + + return result; + } + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.h 2010-04-23 14:51:53 UTC (rev 1331) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_RelHead.h 2010-04-23 14:52:57 UTC (rev 1332) @@ -25,6 +25,7 @@ #include "zoolib/ZUniSet_T.h" #include <string> +#include <map> NAMESPACE_ZOOLIB_BEGIN namespace ZQL { @@ -56,6 +57,14 @@ inline RelHead operator^(const RelHead& iRelHead, const char* iElem) { return iRelHead ^ std::string(iElem); } +// ================================================================================================= +#pragma mark - +#pragma mark * Rename_t + +typedef std::map<std::string, std::string> Rename_t; + +Rename_t sInvert(const Rename_t& iRename); + } // namespace ZQL NAMESPACE_ZOOLIB_END Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_SQL.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_SQL.cpp 2010-04-23 14:51:53 UTC (rev 1331) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_SQL.cpp 2010-04-23 14:52:57 UTC (rev 1332) @@ -18,13 +18,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------------------------- */ -#include "zoolib/ZVisitor_Expr_Logic_ValCondition_DoToStrim.h" -#include "zoolib/ZVisitor_Expr_Op_DoTransform_T.h" #include "zoolib/ZExpr_Logic_ValCondition.h" #include "zoolib/ZStrim.h" #include "zoolib/ZStrim_Escaped.h" #include "zoolib/ZTime.h" #include "zoolib/ZUtil_Strim.h" +#include "zoolib/ZVisitor_Expr_Logic_ValCondition_DoToStrim.h" +#include "zoolib/ZVisitor_Expr_Op_DoTransform_T.h" #include "zoolib/zql/ZQL_Expr_Rel_Join.h" #include "zoolib/zql/ZQL_Expr_Rel_Project.h" @@ -45,12 +45,10 @@ // ================================================================================================= #pragma mark - -#pragma mark * Anonymous +#pragma mark * DoRename namespace ZANONYMOUS { -typedef map<string8, string8> Rename_t; - class DoRename : public virtual ZVisitor_Expr_Op_DoTransform_T<ZExpr_Logic> , public virtual ZVisitor_Expr_Logic_ValCondition @@ -76,6 +74,14 @@ this->pSetResult(iExpr); } +} // anonymous namespace + +// ================================================================================================= +#pragma mark - +#pragma mark * Doer + +namespace ZANONYMOUS { + class Doer : public virtual ZVisitor_Expr_Op_DoTransform_T<Expr_Rel_SFW> , public virtual ZQL::Visitor_Expr_Rel_Join @@ -118,8 +124,8 @@ ZRef<Expr_Rel_SFW> sfw0 = this->Do(iExpr->GetOp0()); ZRef<Expr_Rel_SFW> sfw1 = this->Do(iExpr->GetOp1()); - Rename_t theRename = sfw0->GetRenameMap(); - const Rename_t& theRename1 = sfw1->GetRenameMap(); + Rename_t theRename = sfw0->GetRename(); + const Rename_t& theRename1 = sfw1->GetRename(); theRename.insert(theRename1.begin(), theRename1.end()); vector<ZRef<Expr_Rel_Concrete> > rels = sfw0->GetRels(); @@ -152,7 +158,7 @@ ZRef<Expr_Rel_SFW> sfw0 = this->Do(iExpr->GetOp0()); ZRef<Expr_Rel_SFW> result = new Expr_Rel_SFW( - sfw0->GetRenameMap(), + sfw0->GetRename(), sfw0->GetRelHead() & iExpr->GetRelHead(), sfw0->GetCondition(), sfw0->GetRels()); @@ -176,7 +182,7 @@ const string8& oldName = iExpr->GetOld(); const string8& newName = iExpr->GetNew(); - Rename_t theRename = sfw0->GetRenameMap(); + Rename_t theRename = sfw0->GetRename(); bool foundIt = false; for (Rename_t::iterator i = theRename.begin(); i != theRename.end(); /*no inc*/) { @@ -199,33 +205,24 @@ this->pSetResult(result); } -static Rename_t spInvert(const Rename_t& iRename) - { - Rename_t result; - for (Rename_t::const_iterator i = iRename.begin(); i != iRename.end(); ++i) - result[(*i).second] = (*i).first; - - return result; - } - static ZValCondition spRenamedInverse( const ZValCondition& iValCondition, const Rename_t& iRename) { ZValCondition result; - if (iValCondition.Renamed(spInvert(iRename), result)) + if (iValCondition.Renamed(sInvert(iRename), result)) return result; return iValCondition; } static ZRef<ZExpr_Logic> spRenamedInverse( ZRef<ZExpr_Logic> iExpr_Logic, const Rename_t& iRename) - { return DoRename(spInvert(iRename)).Do(iExpr_Logic); } + { return DoRename(sInvert(iRename)).Do(iExpr_Logic); } void Doer::Visit_Expr_Rel_Restrict(ZRef<Expr_Rel_Restrict> iExpr) { ZRef<Expr_Rel_SFW> sfw0 = this->Do(iExpr->GetOp0()); - const Rename_t& theRename = sfw0->GetRenameMap(); + const Rename_t& theRename = sfw0->GetRename(); ZRef<Expr_Rel_SFW> result = new Expr_Rel_SFW( theRename, sfw0->GetRelHead(), @@ -239,7 +236,7 @@ { ZRef<Expr_Rel_SFW> sfw0 = this->Do(iExpr->GetOp0()); - const Rename_t& theRename = sfw0->GetRenameMap(); + const Rename_t& theRename = sfw0->GetRename(); ZRef<Expr_Rel_SFW> result = new Expr_Rel_SFW( theRename, sfw0->GetRelHead(), @@ -249,17 +246,17 @@ this->pSetResult(result); } -} // namespace ZANONYMOUS +} // anonymous namespace // ================================================================================================= #pragma mark - #pragma mark * Expr_Rel_SFW -Expr_Rel_SFW::Expr_Rel_SFW(const map<string8, string8>& iRenameMap, +Expr_Rel_SFW::Expr_Rel_SFW(const Rename_t& iRename, const RelHead& iRelHead, ZRef<ZExpr_Logic> iCondition, const vector<ZRef<Expr_Rel_Concrete> >& iRels) -: fRenameMap(iRenameMap) +: fRename(iRename) , fRelHead(iRelHead) , fCondition(iCondition) , fRels(iRels) @@ -268,8 +265,8 @@ RelHead Expr_Rel_SFW::GetRelHead() { return fRelHead; } -const map<string8, string8>& Expr_Rel_SFW::GetRenameMap() - { return fRenameMap; } +const Rename_t& Expr_Rel_SFW::GetRename() + { return fRename; } ZRef<ZExpr_Logic> Expr_Rel_SFW::GetCondition() { return fCondition; } @@ -279,11 +276,15 @@ // ================================================================================================= #pragma mark - -#pragma mark * ZQL::SQL +#pragma mark * ZQL::SQL::sConvert ZRef<Expr_Rel_SFW> sConvert(ZRef<Expr_Rel> iExpr) { return Doer().Do(iExpr); } +// ================================================================================================= +#pragma mark - +#pragma mark * ToStrim_SQL + namespace ZANONYMOUS { class ToStrim_SQL @@ -481,16 +482,18 @@ } // anonymous namespace -string8 sAsSQL(ZRef<Expr_Rel_SFW> iSFW) +// ================================================================================================= +#pragma mark - +#pragma mark * ZQL::SQL::sConvert + +void sAsSQL(ZRef<Expr_Rel_SFW> iSFW, const ZStrimW& s) { - string8 result; - ZStrimW_String s(result); if (iSFW) { s << "SELECT"; const RelHead& theRelHead = iSFW->GetRelHead(); - const Rename_t theRename = spInvert(iSFW->GetRenameMap()); + const Rename_t theRename = sInvert(iSFW->GetRename()); bool universal; const set<string8>& names = theRelHead.GetElems(universal); @@ -542,6 +545,12 @@ ToStrim_SQL().DoToStrim(ToStrim_SQL::Options(), s, iSFW->GetCondition()); s << ";"; } + } + +string8 sAsSQL(ZRef<Expr_Rel_SFW> iSFW) + { + string8 result; + sAsSQL(iSFW, ZStrimW_String(result)); return result; } Modified: trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_SQL.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_SQL.h 2010-04-23 14:51:53 UTC (rev 1331) +++ trunk/zoolib/source/cxx/more/zoolib/zql/ZQL_SQL.h 2010-04-23 14:52:57 UTC (rev 1332) @@ -39,7 +39,7 @@ class Expr_Rel_SFW : public Expr_Rel_Concrete { public: - Expr_Rel_SFW(const std::map<string8, string8>& iRenameMap, + Expr_Rel_SFW(const Rename_t& iRename, const RelHead& iRelHead, ZRef<ZExpr_Logic> iCondition, const std::vector<ZRef<Expr_Rel_Concrete> >& iRels); @@ -48,12 +48,12 @@ virtual RelHead GetRelHead(); // Our protocol - const std::map<string8, string8>& GetRenameMap(); + const Rename_t& GetRename(); ZRef<ZExpr_Logic> GetCondition(); const std::vector<ZRef<Expr_Rel_Concrete> >& GetRels(); public: - const std::map<string8, string8> fRenameMap; + const Rename_t fRename; const RelHead fRelHead; const ZRef<ZExpr_Logic> fCondition; const std::vector<ZRef<Expr_Rel_Concrete> > fRels; @@ -65,6 +65,7 @@ ZRef<Expr_Rel_SFW> sConvert(ZRef<Expr_Rel> iExpr); +void sAsSQL(ZRef<Expr_Rel_SFW> iSFW, const ZStrimW& s); string8 sAsSQL(ZRef<Expr_Rel_SFW> iSFW); } // namespace SQL Modified: trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h 2010-04-23 14:51:53 UTC (rev 1331) +++ trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h 2010-04-23 14:52:57 UTC (rev 1332) @@ -30,6 +30,10 @@ NAMESPACE_ZOOLIB_BEGIN +// There is an equivalent typedef in ZQL_RelHead, and it's possible that it +// should be promoted to its own file, but for now that seems excessive. +typedef std::map<std::string, std::string> Rename_t; + class ZValContext {}; @@ -176,7 +180,7 @@ virtual Val Imp_GetVal(ZValContext& iContext, const Val& iVal) = 0; virtual std::set<std::string> GetNames(); - virtual ZRef<ZValComparandRep_T> Renamed(const std::map<std::string, std::string>& iRenameMap); + virtual ZRef<ZValComparandRep_T> Renamed(const Rename_t& iRename); }; template <class Val> @@ -192,8 +196,7 @@ { return std::set<std::string>(); } template <class Val> -ZRef<ZValComparandRep_T<Val> > ZValComparandRep_T<Val>::Renamed( - const std::map<std::string, std::string>& iRenameMap) +ZRef<ZValComparandRep_T<Val> > ZValComparandRep_T<Val>::Renamed(const Rename_t& iRename) { return this; } // ================================================================================================= @@ -243,7 +246,7 @@ virtual Val Imp_GetVal(ZValContext& iContext, const Val& iVal); virtual std::set<std::string> GetNames(); virtual ZRef<ZValComparandRep_T<Val> > Renamed( - const std::map<std::string, std::string>& iRenameMap); + const Rename_t& iRename); // Our protocol const ZTrail& GetTrail(); @@ -282,13 +285,13 @@ template <class Val> ZRef<ZValComparandRep_T<Val> > ZValComparandRep_Trail_T<Val>::Renamed( - const std::map<std::string, std::string>& iRenameMap) + const Rename_t& iRename) { if (fTrail.Count()) { std::string theName = fTrail.At(0); - std::map<std::string, std::string>::const_iterator i = iRenameMap.find(theName); - if (i != iRenameMap.end()) + Rename_t::const_iterator i = iRename.find(theName); + if (i != iRename.end()) return new ZValComparandRep_Trail_T((*i).second + fTrail.SubTrail(1)); } return this; @@ -388,8 +391,7 @@ std::set<std::string> GetNames() const; - bool Renamed( - const std::map<std::string, std::string>& iRenameMap, ZValCondition_T& oResult) const; + bool Renamed(const Rename_t& iRename, ZValCondition_T& oResult) const; private: ZValComparand_T<Val> fLHS; @@ -456,11 +458,10 @@ { return ZUtil_STL_set::sOr(fLHS.GetNames(), fRHS.GetNames()); } template <class Val> -bool ZValCondition_T<Val>::Renamed( - const std::map<std::string, std::string>& iRenameMap, ZValCondition_T& oResult) const +bool ZValCondition_T<Val>::Renamed(const Rename_t& iRename, ZValCondition_T& oResult) const { - ZRef<ZValComparandRep_T<Val> > newLHS = fLHS->Renamed(iRenameMap); - ZRef<ZValComparandRep_T<Val> > newRHS = fRHS->Renamed(iRenameMap); + ZRef<ZValComparandRep_T<Val> > newLHS = fLHS->Renamed(iRename); + ZRef<ZValComparandRep_T<Val> > newRHS = fRHS->Renamed(iRename); if (newLHS == fLHS && newRHS == fRHS) return false; oResult = ZValCondition_T(newLHS, fComparator, newRHS); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2010-05-27 19:28:20
|
Revision: 1382 http://zoolib.svn.sourceforge.net/zoolib/?rev=1382&view=rev Author: agreen Date: 2010-05-27 19:28:12 +0000 (Thu, 27 May 2010) Log Message: ----------- Docs, and ValCondition-->ValPred. Modified Paths: -------------- trunk/zoolib/source/cxx/Doxyfile trunk/zoolib/source/cxx/default_config/zconfig.h trunk/zoolib/source/cxx/more/zoolib/zqe/ReadMe.txt trunk/zoolib/source/cxx/more/zoolib/zra/ReadMe.txt trunk/zoolib/source/cxx/zoolib/Docs_MainPage.txt trunk/zoolib/source/cxx/zoolib/Docs_NamingConvention.txt Added Paths: ----------- trunk/zoolib/source/cxx/zoolib/Docs_BuildingZooLib.txt trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValPred.h trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValPred_T.h trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValPred.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValPred.h trunk/zoolib/source/cxx/zoolib/ZValPred.h trunk/zoolib/source/cxx/zoolib/ZValPredCompound.cpp trunk/zoolib/source/cxx/zoolib/ZValPredCompound.h trunk/zoolib/source/cxx/zoolib/ZValPred_T.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Logic_ValPred_DoEval_Matches_T.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Logic_ValPred_DoGetNames_T.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Logic_ValPred_DoToStrim.cpp trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Logic_ValPred_DoToStrim.h Removed Paths: ------------- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.h trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition.h trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition_T.h trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValCondition.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValCondition.h trunk/zoolib/source/cxx/zoolib/ZValCondition.h trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Logic_ValCondition_DoEval_Matches_T.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Logic_ValCondition_DoGetNames_T.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Logic_ValCondition_DoToStrim.cpp trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Logic_ValCondition_DoToStrim.h Modified: trunk/zoolib/source/cxx/Doxyfile =================================================================== --- trunk/zoolib/source/cxx/Doxyfile 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/Doxyfile 2010-05-27 19:28:12 UTC (rev 1382) @@ -31,7 +31,7 @@ # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.9 +##PROJECT_NUMBER = 0.9 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -105,7 +105,7 @@ # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. -FULL_PATH_NAMES = NO +FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is @@ -314,7 +314,8 @@ # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. -EXTRACT_LOCAL_CLASSES = YES +### +EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in @@ -337,14 +338,16 @@ # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_MEMBERS = YES +###HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_CLASSES = YES +###HIDE_UNDOC_CLASSES = YES +HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. @@ -414,7 +417,8 @@ # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. -SORT_GROUP_NAMES = NO +###SORT_GROUP_NAMES = NO +SORT_GROUP_NAMES = YES # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to @@ -442,7 +446,8 @@ # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. -GENERATE_BUGLIST = YES +###GENERATE_BUGLIST = YES +GENERATE_BUGLIST = NO # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting @@ -475,7 +480,8 @@ # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. -SHOW_DIRECTORIES = NO +###SHOW_DIRECTORIES = NO +SHOW_DIRECTORIES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the @@ -570,8 +576,19 @@ # with spaces. INPUT = \ + ./zoolib/ \ + ./more/zoolib/blackberry/ \ + ./more/zoolib/sqlite/ \ ./more/zoolib/zqe/ \ - ./more/zoolib/zql/ \ + ./more/zoolib/zra/ \ + + +INPUTDIS3 = \ + ./more/zoolib/photoshop/ \ + ./more/zoolib/sqlite/ \ + ./more/zoolib/tuplebase/ \ + ./more/zoolib/zqe/ \ + ./more/zoolib/zra/ \ ./zoolib/ \ INPUT_DIS2 = DoxygenMainPage.txt \ @@ -757,20 +774,23 @@ # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. -ALPHABETICAL_INDEX = NO +###ALPHABETICAL_INDEX = NO +ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) -COLS_IN_ALPHA_INDEX = 5 +###COLS_IN_ALPHA_INDEX = 5 +COLS_IN_ALPHA_INDEX = 3 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +###IGNORE_PREFIX = +IGNORE_PREFIX = Z #--------------------------------------------------------------------------- # configuration options related to the HTML output @@ -826,7 +846,8 @@ # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). -HTML_DYNAMIC_SECTIONS = NO +###HTML_DYNAMIC_SECTIONS = NO +HTML_DYNAMIC_SECTIONS = YES # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 @@ -838,21 +859,22 @@ # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. -GENERATE_DOCSET = NO +###GENERATE_DOCSET = NO +GENERATE_DOCSET = YES # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. -DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_FEEDNAME = "ZooLib" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. -DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_BUNDLE_ID = org.zoolib # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the Modified: trunk/zoolib/source/cxx/default_config/zconfig.h =================================================================== --- trunk/zoolib/source/cxx/default_config/zconfig.h 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/default_config/zconfig.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -22,6 +22,10 @@ #define __zconfig__ 1 #include "zoolib/zconfigd.h" + +// For projects that need special settings, copy this file to a location that will be found +// first by your compiler and put any settings here -- after zconfid.h, and before zconfigl.h. + #include "zoolib/zconfigl.h" #endif // __zconfig__ Deleted: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.cpp 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,101 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZYad_Any.h" -#include "zoolib/valbase/ZValBase.h" -#include "zoolib/valbase/ZValBase_YadSeqRPos.h" -#include "zoolib/zqe/ZQE_Result_Any.h" -#include "zoolib/zra/ZRA_Expr_Rel_Concrete.h" - -NAMESPACE_ZOOLIB_BEGIN -namespace ZValBase_YadSeqRPos { - -// ================================================================================================= -#pragma mark - -#pragma mark * Iterator - -class Iterator : public ZQE::Iterator - { -public: - Iterator(ZRef<ZYadSeqRPos> iYadSeqRPos); - virtual ~Iterator(); - - virtual ZRef<ZQE::Iterator> Clone(); - virtual ZRef<ZQE::Result> ReadInc(); - -protected: - ZRef<ZYadSeqRPos> fYadSeqRPos; - }; - -Iterator::Iterator(ZRef<ZYadSeqRPos> iYadSeqRPos) -: fYadSeqRPos(iYadSeqRPos) - {} - -Iterator::~Iterator() - {} - -ZRef<ZQE::Iterator> Iterator::Clone() - { return new Iterator(fYadSeqRPos->Clone()); } - -ZRef<ZQE::Result> Iterator::ReadInc() - { - if (ZRef<ZYadR> theYadR = fYadSeqRPos->ReadInc()) - return new ZQE::Result_Any(sFromYadR(ZVal_Any(), theYadR)); - return ZRef<ZQE::Result>(); - } - -// ================================================================================================= -#pragma mark - -#pragma mark * Expr_Rel_Concrete - -class Expr_Rel_Concrete : public ZValBase::Expr_Rel_Concrete - { -public: - Expr_Rel_Concrete(ZRef<ZYadSeqRPos> iYadSeqRPos); - -// From ZRA::Expr_Rel_Concrete via ZValBase::Expr_Rel_Concrete - virtual ZRA::RelHead GetRelHead(); - -// From ZValBase::Expr_Rel_Concrete - virtual ZRef<ZQE::Iterator> MakeIterator(); - -private: - ZRef<ZYadSeqRPos> fYadSeqRPos; - }; - -Expr_Rel_Concrete::Expr_Rel_Concrete(ZRef<ZYadSeqRPos> iYadSeqRPos) -: fYadSeqRPos(iYadSeqRPos) - {} - -ZRA::RelHead Expr_Rel_Concrete::GetRelHead() - { return ZRA::RelHead::sUniversal(); } - -ZRef<ZQE::Iterator> Expr_Rel_Concrete::MakeIterator() - { return new Iterator(fYadSeqRPos); } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZValBase_YadSeqRPos pseudo constructors - -ZRef<ZRA::Expr_Rel> sConcrete(ZRef<ZYadSeqRPos> iYadSeqRPos) - { return new Expr_Rel_Concrete(iYadSeqRPos); } - -} // namespace ZValBase_YadSeqRPos -NAMESPACE_ZOOLIB_END Deleted: trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.h 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/more/zoolib/valbase/ZValBase_YadSeqRPos.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,40 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZValBase_YadSeqRPos__ -#define __ZValBase_YadSeqRPos__ 1 -#include "zconfig.h" - -#include "zoolib/ZYad.h" -#include "zoolib/zra/ZRA_Expr_Rel.h" - -NAMESPACE_ZOOLIB_BEGIN -namespace ZValBase_YadSeqRPos { - -// ================================================================================================= -#pragma mark - -#pragma mark * ZValBase_YadSeqRPos pseudo constructors - -ZRef<ZRA::Expr_Rel> sConcrete(ZRef<ZYadSeqRPos> iYadSeqRPos); - -} // namespace ZValBase_YadSeqRPos -NAMESPACE_ZOOLIB_END - -#endif // __ZValBase_YadSeqRPos__ Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ReadMe.txt =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ReadMe.txt 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ReadMe.txt 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,4 +1,6 @@ /** \defgroup ZQE +The ZQE namespace contains facilities for building a Query Engine, code that can walk data sources to implement relational semantics. + */ Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ReadMe.txt =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ReadMe.txt 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ReadMe.txt 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,4 +1,6 @@ /** \defgroup ZRA +The ZRA namespace contains a suite of Relational Algebra expression nodes, and functions and operators for combining them. + */ Added: trunk/zoolib/source/cxx/zoolib/Docs_BuildingZooLib.txt =================================================================== --- trunk/zoolib/source/cxx/zoolib/Docs_BuildingZooLib.txt (rev 0) +++ trunk/zoolib/source/cxx/zoolib/Docs_BuildingZooLib.txt 2010-05-27 19:28:12 UTC (rev 1382) @@ -0,0 +1,24 @@ +/** +\defgroup BuildingZooLib Building ZooLib + +ZooLib is not a monolithic framework. It's more like a kit, something from which you draw pieces as you need them. So we tend not to build it as a standalone library or dll, instead we simply incorporate the source files we need for the task at hand. + +Generally any ZooLib source file can be included in any project, regardless of compiler or operating system. Code that depends on a compiler or OS facility is conditionally compiled and simply drops out if it's not usable. The file ZCONFIG_SPI.h uses compiler and environment-provided macro definitions to set up SPI (Service Provider Interface) macros that indicate whether a feature is available or not. Some of the SPI macros are quite broad e.g. Are we building for Mac OS X? Are we building for Windows?. Most are more specific e.g. Is CoreFoundation available? Is pthreads available? + +SPI features are marked with two macros. For example the pthread macros are ZCONFIG_SPI_Avail__pthread and ZCONFIG_SPI_Desired__pthread. If the Avail macro evaluates true it indicates that the feature is available. If the Desired macro evaluates true, it indicates that the project would like to use the feature. You test for availability and desirability with the macro ZCONFIG_SPI_Enabled(pthread). By default all features are marked as desired, and are marked as available if we can be sure they are available. So you can force use of a feature by setting ZCONFIG_SPI_Avail__XXX true, and force non-use by setting ZCONFIG_SPI_Desired__XXX false. + +Every ZooLib header file starts with +\code +#include "zconfig.h" +\endcode +There is a default copy of this file in \c zoolib/default_config. If you wish to provide project-specific settings, create your own \c zconfig.h file and make sure it's found before the default one. The simplest way to do that is to put it in with your own source files, and to make sure that \c zoolib/default_config is not in your project's include paths. + +To use ZooLib in your own project: +- Put the ZooLib directory somewhere stable. +- In your project, add the \c zoolib/source/zoolib/cxx directory to your header search paths. +- If you \e don't need to make any configuration changes, add \c zoolib/source/zoolib/cxx/default_config to your header search paths. +- If you want to use any features from the more directory, add \c zoolib/source/zoolib/cxx/more to your header search paths. +- Add to your project whichever ZooLib cpp/mm files you need. + +You can see sample projects in \c zoolib_samples, a sibling of the top-level zoolib directory. +*/ Modified: trunk/zoolib/source/cxx/zoolib/Docs_MainPage.txt =================================================================== --- trunk/zoolib/source/cxx/zoolib/Docs_MainPage.txt 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/zoolib/Docs_MainPage.txt 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,4 +1,63 @@ /** \mainpage -Some words for the main page + +ZooLib is a C++ library that I've been developing and using since 1992, and which has been open source since 2000. + +As it's under active development you may want to subscribe to the zoolib-checkins mailing list at <https://lists.sourceforge.net/lists/listinfo/zoolib-checkins>. + +It has several purposes: +- To extend the longevity of code I write, by providing some isolation from the inevitable compiler, library and operating system differences and changes. +- To provide simpler APIs for common tasks and to isolate workarounds. +- To be a repository of useful building blocks. + +So its content is somewhat eclectic, but can be considered as falling into four groups: +- OS abstractions +- ZooLib abstractions +- Higher level facilities +- API and product-specific facilities + +\section MainOSAbstractions OS Abstractions +Yep, another suite of OS wrappers, sorry. In my defense in 2010 we've only just witnessed the standardization of a portable thread API, and still don't have standard networking or file system APIs. You don't have to learn ZooLib's OS abstractions, and obviously you don't have to use them in your own code. But they're pretty robust and are there if you want. + +- \link Threads Threads\endlink +- \link Networking Networking\endlink +- \link Files Files\endlink + +\section MainZooLibAbstractions ZooLib Abstractions +- Byte streams +- String streams +- Unicode and text encodings +- Variant types +- Structured data parsing and generation +- Work and task management +- Reference counting + +\subsection MainByteAndStringStreams Byte and String Streams +ZooLib makes an explicit distinction between a \link Stream byte stream \endlink and a \link Strim string stream \endlink (a \em strim in our parlance). The former is just what you'd expect -- an entity to which you can write (or from which you can read) bytes. With the latter you write or read unicode strings (and in the limit, single unicode code points). + +\subsection MainUnicodeAndTextEncodings Unicode and Text Encodings +ZooLib provides platform-appropriate typedefs for UTF8, UTF16 and UTF32 code units, and string8, string16 and string32 (basic_string parameterized on those types.) There's a complete suite of 8<-->16<-->32<-->8 conversion functions that work with raw buffers, strings and iterators. String streams take and return strings using whichever serialization is most convenient for your code, regardless of the underlying encoding. + +\subsection MainVariantTypes Variant Types +Variants are a fairly new addition to ZooLIb. Variants like OSX's CFTypeRef show up all over the place but have wildly differing APIs. ZooLib has a standard API for working with variants, such that you can often change a typedef or parametrize a template on a different variant type without changing code. If nothing else they mean you don't have to remember multiple APIs. + +\subsection MainStructuredData Structured Data Parsing and Generation +XML of one sort and another, JSON, in-memory variant types, the windows registry, AppleEvents and similar RPC representations can all be worked with using the ZYadR suite. + +\section MainHigherLevelFacilities Higher Level Facilities +- Wide variety of streams and strims +- Generic Pixmap +- Pixmap codecs + +\section MainAPIFacilities API and Product-Specific Facilities +- \link BlackBerry BlackBerry\endlink +- Javascriptcore bindings +- Netscape plugins +- Photoshop +- Sqlite +- Tuplebase and tuplesoup +- \link ZRA Relational algebra\endlink +- \link ZQE Relational query executor\endlink +- Dataspace + */ Modified: trunk/zoolib/source/cxx/zoolib/Docs_NamingConvention.txt =================================================================== --- trunk/zoolib/source/cxx/zoolib/Docs_NamingConvention.txt 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/zoolib/Docs_NamingConvention.txt 2010-05-27 19:28:12 UTC (rev 1382) @@ -51,8 +51,8 @@ Classes and method names have an upper case initial letter. -Local variables have a lower case initial letter. I often use a \c the prefix, but the really -just whatever reads best. +Local variables have a lower case initial letter. I often use a \c the prefix, but the +goal is just to make it read well. Pretty much everything else has a scope prefix. Deleted: trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition.h 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,52 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZExpr_Logic_ValCondition__ -#define __ZExpr_Logic_ValCondition__ 1 -#include "zconfig.h" - -#include "zoolib/ZExpr_Logic_ValCondition_T.h" -#include "zoolib/ZValCondition.h" -#include "zoolib/ZVisitor_Expr_Logic_ValCondition_DoEval_Matches_T.h" -#include "zoolib/ZVisitor_Expr_Logic_ValCondition_DoGetNames_T.h" - -NAMESPACE_ZOOLIB_BEGIN - -// ================================================================================================= -#pragma mark - -#pragma mark * ZExpr_Logic_ValCondition - -typedef ZExpr_Logic_ValCondition_T<ZVal_Expr> ZExpr_Logic_ValCondition; - -typedef ZVisitor_Expr_Logic_ValCondition_T<ZVal_Expr> ZVisitor_Expr_Logic_ValCondition; - - -inline std::set<std::string> sGetNames(const ZRef<ZExpr_Logic>& iExpr) - { return ZVisitor_Expr_Logic_ValCondition_DoGetNames_T<ZVal_Expr>().Do(iExpr); } - -inline bool sMatches(const ZRef<ZExpr_Logic>& iExpr, const ZVal_Expr& iVal) - { return ZVisitor_Expr_Logic_ValCondition_DoEval_Matches_T<ZVal_Expr>(iVal).Do(iExpr); } - -inline bool sMatches(const ZValCondition& iValCondition, const ZVal_Expr& iVal) - { return sMatches(new ZExpr_Logic_ValCondition(iValCondition), iVal); } - -NAMESPACE_ZOOLIB_END - -#endif // __ZExpr_Logic_ValCondition__ Deleted: trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition_T.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition_T.h 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValCondition_T.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,213 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZExpr_Logic_ValCondition_T__ -#define __ZExpr_Logic_ValCondition_T__ 1 -#include "zconfig.h" - -#include "zoolib/ZExpr_Logic.h" -#include "zoolib/ZValCondition_T.h" - -NAMESPACE_ZOOLIB_BEGIN - -template <class Val> class ZVisitor_Expr_Logic_ValCondition_T; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZExpr_Logic_ValCondition_T - -template <class Val> -class ZExpr_Logic_ValCondition_T -: public virtual ZExpr_Logic -, public virtual ZExpr_Op0_T<ZExpr_Logic> - { - typedef ZExpr_Op0_T<ZExpr_Logic> inherited; -public: - ZExpr_Logic_ValCondition_T(const ZValCondition_T<Val>& iCondition); - virtual ~ZExpr_Logic_ValCondition_T(); - -// From ZExpr_Op0 - virtual void Accept_Expr_Op0(ZVisitor_Expr_Op0_T<ZExpr_Logic>& iVisitor); - - virtual ZRef<ZExpr_Logic> Self(); - virtual ZRef<ZExpr_Logic> Clone(); - -// Our protocol - virtual void Accept_Expr_Logic_ValCondition(ZVisitor_Expr_Logic_ValCondition_T<Val>& iVisitor); - - const ZValCondition_T<Val>& GetValCondition(); - -private: - const ZValCondition_T<Val> fValCondition; - }; - -template <class Val> -ZExpr_Logic_ValCondition_T<Val>::ZExpr_Logic_ValCondition_T( - const ZValCondition_T<Val>& iValCondition) -: fValCondition(iValCondition) - {} - -template <class Val> -ZExpr_Logic_ValCondition_T<Val>::~ZExpr_Logic_ValCondition_T() - {} - -template <class Val> -void ZExpr_Logic_ValCondition_T<Val>::Accept_Expr_Op0(ZVisitor_Expr_Op0_T<ZExpr_Logic>& iVisitor) - { - if (ZVisitor_Expr_Logic_ValCondition_T<Val>* theVisitor = - dynamic_cast<ZVisitor_Expr_Logic_ValCondition_T<Val>*>(&iVisitor)) - { - this->Accept_Expr_Logic_ValCondition(*theVisitor); - } - else - { - inherited::Accept_Expr_Op0(iVisitor); - } - } - -template <class Val> -ZRef<ZExpr_Logic> ZExpr_Logic_ValCondition_T<Val>::Self() - { return this; } - -template <class Val> -ZRef<ZExpr_Logic> ZExpr_Logic_ValCondition_T<Val>::Clone() - { return this; } - -template <class Val> -void ZExpr_Logic_ValCondition_T<Val>::Accept_Expr_Logic_ValCondition( - ZVisitor_Expr_Logic_ValCondition_T<Val>& iVisitor) - { iVisitor.Visit_Expr_Logic_ValCondition(this); } - -template <class Val> -const ZValCondition_T<Val>& -ZExpr_Logic_ValCondition_T<Val>::GetValCondition() - { return fValCondition; } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZVisitor_Expr_Logic_ValCondition_T - -template <class Val> -class ZVisitor_Expr_Logic_ValCondition_T -: public virtual ZVisitor_Expr_Op0_T<ZExpr_Logic> - { - typedef ZVisitor_Expr_Op0_T<ZExpr_Logic> inherited; -public: - virtual void Visit_Expr_Logic_ValCondition(ZRef<ZExpr_Logic_ValCondition_T<Val> > iExpr); - }; - -template <class Val> -void ZVisitor_Expr_Logic_ValCondition_T<Val>::Visit_Expr_Logic_ValCondition( - ZRef<ZExpr_Logic_ValCondition_T<Val> > iExpr) - { this->Visit_Expr_Op0(iExpr); } - -// ================================================================================================= -#pragma mark - -#pragma mark * Operators - -template <class Val> -ZRef<ZExpr_Logic> sLogic(const ZValCondition_T<Val>& iValCondition) - { return new ZExpr_Logic_ValCondition_T<Val>(iValCondition); } - -template <class Val> -ZRef<ZExpr_Logic_Not> operator~(const ZValCondition_T<Val>& iValCondition) - { return new ZExpr_Logic_Not(new ZExpr_Logic_ValCondition_T<Val>(iValCondition)); } - -template <class Val> -ZRef<ZExpr_Logic> operator&(bool iBool, const ZValCondition_T<Val>& iValCondition) - { - if (iBool) - return new ZExpr_Logic_ValCondition_T<Val>(iValCondition); - return new ZExpr_Logic_False; - } - -template <class Val> -ZRef<ZExpr_Logic> operator&(const ZValCondition_T<Val>& iValCondition, bool iBool) - { - if (iBool) - return new ZExpr_Logic_ValCondition_T<Val>(iValCondition); - return new ZExpr_Logic_False; - } - -template <class Val> -ZRef<ZExpr_Logic> operator|(bool iBool, const ZValCondition_T<Val>& iValCondition) - { - if (iBool) - return new ZExpr_Logic_True; - return new ZExpr_Logic_ValCondition_T<Val>(iValCondition); - } - -template <class Val> -ZRef<ZExpr_Logic> operator|(const ZValCondition_T<Val>& iValCondition, bool iBool) - { - if (iBool) - return new ZExpr_Logic_True; - return new ZExpr_Logic_ValCondition_T<Val>(iValCondition); - } - -template <class Val> -ZRef<ZExpr_Logic> operator&(const ZValCondition_T<Val>& iLHS, const ZValCondition_T<Val>& iRHS) - { - return new ZExpr_Logic_And( - new ZExpr_Logic_ValCondition_T<Val>(iLHS), - new ZExpr_Logic_ValCondition_T<Val>(iRHS)); - } - -template <class Val> -ZRef<ZExpr_Logic> operator&(const ZValCondition_T<Val>& iLHS, const ZRef<ZExpr_Logic>& iRHS) - { return new ZExpr_Logic_And(new ZExpr_Logic_ValCondition_T<Val>(iLHS), iRHS); } - -template <class Val> -ZRef<ZExpr_Logic> operator&(const ZRef<ZExpr_Logic>& iLHS, const ZValCondition_T<Val>& iRHS) - { return new ZExpr_Logic_And(new ZExpr_Logic_ValCondition_T<Val>(iRHS), iLHS); } - -template <class Val> -ZRef<ZExpr_Logic>& operator&=(ZRef<ZExpr_Logic>& ioLHS, const ZValCondition_T<Val>& iRHS) - { - ioLHS = ioLHS & iRHS; - return ioLHS; - } - -template <class Val> -ZRef<ZExpr_Logic> operator|(const ZValCondition_T<Val>& iLHS, const ZValCondition_T<Val>& iRHS) - { - return new ZExpr_Logic_Or( - new ZExpr_Logic_ValCondition_T<Val>(iLHS), - new ZExpr_Logic_ValCondition_T<Val>(iRHS)); - } - -template <class Val> -ZRef<ZExpr_Logic> operator|(const ZValCondition_T<Val>& iLHS, const ZRef<ZExpr_Logic>& iRHS) - { return new ZExpr_Logic_Or(new ZExpr_Logic_ValCondition_T<Val>(iLHS), iRHS); } - -template <class Val> -ZRef<ZExpr_Logic> operator|(const ZRef<ZExpr_Logic>& iLHS, const ZValCondition_T<Val>& iRHS) - { return new ZExpr_Logic_Or(new ZExpr_Logic_ValCondition_T<Val>(iRHS), iLHS); } - -template <class Val> -ZRef<ZExpr_Logic>& operator|=(ZRef<ZExpr_Logic>& ioLHS, const ZValCondition_T<Val>& iRHS) - { - ioLHS = ioLHS | iRHS; - return ioLHS; - } - -NAMESPACE_ZOOLIB_END - -#endif // __ZExpr_Logic_ValCondition_T__ Added: trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValPred.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValPred.h (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValPred.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -0,0 +1,52 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZExpr_Logic_ValPred__ +#define __ZExpr_Logic_ValPred__ 1 +#include "zconfig.h" + +#include "zoolib/ZExpr_Logic_ValPred_T.h" +#include "zoolib/ZValPred.h" +#include "zoolib/ZVisitor_Expr_Logic_ValPred_DoEval_Matches_T.h" +#include "zoolib/ZVisitor_Expr_Logic_ValPred_DoGetNames_T.h" + +NAMESPACE_ZOOLIB_BEGIN + +// ================================================================================================= +#pragma mark - +#pragma mark * ZExpr_Logic_ValPred + +typedef ZExpr_Logic_ValPred_T<ZVal_Expr> ZExpr_Logic_ValPred; + +typedef ZVisitor_Expr_Logic_ValPred_T<ZVal_Expr> ZVisitor_Expr_Logic_ValPred; + + +inline std::set<std::string> sGetNames(const ZRef<ZExpr_Logic>& iExpr) + { return ZVisitor_Expr_Logic_ValPred_DoGetNames_T<ZVal_Expr>().Do(iExpr); } + +inline bool sMatches(const ZRef<ZExpr_Logic>& iExpr, const ZVal_Expr& iVal) + { return ZVisitor_Expr_Logic_ValPred_DoEval_Matches_T<ZVal_Expr>(iVal).Do(iExpr); } + +inline bool sMatches(const ZValPred& iValPred, const ZVal_Expr& iVal) + { return sMatches(new ZExpr_Logic_ValPred(iValPred), iVal); } + +NAMESPACE_ZOOLIB_END + +#endif // __ZExpr_Logic_ValPred__ Added: trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValPred_T.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValPred_T.h (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Logic_ValPred_T.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -0,0 +1,213 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZExpr_Logic_ValPred_T__ +#define __ZExpr_Logic_ValPred_T__ 1 +#include "zconfig.h" + +#include "zoolib/ZExpr_Logic.h" +#include "zoolib/ZValPred_T.h" + +NAMESPACE_ZOOLIB_BEGIN + +template <class Val> class ZVisitor_Expr_Logic_ValPred_T; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZExpr_Logic_ValPred_T + +template <class Val> +class ZExpr_Logic_ValPred_T +: public virtual ZExpr_Logic +, public virtual ZExpr_Op0_T<ZExpr_Logic> + { + typedef ZExpr_Op0_T<ZExpr_Logic> inherited; +public: + ZExpr_Logic_ValPred_T(const ZValPred_T<Val>& iCondition); + virtual ~ZExpr_Logic_ValPred_T(); + +// From ZExpr_Op0 + virtual void Accept_Expr_Op0(ZVisitor_Expr_Op0_T<ZExpr_Logic>& iVisitor); + + virtual ZRef<ZExpr_Logic> Self(); + virtual ZRef<ZExpr_Logic> Clone(); + +// Our protocol + virtual void Accept_Expr_Logic_ValPred(ZVisitor_Expr_Logic_ValPred_T<Val>& iVisitor); + + const ZValPred_T<Val>& GetValPred(); + +private: + const ZValPred_T<Val> fValPred; + }; + +template <class Val> +ZExpr_Logic_ValPred_T<Val>::ZExpr_Logic_ValPred_T( + const ZValPred_T<Val>& iValPred) +: fValPred(iValPred) + {} + +template <class Val> +ZExpr_Logic_ValPred_T<Val>::~ZExpr_Logic_ValPred_T() + {} + +template <class Val> +void ZExpr_Logic_ValPred_T<Val>::Accept_Expr_Op0(ZVisitor_Expr_Op0_T<ZExpr_Logic>& iVisitor) + { + if (ZVisitor_Expr_Logic_ValPred_T<Val>* theVisitor = + dynamic_cast<ZVisitor_Expr_Logic_ValPred_T<Val>*>(&iVisitor)) + { + this->Accept_Expr_Logic_ValPred(*theVisitor); + } + else + { + inherited::Accept_Expr_Op0(iVisitor); + } + } + +template <class Val> +ZRef<ZExpr_Logic> ZExpr_Logic_ValPred_T<Val>::Self() + { return this; } + +template <class Val> +ZRef<ZExpr_Logic> ZExpr_Logic_ValPred_T<Val>::Clone() + { return this; } + +template <class Val> +void ZExpr_Logic_ValPred_T<Val>::Accept_Expr_Logic_ValPred( + ZVisitor_Expr_Logic_ValPred_T<Val>& iVisitor) + { iVisitor.Visit_Expr_Logic_ValPred(this); } + +template <class Val> +const ZValPred_T<Val>& +ZExpr_Logic_ValPred_T<Val>::GetValPred() + { return fValPred; } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZVisitor_Expr_Logic_ValPred_T + +template <class Val> +class ZVisitor_Expr_Logic_ValPred_T +: public virtual ZVisitor_Expr_Op0_T<ZExpr_Logic> + { + typedef ZVisitor_Expr_Op0_T<ZExpr_Logic> inherited; +public: + virtual void Visit_Expr_Logic_ValPred(ZRef<ZExpr_Logic_ValPred_T<Val> > iExpr); + }; + +template <class Val> +void ZVisitor_Expr_Logic_ValPred_T<Val>::Visit_Expr_Logic_ValPred( + ZRef<ZExpr_Logic_ValPred_T<Val> > iExpr) + { this->Visit_Expr_Op0(iExpr); } + +// ================================================================================================= +#pragma mark - +#pragma mark * Operators + +template <class Val> +ZRef<ZExpr_Logic> sLogic(const ZValPred_T<Val>& iValPred) + { return new ZExpr_Logic_ValPred_T<Val>(iValPred); } + +template <class Val> +ZRef<ZExpr_Logic_Not> operator~(const ZValPred_T<Val>& iValPred) + { return new ZExpr_Logic_Not(new ZExpr_Logic_ValPred_T<Val>(iValPred)); } + +template <class Val> +ZRef<ZExpr_Logic> operator&(bool iBool, const ZValPred_T<Val>& iValPred) + { + if (iBool) + return new ZExpr_Logic_ValPred_T<Val>(iValPred); + return new ZExpr_Logic_False; + } + +template <class Val> +ZRef<ZExpr_Logic> operator&(const ZValPred_T<Val>& iValPred, bool iBool) + { + if (iBool) + return new ZExpr_Logic_ValPred_T<Val>(iValPred); + return new ZExpr_Logic_False; + } + +template <class Val> +ZRef<ZExpr_Logic> operator|(bool iBool, const ZValPred_T<Val>& iValPred) + { + if (iBool) + return new ZExpr_Logic_True; + return new ZExpr_Logic_ValPred_T<Val>(iValPred); + } + +template <class Val> +ZRef<ZExpr_Logic> operator|(const ZValPred_T<Val>& iValPred, bool iBool) + { + if (iBool) + return new ZExpr_Logic_True; + return new ZExpr_Logic_ValPred_T<Val>(iValPred); + } + +template <class Val> +ZRef<ZExpr_Logic> operator&(const ZValPred_T<Val>& iLHS, const ZValPred_T<Val>& iRHS) + { + return new ZExpr_Logic_And( + new ZExpr_Logic_ValPred_T<Val>(iLHS), + new ZExpr_Logic_ValPred_T<Val>(iRHS)); + } + +template <class Val> +ZRef<ZExpr_Logic> operator&(const ZValPred_T<Val>& iLHS, const ZRef<ZExpr_Logic>& iRHS) + { return new ZExpr_Logic_And(new ZExpr_Logic_ValPred_T<Val>(iLHS), iRHS); } + +template <class Val> +ZRef<ZExpr_Logic> operator&(const ZRef<ZExpr_Logic>& iLHS, const ZValPred_T<Val>& iRHS) + { return new ZExpr_Logic_And(new ZExpr_Logic_ValPred_T<Val>(iRHS), iLHS); } + +template <class Val> +ZRef<ZExpr_Logic>& operator&=(ZRef<ZExpr_Logic>& ioLHS, const ZValPred_T<Val>& iRHS) + { + ioLHS = ioLHS & iRHS; + return ioLHS; + } + +template <class Val> +ZRef<ZExpr_Logic> operator|(const ZValPred_T<Val>& iLHS, const ZValPred_T<Val>& iRHS) + { + return new ZExpr_Logic_Or( + new ZExpr_Logic_ValPred_T<Val>(iLHS), + new ZExpr_Logic_ValPred_T<Val>(iRHS)); + } + +template <class Val> +ZRef<ZExpr_Logic> operator|(const ZValPred_T<Val>& iLHS, const ZRef<ZExpr_Logic>& iRHS) + { return new ZExpr_Logic_Or(new ZExpr_Logic_ValPred_T<Val>(iLHS), iRHS); } + +template <class Val> +ZRef<ZExpr_Logic> operator|(const ZRef<ZExpr_Logic>& iLHS, const ZValPred_T<Val>& iRHS) + { return new ZExpr_Logic_Or(new ZExpr_Logic_ValPred_T<Val>(iRHS), iLHS); } + +template <class Val> +ZRef<ZExpr_Logic>& operator|=(ZRef<ZExpr_Logic>& ioLHS, const ZValPred_T<Val>& iRHS) + { + ioLHS = ioLHS | iRHS; + return ioLHS; + } + +NAMESPACE_ZOOLIB_END + +#endif // __ZExpr_Logic_ValPred_T__ Deleted: trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValCondition.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValCondition.cpp 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValCondition.cpp 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,131 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZUtil_Strim_ValCondition.h" -#include "zoolib/ZYad_Any.h" -#include "zoolib/ZYad_ZooLibStrim.h" - -NAMESPACE_ZOOLIB_BEGIN - -namespace ZUtil_Strim_ValCondition { - -using std::string; - -typedef ZValComparator_Simple_T<ZVal_Expr> ZValComparator_Simple; -typedef ZValComparand_Trail_T<ZVal_Expr> ZValComparand_Trail; -typedef ZValComparand_Var_T<ZVal_Expr> ZValComparand_Var; -typedef ZValComparand_Const_T<ZVal_Expr> ZValComparand_Const; - -// ================================================================================================= -#pragma mark - -#pragma mark * Static helper functions - -static void spWrite_PropName(const string& iName, const ZStrimW& s) - { - s.Write("@"); - ZYad_ZooLibStrim::sWrite_PropName(iName, s); - } - -static void spToStrim(const ZRef<ZValCondition::ComparandRep>& iCR, const ZStrimW& s) - { - if (!iCR) - { - s << "!!Null Comparand!!"; - } - else if (ZRef<ZValComparand_Trail> cr = iCR.DynamicCast<ZValComparand_Trail>()) - { - const ZTrail& theTrail = cr->GetTrail(); - if (theTrail.Count() == 1) - spWrite_PropName(theTrail.At(0), s); - else - spWrite_PropName("/" + theTrail.AsString(), s); - } - else if (ZRef<ZValComparand_Var> cr = iCR.DynamicCast<ZValComparand_Var>()) - { - s << "$"; - ZYad_ZooLibStrim::sWrite_PropName(cr->GetVarName(), s); - } - else if (ZRef<ZValComparand_Const> cr = iCR.DynamicCast<ZValComparand_Const>()) - { - ZYad_ZooLibStrim::sToStrim(sMakeYadR(cr->GetVal()), s); - } - else - { - s << "!!Unknown Comparand!!"; - } - } - -static void spToStrim(const ZRef<ZValCondition::ComparatorRep>& iCR, const ZStrimW& s) - { - if (!iCR) - { - s << "!!Null Comparator!!"; - } - else if (ZRef<ZValComparator_Simple> cr = iCR.DynamicCast<ZValComparator_Simple>()) - { - switch (cr->GetEComparator()) - { - case ZValComparator_Simple::eLT: - { - s << " < "; - break; - } - case ZValComparator_Simple::eLE: - { - s << " <= "; - break; - } - case ZValComparator_Simple::eEQ: - { - s << " == "; - break; - } - case ZValComparator_Simple::eGE: - { - s << " >= "; - break; - } - case ZValComparator_Simple::eGT: - { - s << " > "; - break; - } - } - } - else - { - s << "!!Unknown Comparator!!"; - } - } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZUtil_Strim_ValCondition - -void sToStrim(const ZValCondition& iValCondition, const ZStrimW& s) - { - spToStrim(iValCondition.GetLHS(), s); - spToStrim(iValCondition.GetComparator(), s); - spToStrim(iValCondition.GetRHS(), s); - } - -} // namespace ZUtil_Strim_ValCondition - -NAMESPACE_ZOOLIB_END Deleted: trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValCondition.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValCondition.h 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValCondition.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,42 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZUtil_Strim_ValCondition__ -#define __ZUtil_Strim_ValCondition__ -#include "zconfig.h" - -#include "zoolib/ZStrim.h" -#include "zoolib/ZValCondition.h" - -NAMESPACE_ZOOLIB_BEGIN - -namespace ZUtil_Strim_ValCondition { - -// ================================================================================================= -#pragma mark - -#pragma mark * ZUtil_Strim_ValCondition - -void sToStrim(const ZValCondition& iValCondition, const ZStrimW& iStrimW); - -} // namespace ZUtil_Strim_ValCondition - -NAMESPACE_ZOOLIB_END - -#endif // __ZUtil_Strim_ValCondition__ Added: trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValPred.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValPred.cpp (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValPred.cpp 2010-05-27 19:28:12 UTC (rev 1382) @@ -0,0 +1,131 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZUtil_Strim_ValPred.h" +#include "zoolib/ZYad_Any.h" +#include "zoolib/ZYad_ZooLibStrim.h" + +NAMESPACE_ZOOLIB_BEGIN + +namespace ZUtil_Strim_ValPred { + +using std::string; + +typedef ZValComparator_Simple_T<ZVal_Expr> ZValComparator_Simple; +typedef ZValComparand_Trail_T<ZVal_Expr> ZValComparand_Trail; +typedef ZValComparand_Var_T<ZVal_Expr> ZValComparand_Var; +typedef ZValComparand_Const_T<ZVal_Expr> ZValComparand_Const; + +// ================================================================================================= +#pragma mark - +#pragma mark * Static helper functions + +static void spWrite_PropName(const string& iName, const ZStrimW& s) + { + s.Write("@"); + ZYad_ZooLibStrim::sWrite_PropName(iName, s); + } + +static void spToStrim(const ZRef<ZValPred::Comparand>& iCR, const ZStrimW& s) + { + if (!iCR) + { + s << "!!Null Comparand!!"; + } + else if (ZRef<ZValComparand_Trail> cr = iCR.DynamicCast<ZValComparand_Trail>()) + { + const ZTrail& theTrail = cr->GetTrail(); + if (theTrail.Count() == 1) + spWrite_PropName(theTrail.At(0), s); + else + spWrite_PropName("/" + theTrail.AsString(), s); + } + else if (ZRef<ZValComparand_Var> cr = iCR.DynamicCast<ZValComparand_Var>()) + { + s << "$"; + ZYad_ZooLibStrim::sWrite_PropName(cr->GetVarName(), s); + } + else if (ZRef<ZValComparand_Const> cr = iCR.DynamicCast<ZValComparand_Const>()) + { + ZYad_ZooLibStrim::sToStrim(sMakeYadR(cr->GetVal()), s); + } + else + { + s << "!!Unknown Comparand!!"; + } + } + +static void spToStrim(const ZRef<ZValPred::Comparator>& iCR, const ZStrimW& s) + { + if (!iCR) + { + s << "!!Null Comparator!!"; + } + else if (ZRef<ZValComparator_Simple> cr = iCR.DynamicCast<ZValComparator_Simple>()) + { + switch (cr->GetEComparator()) + { + case ZValComparator_Simple::eLT: + { + s << " < "; + break; + } + case ZValComparator_Simple::eLE: + { + s << " <= "; + break; + } + case ZValComparator_Simple::eEQ: + { + s << " == "; + break; + } + case ZValComparator_Simple::eGE: + { + s << " >= "; + break; + } + case ZValComparator_Simple::eGT: + { + s << " > "; + break; + } + } + } + else + { + s << "!!Unknown Comparator!!"; + } + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZUtil_Strim_ValPred + +void sToStrim(const ZValPred& iValPred, const ZStrimW& s) + { + spToStrim(iValPred.GetLHS(), s); + spToStrim(iValPred.GetComparator(), s); + spToStrim(iValPred.GetRHS(), s); + } + +} // namespace ZUtil_Strim_ValPred + +NAMESPACE_ZOOLIB_END Added: trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValPred.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValPred.h (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Strim_ValPred.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -0,0 +1,42 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZUtil_Strim_ValPred__ +#define __ZUtil_Strim_ValPred__ +#include "zconfig.h" + +#include "zoolib/ZStrim.h" +#include "zoolib/ZValPred.h" + +NAMESPACE_ZOOLIB_BEGIN + +namespace ZUtil_Strim_ValPred { + +// ================================================================================================= +#pragma mark - +#pragma mark * ZUtil_Strim_ValPred + +void sToStrim(const ZValPred& iValPred, const ZStrimW& iStrimW); + +} // namespace ZUtil_Strim_ValPred + +NAMESPACE_ZOOLIB_END + +#endif // __ZUtil_Strim_ValPred__ Deleted: trunk/zoolib/source/cxx/zoolib/ZValCondition.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZValCondition.h 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/zoolib/ZValCondition.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,67 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZValCondition__ -#define __ZValCondition__ 1 -#include "zconfig.h" - -#include "zoolib/ZValCondition_T.h" - -#include "zoolib/ZVal_Any.h" -//#include "zoolib/ZVal_CFType.h" -//#include "zoolib/ZVal_Zoolib.h" - -NAMESPACE_ZOOLIB_BEGIN - -typedef ZMap_Any ZMap_Expr; - -//typedef ZMap_CFType ZMap_Expr; -//typedef ZMap_ZooLib ZMap_Expr; - -typedef ZMap_Expr::Val_t ZVal_Expr; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZValCondition - -typedef ZValCondition_T<ZVal_Expr> ZValCondition; -typedef ZValComparandPseudo_T<ZVal_Expr> ZValComparandPseudo; - -inline ZValComparandPseudo CString(const std::string& iVal) - { return CConst_T<ZVal_Expr>(string8(iVal)); } - -inline ZValComparandPseudo CConst(const ZVal_Expr& iVal) - { return CConst_T<ZVal_Expr>(iVal); } - -inline ZValComparandPseudo CName(const std::string& iName) - { return CName_T<ZVal_Expr>(iName); } - -inline ZValComparandPseudo CTrail(const ZTrail& iTrail) - { return CTrail_T<ZVal_Expr>(iTrail); } - -inline ZValComparandPseudo CVal() - { return CVal_T<ZVal_Expr>(); } - -inline ZValComparandPseudo CVar(const std::string& iVarName) - { return CVar_T<ZVal_Expr>(iVarName); } - -NAMESPACE_ZOOLIB_END - -#endif // __ZValCondition__ Deleted: trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h 2010-05-27 19:27:02 UTC (rev 1381) +++ trunk/zoolib/source/cxx/zoolib/ZValCondition_T.h 2010-05-27 19:28:12 UTC (rev 1382) @@ -1,557 +0,0 @@ -/* --------------------------------... [truncated message content] |
From: <ag...@us...> - 2010-06-16 03:19:04
|
Revision: 1433 http://zoolib.svn.sourceforge.net/zoolib/?rev=1433&view=rev Author: agreen Date: 2010-06-16 03:18:57 +0000 (Wed, 16 Jun 2010) Log Message: ----------- More QGet_T changes. Add XGet_T(name/index) variants for some maps and seq. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.cpp trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.h trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Guest.cpp trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Host.cpp trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Object.h trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_ObjectPriv.h trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Variant.cpp trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Variant.h trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_FileRef.cpp trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h trunk/zoolib/source/cxx/zoolib/ZAny.h trunk/zoolib/source/cxx/zoolib/ZHTTP.cpp trunk/zoolib/source/cxx/zoolib/ZQ_T.h trunk/zoolib/source/cxx/zoolib/ZValAccessors.h trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp trunk/zoolib/source/cxx/zoolib/ZVal_Any.h trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h trunk/zoolib/source/cxx/zoolib/ZVal_CFType.h trunk/zoolib/source/cxx/zoolib/ZVal_NS.h trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.h trunk/zoolib/source/cxx/zoolib/ZWinCOM.cpp trunk/zoolib/source/cxx/zoolib/ZWinCOM.h trunk/zoolib/source/cxx/zoolib/ZWinService.cpp Modified: trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -406,12 +406,12 @@ } case kJSTypeNumber: { - return ZAny(double(::JSValueToNumber(sCurrentContextRef(), theRef, nil))); + return ZAny(double(::JSValueToNumber(sCurrentContextRef(), theRef, nullptr))); } case kJSTypeString: { ZRef<JSStringRef> theStringRef = - Adopt(::JSValueToStringCopy(sCurrentContextRef(), theRef, nil)); + Adopt(::JSValueToStringCopy(sCurrentContextRef(), theRef, nullptr)); return ZAny(spAsString8(theStringRef)); } case kJSTypeObject: @@ -539,94 +539,78 @@ String Value::ToString() const { if (JSValueRef theRef = inherited::Get()) - return Adopt(::JSValueToStringCopy(sCurrentContextRef(), theRef, nil)); + return Adopt(::JSValueToStringCopy(sCurrentContextRef(), theRef, nullptr)); return String(); } template <> -bool Value::QGet_T<bool>(bool& oVal) const +ZQ_T<bool> Value::QGet_T<bool>() const { if (JSValueRef theRef = inherited::Get()) { if (kJSTypeBoolean == ::JSValueGetType(sCurrentContextRef(), theRef)) - { - oVal = ::JSValueToBoolean(sCurrentContextRef(), theRef); - return true; - } + return bool(::JSValueToBoolean(sCurrentContextRef(), theRef)); } - return false; + return null; } template <> -bool Value::QGet_T<double>(double& oVal) const +ZQ_T<double> Value::QGet_T<double>() const { if (JSValueRef theRef = inherited::Get()) { if (kJSTypeNumber == ::JSValueGetType(sCurrentContextRef(), theRef)) { - JSValueRef theEx = nil; - oVal = ::JSValueToNumber(sCurrentContextRef(), theRef, &theEx); - return !theEx; + JSValueRef theEx = nullptr; + double theValue = ::JSValueToNumber(sCurrentContextRef(), theRef, &theEx); + if (!theEx) + return theValue; } } - return false; + return null; } template <> -bool Value::QGet_T<String>(String& oVal) const +ZQ_T<String> Value::QGet_T<String>() const { if (JSValueRef theRef = inherited::Get()) { if (kJSTypeString == ::JSValueGetType(sCurrentContextRef(), theRef)) { if (ZRef<JSStringRef> theStringRef = - Adopt(::JSValueToStringCopy(sCurrentContextRef(), theRef, nil))) - { - oVal = theStringRef; - return true; - } + Adopt(::JSValueToStringCopy(sCurrentContextRef(), theRef, nullptr))) + return theStringRef; } } - return false; + return null; } template <> -bool Value::QGet_T<string16>(string16& oVal) const +ZQ_T<string16> Value::QGet_T<string16>() const { - String theString; - if (this->QGet_T<String>(theString)) - { - oVal = theString.AsString16(); - return true; - } - return false; + if (ZQ_T<String> theQ = this->QGet_T<String>()) + return theQ.Get().AsString16(); + return null; } template <> -bool Value::QGet_T<string8>(string8& oVal) const +ZQ_T<string8> Value::QGet_T<string8>() const { - String theString; - if (this->QGet_T<String>(theString)) - { - oVal = theString.AsString8(); - return true; - } - return false; + if (ZQ_T<String> theQ = this->QGet_T<String>()) + return theQ.Get().AsString8(); + return null; } template <> -bool Value::QGet_T<ObjectRef>(ObjectRef& oVal) const +ZQ_T<ObjectRef> Value::QGet_T<ObjectRef>() const { if (JSValueRef theRef = inherited::Get()) { if (::JSValueIsObject(sCurrentContextRef(), theRef)) - { - oVal = ObjectRef(const_cast<JSObjectRef>(theRef)); - return true; - } + return ObjectRef(const_cast<JSObjectRef>(theRef)); } - return false; + return null; } ZMACRO_ZValAccessors_Def_GetP(,Value, Bool, bool) @@ -644,11 +628,10 @@ { if (JSObjectRef thisRef = inherited::Get()) { - double length; - if (this->Get("length").QGetDouble(length)) + if (ZQ_T<double> theQ = this->Get("length").QGetDouble()) { ZSeq_Any result; - for (size_t x = 0; x < length; ++x) + for (size_t x = 0; x < theQ.Get(); ++x) result.Append(this->Get(x).AsAny()); return ZAny(result); } @@ -670,7 +653,7 @@ } ObjectRef::ObjectRef() -: inherited(::JSObjectMake(sCurrentContextRef(), nil, nil)) +: inherited(::JSObjectMake(sCurrentContextRef(), nullptr, nullptr)) {} ObjectRef::ObjectRef(const ObjectRef& iOther) @@ -696,24 +679,20 @@ return *this; } -bool ObjectRef::QGet(const string8& iName, Value& oVal) const +ZQ_T<Value> ObjectRef::QGet(const string8& iName) const { - JSValueRef theEx = nil; + JSValueRef theEx = nullptr; JSValueRef theResult = ::JSObjectGetProperty(sCurrentContextRef(), inherited::Get(), String(iName), &theEx); if (!theEx) - { - oVal = Value(theResult); - return true; - } - return false; + return Value(theResult); + return null; } Value ObjectRef::DGet(const Value& iDefault, const string8& iName) const { - Value result; - if (this->QGet(iName, result)) - return result; + if (ZQ_T<Value> theQ = this->QGet(iName)) + return theQ.Get(); return iDefault; } @@ -722,7 +701,7 @@ bool ObjectRef::Set(const string8& iName, const Value& iValue) { - JSValueRef theEx = nil; + JSValueRef theEx = nullptr; ::JSObjectSetProperty(sCurrentContextRef(), inherited::Get(), String(iName), iValue, 0, &theEx); return !theEx; @@ -735,40 +714,31 @@ } bool ObjectRef::IsSeq() const + { return this->QGet("length"); } + +ZQ_T<Value> ObjectRef::QGet(size_t iIndex) const { - double length; - if (this->Get("length").QGetDouble(length)) - return true; - return false; + JSValueRef theEx = nullptr; + JSValueRef theResult = ::JSObjectGetPropertyAtIndex(sCurrentContextRef(), + inherited::Get(), iIndex, &theEx); + if (!theEx) + return Value(theResult); + return null; } Value ObjectRef::DGet(const Value& iDefault, size_t iIndex) const { - Value result; - if (this->QGet(iIndex, result)) - return result; + if (ZQ_T<Value> theQ = this->QGet(iIndex)) + return theQ.Get(); return iDefault; } -bool ObjectRef::QGet(size_t iIndex, Value& oVal) const - { - JSValueRef theEx = nil; - JSValueRef theResult = ::JSObjectGetPropertyAtIndex(sCurrentContextRef(), - inherited::Get(), iIndex, &theEx); - if (!theEx) - { - oVal = Value(theResult); - return true; - } - return false; - } - Value ObjectRef::Get(size_t iIndex) const { return this->DGet(Value(), iIndex); } bool ObjectRef::Set(size_t iIndex, const Value& iValue) { - JSValueRef theEx = nil; + JSValueRef theEx = nullptr; ::JSObjectSetPropertyAtIndex(sCurrentContextRef(), inherited::Get(), iIndex, iValue, &theEx); return !theEx; @@ -802,7 +772,7 @@ #pragma mark * ZJavaScriptCore::ObjectImp ObjectImp::ObjectImp() -: fJSObjectRef(nil) +: fJSObjectRef(nullptr) { JSObjectRef theOR = ::JSObjectMake(sCurrentContextRef(), spGetJSClass(), this); ZAssert(theOR == fJSObjectRef); @@ -837,7 +807,7 @@ void ObjectImp::Finalize(JSObjectRef iJSObjectRef) { ZAssert(fJSObjectRef == iJSObjectRef); - fJSObjectRef = nil; + fJSObjectRef = nullptr; this->pTossIfAppropriate(); } @@ -874,7 +844,7 @@ void ObjectImp::spFinalize(JSObjectRef object) { // Hmm -- pretend there's no current context. - ContextRefSetter cs(nil); + ContextRefSetter cs(nullptr); if (ZRef<ObjectImp> fun = spFromRef(object)) fun->Finalize(object); } Modified: trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -159,14 +159,13 @@ // ZVal Get protocol template <class S> - bool QGet_T(S& oVal) const; + ZQ_T<S> QGet_T() const; template <class S> S DGet_T(const S& iDefault) const { - S result; - if (this->QGet_T(result)) - return result; + if (ZQ_T<S> theQ = this->QGet_T<S>()) + return theQ.Get(); return iDefault; } @@ -202,7 +201,7 @@ ObjectRef& operator=(const ZRef<JSObjectRef>& iOther); // ZMap protocol (ish) - bool QGet(const string8& iName, Value& oVal) const; + ZQ_T<Value> QGet(const string8& iName) const; Value DGet(const Value& iDefault, const string8& iName) const; Value Get(const string8& iName) const; bool Set(const string8& iName, const Value& iValue); @@ -211,7 +210,7 @@ // ZSeq protocol (ish) bool IsSeq() const; size_t Count() const; - bool QGet(size_t iIndex, Value& oVal) const; + ZQ_T<Value> QGet(size_t iIndex) const; Value DGet(const Value& iDefault, size_t iIndex) const; Value Get(size_t iIndex) const; bool Set(size_t iIndex, const Value& iValue); Modified: trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Guest.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Guest.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Guest.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -70,14 +70,11 @@ // Provide implementation of NPVariantBase::QGet_T<ZRef<NPObjectG> > template <> -bool NPVariantBase::QGet_T<ZRef<NPObjectG> >(ZRef<NPObjectG>& oVal) const +ZQ_T<ZRef<NPObjectG> > NPVariantBase::QGet_T<ZRef<NPObjectG> >() const { if (type == NPVariantType_Object) - { - oVal = static_cast<NPObjectG*>(value.objectValue); - return true; - } - return false; + return ZRef<NPObjectG>(static_cast<NPObjectG*>(value.objectValue)); + return null; } template <> Modified: trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Host.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Host.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Host.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -46,14 +46,11 @@ // Provide implementation of NPVariantBase::QGet_T<ZRef<NPObjectH> > template <> -bool NPVariantBase::QGet_T<ZRef<NPObjectH> >(ZRef<NPObjectH>& oVal) const +ZQ_T<ZRef<NPObjectH> > NPVariantBase::QGet_T<ZRef<NPObjectH> >() const { if (type == NPVariantType_Object) - { - oVal = static_cast<NPObjectH*>(value.objectValue); - return true; - } - return false; + return ZRef<NPObjectH>(static_cast<NPObjectH*>(value.objectValue)); + return null; } template <> Modified: trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Object.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Object.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Object.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -22,6 +22,7 @@ #define __ZNetscape_Object__ 1 #include "zconfig.h" +#include "zoolib/ZQ_T.h" #include "zoolib/netscape/ZNetscape.h" #include <string> @@ -81,8 +82,8 @@ bool Enumerate(std::vector<NPIdentifier>& oIdentifiers); // ZMap protocol (ish) - bool QGet(const std::string& iName, Variant_t& oVal); - bool QGet(size_t iIndex, Variant_t& oVal); + ZQ_T<Variant_t> QGet(const std::string& iName); + ZQ_T<Variant_t> QGet(size_t iIndex); Variant_t DGet(const Variant_t& iDefault, const std::string& iName); Variant_t DGet(const Variant_t& iDefault, size_t iIndex); Modified: trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_ObjectPriv.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_ObjectPriv.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_ObjectPriv.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -130,12 +130,22 @@ } template <class Variant_t> -bool NPObject_T<Variant_t>::QGet(const std::string& iName, Variant_t& oVal) - { return static_cast<Self_t*>(this)->GetProperty(iName, oVal); } +ZQ_T<Variant_t> NPObject_T<Variant_t>::QGet(const std::string& iName) + { + Variant_t theVar; + if (static_cast<Self_t*>(this)->GetProperty(iName, theVar)) + return theVar; + return null; + } template <class Variant_t> -bool NPObject_T<Variant_t>::QGet(size_t iIndex, Variant_t& oVal) - { return static_cast<Self_t*>(this)->GetProperty(iIndex, oVal); } +ZQ_T<Variant_t> NPObject_T<Variant_t>::QGet(size_t iIndex) + { + Variant_t theVar; + if (static_cast<Self_t*>(this)->GetProperty(iIndex, theVar)) + return theVar; + return null; + } template <class Variant_t> Variant_t NPObject_T<Variant_t>::DGet(const Variant_t& iDefault, const std::string& iName) Modified: trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Variant.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Variant.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Variant.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -29,49 +29,39 @@ #pragma mark * NPVariantBase template <> -bool NPVariantBase::QGet_T<bool>(bool& oVal) const +ZQ_T<bool> NPVariantBase::QGet_T<bool>() const { if (type == NPVariantType_Bool) - { - oVal = value.boolValue; - return true; - } - return false; + return bool(value.boolValue); + return null; } template <> -bool NPVariantBase::QGet_T<int32>(int32& oVal) const +ZQ_T<int32> NPVariantBase::QGet_T<int32>() const { if (type == NPVariantType_Int32) - { - oVal = value.intValue; - return true; - } - return false; + return int32(value.boolValue); + return null; } template <> -bool NPVariantBase::QGet_T<double>(double& oVal) const +ZQ_T<double> NPVariantBase::QGet_T<double>() const { if (type == NPVariantType_Double) - { - oVal = value.doubleValue; - return true; - } - return false; + return double(value.boolValue); + return null; } template <> -bool NPVariantBase::QGet_T<std::string>(std::string& oVal) const +ZQ_T<std::string> NPVariantBase::QGet_T<std::string>() const { if (type == NPVariantType_String) { - oVal = std::string( + return std::string( sNPStringCharsConst(value.stringValue), sNPStringLengthConst(value.stringValue)); - return true; } - return false; + return null; } } // namespace ZNetscape Modified: trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Variant.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Variant.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Variant.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -45,14 +45,13 @@ public: // ZVal Get protocol template <class S> - bool QGet_T(S& oVal) const; + ZQ_T<S> QGet_T() const; template <class S> S DGet_T(const S& iDefault) const { - S result; - if (this->QGet_T(result)) - return result; + if (ZQ_T<S> theQ = this->QGet_T<S>()) + return theQ.Get(); return iDefault; } Modified: trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_FileRef.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_FileRef.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_FileRef.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -84,10 +84,6 @@ #endif // __PIMac__ -namespace ZooLib { - -using std::string; - // ================================================================================================= #pragma mark - #pragma mark * ZPhotoshop suites, for local use @@ -95,9 +91,14 @@ static AutoSuite<PSHandleSuite2> spPSHandle(kPSHandleSuite, kPSHandleSuiteVersion2); + +namespace ZooLib { + +using std::string; + // ================================================================================================= #pragma mark - -#pragma mark * UseHandle +#pragma mark * UseHandle (anonymous) namespace { // anonymous Modified: trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -303,6 +303,26 @@ Val DGet(const Val& iDefault, size_t iIndex) const; Val Get(size_t iIndex) const; + template <class S> + ZQ_T<S> QGet_T(size_t iIndex) const + { + if (ZQ_T<Val_t> theQ = this->QGet(iIndex)) + return theQ.Get().QGet_T<S>(); + return null; + } + + template <class S> + S DGet_T(const S& iDefault, size_t iIndex) const + { + if (ZQ_T<S> theQ = this->QGet_T<S>(iIndex)) + return theQ.Get(); + return iDefault; + } + + template <class S> + S Get_T(size_t iIndex) const + { return this->DGet_T<S>(S(), iIndex); } + Seq& Append(const Val& iVal); // Our protocol @@ -363,6 +383,42 @@ Val Get(const string8& iName) const; Val Get(Index_t iIndex) const; + template <class S> + ZQ_T<S> QGet_T(KeyID iKey) const + { return this->Get(iKey).QGet_T<S>(); } + + template <class S> + ZQ_T<S> QGet_T(const string8& iName) const + { return this->Get(iName).QGet_T<S>(); } + + template <class S> + ZQ_T<S> QGet_T(const Index_t& iIndex) const + { return this->Get(iIndex).QGet_T<S>(); } + + template <class S> + S DGet_T(const S& iDefault, KeyID iKey) const + { return this->Get(iKey).DGet_T<S>(iDefault); } + + template <class S> + S DGet_T(const S& iDefault, const string8& iName) const + { return this->Get(iName).DGet_T<S>(iDefault); } + + template <class S> + S DGet_T(const S& iDefault, const Index_t& iIndex) const + { return this->Get(iIndex).DGet_T<S>(iDefault); } + + template <class S> + S Get_T(KeyID iKey) const + { return this->Get(iKey).Get_T<S>(); } + + template <class S> + S Get_T(const string8& iName) const + { return this->Get(iName).Get_T<S>(); } + + template <class S> + S Get_T(const Index_t& iIndex) const + { return this->Get(iIndex).Get_T<S>(); } + Map& Set(KeyID iKey, const Val& iVal); Map& Set(const string8& iName, const Val& iVal); Map& Set(Index_t iIndex, const Val& iVal); Modified: trunk/zoolib/source/cxx/zoolib/ZAny.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZAny.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZAny.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -207,17 +207,6 @@ { return ZAnyBaseCast<S>(this); } template <class S> - bool QGet_T(S& oVal) const - { - if (const S* theVal = this->PGet_T<S>()) - { - oVal = *theVal; - return true; - } - return false; - } - - template <class S> ZQ_T<S> QGet_T() const { if (const S* theVal = this->PGet_T<S>()) Modified: trunk/zoolib/source/cxx/zoolib/ZHTTP.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZHTTP.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZHTTP.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -216,31 +216,27 @@ bool sOrganizeRanges(size_t iSourceSize, const Val& iRangeParam, vector<pair<size_t, size_t> >& oRanges) { - Map asMap = iRangeParam.GetMap(); - int64 reqBegin; - if (asMap.Get("begin").QGet_T(reqBegin)) + const Map asMap = iRangeParam.GetMap(); + if (ZQ_T<int64> reqBegin = asMap.QGet_T<int64>("begin")) { - int64 reqEnd; - if (asMap.Get("end").QGet_T(reqEnd)) + if (reqBegin.Get() <= iSourceSize) { - if (reqEnd < reqBegin) - return false; - if (reqEnd > iSourceSize) - return false; + if (ZQ_T<int64> reqEnd = asMap.QGet_T<int64>("end")) + { + if (reqEnd.Get() < reqBegin.Get()) + return false; + if (reqEnd.Get() > iSourceSize) + return false; + oRanges.push_back(pair<size_t, size_t>(reqBegin.Get(), reqEnd.Get() + 1)); + return true; + } } - if (reqBegin > iSourceSize) - return false; - oRanges.push_back(pair<size_t, size_t>(reqBegin, reqEnd + 1)); - return true; } - else + else if (ZQ_T<int64> reqLast = asMap.QGet_T<int64>("last")) { - int64 reqLast; - if (asMap.Get("last").QGet_T(reqLast)) + if (reqLast.Get() <= iSourceSize) { - if (reqLast > iSourceSize) - return false; - oRanges.push_back(pair<size_t, size_t>(iSourceSize - reqLast, iSourceSize)); + oRanges.push_back(pair<size_t, size_t>(iSourceSize - reqLast.Get(), iSourceSize)); return true; } } Modified: trunk/zoolib/source/cxx/zoolib/ZQ_T.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZQ_T.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZQ_T.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -59,7 +59,7 @@ sDestroy_T<T>(iOther.fBytes); iOther.fHasValue = false; fHasValue = true; - } + } } ZQ_T() @@ -131,6 +131,22 @@ return *sFetch_T<T>(fBytes); } + T& Get() + { + ZAssert(fHasValue); + return *sFetch_T<T>(fBytes); + } + + T& OParam() + { + if (fHasValue) + sDestroy_T<T>(fBytes); + + fHasValue = true; + + sConstruct_T<T>(fBytes); + } + void Clear() { if (fHasValue) Modified: trunk/zoolib/source/cxx/zoolib/ZValAccessors.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZValAccessors.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZValAccessors.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -27,6 +27,7 @@ #pragma mark * ZMACRO_ZValAccessors #define ZMACRO_ZValAccessors_Decl_Get(T, TYPENAME, TYPE) \ + ZQ_T<TYPE> QGet##TYPENAME() const; \ bool QGet##TYPENAME(TYPE& oVal) const; \ TYPE DGet##TYPENAME(const TYPE& iDefault) const; \ TYPE Get##TYPENAME() const; \ @@ -36,10 +37,16 @@ void Set##TYPENAME(const TYPE& iVal); \ #define ZMACRO_ZValAccessors_Def_GetP(P, T, TYPENAME, TYPE) \ + P ZQ_T<TYPE> T::QGet##TYPENAME() const \ + { return this->QGet_T<TYPE>(); } \ P bool T::QGet##TYPENAME(TYPE& oVal) const \ - { return this->QGet_T<>(oVal); } \ + { \ + if (ZQ_T<TYPE> theQ = this->QGet_T<TYPE>()) \ + { oVal = theQ.Get(); return true; } \ + return false; \ + } \ P TYPE T::DGet##TYPENAME(const TYPE& iDefault) const \ - { return this->DGet_T<>(iDefault); } \ + { return this->DGet_T<TYPE>(iDefault); } \ P TYPE T::Get##TYPENAME() const \ { return this->Get_T<TYPE>(); } \ Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -175,16 +175,6 @@ return ZQ_T<ZVal_Any>(); } -bool ZSeq_Any::QGet(size_t iIndex, ZVal_Any& oVal) const - { - if (const ZVal_Any* theVal = this->PGet(iIndex)) - { - oVal = *theVal; - return true; - } - return false; - } - ZVal_Any ZSeq_Any::DGet(const ZVal_Any& iDefault, size_t iIndex) const { if (const ZVal_Any* theVal = this->PGet(iIndex)) @@ -436,26 +426,6 @@ return ZQ_T<ZVal_Any>(); } -bool ZMap_Any::QGet(const string8& iName, ZVal_Any& oVal) const - { - if (const ZVal_Any* theVal = this->PGet(iName)) - { - oVal = *theVal; - return true; - } - return false; - } - -bool ZMap_Any::QGet(const Index_t& iIndex, ZVal_Any& oVal) const - { - if (const ZVal_Any* theVal = this->PGet(iIndex)) - { - oVal = *theVal; - return true; - } - return false; - } - ZVal_Any ZMap_Any::DGet(const ZVal_Any& iDefault, const string8& iName) const { if (const ZVal_Any* theVal = this->PGet(iName)) Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -133,28 +133,48 @@ void Clear(); + ZVal_Any* PGet(size_t iIndex); + const ZVal_Any* PGet(size_t iIndex) const; + ZQ_T<ZVal_Any> QGet(size_t iIndex) const; + ZVal_Any DGet(const ZVal_Any& iDefault, size_t iIndex) const; + const ZVal_Any& Get(size_t iIndex) const; + template <class S> - S* PGet_T(size_t iIndex); + S* PGet_T(size_t iIndex) + { + if (ZVal_Any* theVal = this->PGet(iIndex)) + return theVal->PGet_T<S>(); + return nullptr; + } template <class S> - const S* PGet_T(size_t iIndex) const; + const S* PGet_T(size_t iIndex) const + { + if (const ZVal_Any* theVal = this->PGet(iIndex)) + return theVal->PGet_T<S>(); + return nullptr; + } template <class S> - ZQ_T<S> QGet_T(size_t iIndex) const; + ZQ_T<S> QGet_T(size_t iIndex) const + { + if (ZQ_T<Val_t> theQ = this->QGet(iIndex)) + return theQ.Get().QGet_T<S>(); + return null; + } template <class S> - S DGet_T(const S& iDefault, size_t iIndex) const; + S DGet_T(const S& iDefault, size_t iIndex) const + { + if (ZQ_T<S> theQ = this->QGet_T<S>(iIndex)) + return theQ.Get(); + return iDefault; + } template <class S> - S Get_T(size_t iIndex) const; + S Get_T(size_t iIndex) const + { return this->DGet_T<S>(S(), iIndex); } - ZVal_Any* PGet(size_t iIndex); - const ZVal_Any* PGet(size_t iIndex) const; - ZQ_T<ZVal_Any> QGet(size_t iIndex) const; - bool QGet(size_t iIndex, ZVal_Any& oVal) const; - ZVal_Any DGet(const ZVal_Any& iDefault, size_t iIndex) const; - const ZVal_Any& Get(size_t iIndex) const; - ZSeq_Any& Set(size_t iIndex, const ZVal_Any& iVal); ZSeq_Any& Erase(size_t iIndex); @@ -169,43 +189,6 @@ ZRef<Rep> fRep; }; -template <class S> -inline -S* ZSeq_Any::PGet_T(size_t iIndex) - { - if (ZVal_Any* theVal = this->PGet(iIndex)) - return theVal->PGet_T<S>(); - return nullptr; - } - -template <class S> -inline -const S* ZSeq_Any::PGet_T(size_t iIndex) const - { - if (const ZVal_Any* theVal = this->PGet(iIndex)) - return theVal->PGet_T<S>(); - return nullptr; - } - -template <class S> -inline -ZQ_T<S> ZSeq_Any::QGet_T(size_t iIndex) const - { - if (const ZVal_Any* theVal = this->PGet(iIndex)) - return theVal->QGet_T<S>(); - return ZQ_T<S>(); - } - -template <class S> -inline -S ZSeq_Any::DGet_T(const S& iDefault, size_t iIndex) const - { return this->Get(iIndex).DGet_T<S>(iDefault); } - -template <class S> -inline -S ZSeq_Any::Get_T(size_t iIndex) const - { return this->Get(iIndex).Get_T<S>(); } - // ================================================================================================= #pragma mark - #pragma mark * ZSeq_Any::Rep @@ -274,54 +257,85 @@ // ZMap protocol void Clear(); + ZVal_Any* PGet(const string8& iName); + ZVal_Any* PGet(const Index_t& iIndex); + + const ZVal_Any* PGet(const string8& iName) const; + const ZVal_Any* PGet(const Index_t& iIndex) const; + + ZQ_T<ZVal_Any> QGet(const string8& iName) const; + ZQ_T<ZVal_Any> QGet(const Index_t& iIndex) const; + + ZVal_Any DGet(const ZVal_Any& iDefault, const string8& iName) const; + ZVal_Any DGet(const ZVal_Any& iDefault, const Index_t& iIndex) const; + + const ZVal_Any& Get(const string8& iName) const; + const ZVal_Any& Get(const Index_t& iIndex) const; + template <class S> - S* PGet_T(const string8& iName); + S* PGet_T(const string8& iName) + { + if (ZVal_Any* theVal = this->PGet(iName)) + return theVal->PGet_T<S>(); + return nullptr; + } template <class S> - S* PGet_T(const Index_t& iIndex); + S* PGet_T(const Index_t& iIndex) + { + if (ZVal_Any* theVal = this->PGet(iIndex)) + return theVal->PGet_T<S>(); + return nullptr; + } template <class S> - const S* PGet_T(const string8& iName) const; + const S* PGet_T(const string8& iName) const + { + if (const ZVal_Any* theVal = this->PGet(iName)) + return theVal->PGet_T<S>(); + return nullptr; + } template <class S> - const S* PGet_T(const Index_t& iIndex) const; + const S* PGet_T(const Index_t& iIndex) const + { + if (const ZVal_Any* theVal = this->PGet(iIndex)) + return theVal->PGet_T<S>(); + return nullptr; + } template <class S> - ZQ_T<S> QGet_T(const string8& iName) const; + ZQ_T<S> QGet_T(const string8& iName) const + { + if (const ZVal_Any* theVal = this->PGet(iName)) + return theVal->QGet_T<S>(); + return ZQ_T<S>(); + } template <class S> - ZQ_T<S> QGet_T(const Index_t& iIndex) const; + ZQ_T<S> QGet_T(const Index_t& iIndex) const + { + if (const ZVal_Any* theVal = this->PGet(iIndex)) + return theVal->QGet_T<S>(); + return ZQ_T<S>(); + } template <class S> - S DGet_T(const S& iDefault, const string8& iName) const; + S DGet_T(const S& iDefault, const string8& iName) const + { return this->Get(iName).DGet_T<S>(iDefault); } template <class S> - S DGet_T(const S& iDefault, const Index_t& iIndex) const; + S DGet_T(const S& iDefault, const Index_t& iIndex) const + { return this->Get(iIndex).DGet_T<S>(iDefault); } template <class S> - S Get_T(const string8& iName) const; + S Get_T(const string8& iName) const + { return this->Get(iName).Get_T<S>(); } template <class S> - S Get_T(const Index_t& iIndex) const; + S Get_T(const Index_t& iIndex) const + { return this->Get(iIndex).Get_T<S>(); } - ZVal_Any* PGet(const string8& iName); - ZVal_Any* PGet(const Index_t& iIndex); - - const ZVal_Any* PGet(const string8& iName) const; - const ZVal_Any* PGet(const Index_t& iIndex) const; - - ZQ_T<ZVal_Any> QGet(const string8& iName) const; - ZQ_T<ZVal_Any> QGet(const Index_t& iIndex) const; - - bool QGet(const string8& iName, ZVal_Any& oVal) const; - bool QGet(const Index_t& iIndex, ZVal_Any& oVal) const; - - ZVal_Any DGet(const ZVal_Any& iDefault, const string8& iName) const; - ZVal_Any DGet(const ZVal_Any& iDefault, const Index_t& iIndex) const; - - const ZVal_Any& Get(const string8& iName) const; - const ZVal_Any& Get(const Index_t& iIndex) const; - ZMap_Any& Set(const string8& iName, const ZVal_Any& iVal); ZMap_Any& Set(const Index_t& iIndex, const ZVal_Any& iVal); @@ -344,80 +358,6 @@ ZRef<Rep> fRep; }; -template <class S> -inline -S* ZMap_Any::PGet_T(const string8& iName) - { - if (ZVal_Any* theVal = this->PGet(iName)) - return theVal->PGet_T<S>(); - return nullptr; - } - -template <class S> -inline -S* ZMap_Any::PGet_T(const Index_t& iIndex) - { - if (ZVal_Any* theVal = this->PGet(iIndex)) - return theVal->PGet_T<S>(); - return nullptr; - } - -template <class S> -inline -const S* ZMap_Any::PGet_T(const string8& iName) const - { - if (const ZVal_Any* theVal = this->PGet(iName)) - return theVal->PGet_T<S>(); - return nullptr; - } - -template <class S> -inline -const S* ZMap_Any::PGet_T(const Index_t& iIndex) const - { - if (const ZVal_Any* theVal = this->PGet(iIndex)) - return theVal->PGet_T<S>(); - return nullptr; - } - -template <class S> -inline -ZQ_T<S> ZMap_Any::QGet_T(const string8& iName) const - { - if (const ZVal_Any* theVal = this->PGet(iName)) - return theVal->QGet_T<S>(); - return ZQ_T<S>(); - } - -template <class S> -inline -ZQ_T<S> ZMap_Any::QGet_T(const Index_t& iIndex) const - { - if (const ZVal_Any* theVal = this->PGet(iIndex)) - return theVal->QGet_T<S>(); - return ZQ_T<S>(); - } - -template <class S> -inline -S ZMap_Any::DGet_T(const S& iDefault, const string8& iName) const - { return this->Get(iName).DGet_T<S>(iDefault); } - -template <class S> -inline -S ZMap_Any::DGet_T(const S& iDefault, const Index_t& iIndex) const - { return this->Get(iIndex).DGet_T<S>(iDefault); } - -template <class S> -inline -S ZMap_Any::Get_T(const string8& iName) const - { return this->Get(iName).Get_T<S>(); } - -template <class S> -inline -S ZMap_Any::Get_T(const Index_t& iIndex) const - { return this->Get(iIndex).Get_T<S>(); } - // ================================================================================================= #pragma mark - #pragma mark * ZMap_Any::Rep Modified: trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -784,14 +784,18 @@ return *this; } -bool ZMap_AppleEvent::QGetAttr(AEKeyword iName, ZVal_AppleEvent& oVal) const - { return noErr == ::AEGetAttributeDesc(this, iName, typeWildCard, &oVal.OParam()); } +ZQ_T<ZVal_AppleEvent> ZMap_AppleEvent::QGetAttr(AEKeyword iName) const + { + ZVal_AppleEvent result; + if (noErr == ::AEGetAttributeDesc(this, iName, typeWildCard, &result.OParam())) + return result; + return null; + } ZVal_AppleEvent ZMap_AppleEvent::DGetAttr(const ZVal_AppleEvent& iDefault, AEKeyword iName) const { - ZVal_AppleEvent theVal; - if (this->QGetAttr(iName, theVal)) - return theVal; + if (ZQ_T<ZVal_AppleEvent> theVal = this->QGetAttr(iName)) + return theVal.Get(); return iDefault; } Modified: trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -100,17 +100,6 @@ ZQ_T<S> QGet_T() const; template <class S> - bool QGet_T(S& oVal) const - { - if (ZQ_T<S> result = this->QGet_T<S>()) - { - oVal = result.Get(); - return true; - } - return false; - } - - template <class S> S DGet_T(const S& iDefault) const { if (ZQ_T<S> result = this->QGet_T<S>()) @@ -251,7 +240,7 @@ // Our protocol AERecord& OParam(); - bool QGetAttr(AEKeyword iName, ZVal_AppleEvent& oVal) const; + ZQ_T<ZVal_AppleEvent> QGetAttr(AEKeyword iName) const; ZVal_AppleEvent DGetAttr(const ZVal_AppleEvent& iDefault, AEKeyword iName) const; ZVal_AppleEvent GetAttr(AEKeyword iName) const; void SetAttr(AEKeyword iName, const AEDesc& iVal); Modified: trunk/zoolib/source/cxx/zoolib/ZVal_CFType.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_CFType.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZVal_CFType.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -96,17 +96,6 @@ ZQ_T<S> QGet_T() const; template <class S> - bool QGet_T(S& oVal) const - { - if (ZQ_T<S> theQ = this->QGet_T<S>()) - { - oVal = theQ.Get(); - return true; - } - return false; - } - - template <class S> S DGet_T(const S& iDefault) const { if (ZQ_T<S> theQ = this->QGet_T<S>()) @@ -183,6 +172,21 @@ ZVal_CFType DGet(const ZVal_CFType& iDefault, size_t iIndex) const; ZVal_CFType Get(size_t iIndex) const; + template <class S> + inline + ZQ_T<S> QGet_T(size_t iIndex) const + { return this->Get(iIndex).QGet_T<S>(); } + + template <class S> + inline + S DGet_T(const S& iDefault, size_t iIndex) const + { return this->Get(iIndex).DGet_T<S>(iDefault); } + + template <class S> + inline + S Get_T(size_t iIndex) const + { return this->Get(iIndex).Get_T<S>(); } + ZSeq_CFType& Set(size_t iIndex, const ZVal_CFType& iVal); ZSeq_CFType& Erase(size_t iIndex); @@ -248,6 +252,30 @@ ZVal_CFType Get(const string8& iName) const; ZVal_CFType Get(CFStringRef iName) const; + template <class S> + ZQ_T<S> QGet_T(const string8& iName) const + { return this->Get(iName).QGet_T<S>(); } + + template <class S> + ZQ_T<S> QGet_T(CFStringRef iName) const + { return this->Get(iName).QGet_T<S>(); } + + template <class S> + S DGet_T(const S& iDefault, const string8& iName) const + { return this->Get(iName).DGet_T<S>(iDefault); } + + template <class S> + S DGet_T(const S& iDefault, CFStringRef iName) const + { return this->Get(iName).DGet_T<S>(iDefault); } + + template <class S> + S Get_T(const string8& iName) const + { return this->Get(iName).Get_T<S>(); } + + template <class S> + S Get_T(CFStringRef iName) const + { return this->Get(iName).Get_T<S>(); } + ZMap_CFType& Set(const string8& iName, const ZVal_CFType& iVal); ZMap_CFType& Set(CFStringRef iName, const ZVal_CFType& iVal); Modified: trunk/zoolib/source/cxx/zoolib/ZVal_NS.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_NS.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZVal_NS.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -96,22 +96,10 @@ ZQ_T<S> QGet_T() const; template <class S> - bool QGet_T(S& oVal) const + S DGet_T(const S& iDefault) const { if (ZQ_T<S> theQ = this->QGet_T<S>()) - { - oVal = theQ.Get(); - return true; - } - return false; - } - - template <class S> - S DGet_T(const S& iDefault) const - { - S result; - if (this->QGet_T(result)) - return result; + return theQ.Get(); return iDefault; } @@ -176,6 +164,18 @@ ZVal_NS DGet(const ZVal_NS& iDefault, size_t iIndex) const; ZVal_NS Get(size_t iIndex) const; + template <class S> + ZQ_T<S> QGet_T(size_t iIndex) const + { return this->Get(iIndex).QGet_T<S>(); } + + template <class S> + S DGet_T(const S& iDefault, size_t iIndex) const + { return this->Get(iIndex).DGet_T<S>(iDefault); } + + template <class S> + S Get_T(size_t iIndex) const + { return this->Get(iIndex).Get_T<S>(); } + ZSeq_NS& Set(size_t iIndex, const ZVal_NS& iVal); ZSeq_NS& Erase(size_t iIndex); @@ -237,6 +237,30 @@ ZVal_NS Get(const string8& iName) const; ZVal_NS Get(NSString* iName) const; + template <class S> + ZQ_T<S> QGet_T(const string8& iName) const + { return this->Get(iName).QGet_T<S>(); } + + template <class S> + ZQ_T<S> QGet_T(NSString* iName) const + { return this->Get(iName).QGet_T<S>(); } + + template <class S> + S DGet_T(const S& iDefault, const string8& iName) const + { return this->Get(iName).DGet_T<S>(iDefault); } + + template <class S> + S DGet_T(const S& iDefault, NSString* iName) const + { return this->Get(iName).DGet_T<S>(iDefault); } + + template <class S> + S Get_T(const string8& iName) const + { return this->Get(iName).Get_T<S>(); } + + template <class S> + S Get_T(NSString* iName) const + { return this->Get(iName).Get_T<S>(); } + ZMap_NS& Set(const string8& iName, const ZVal_NS& iVal); ZMap_NS& Set(NSString* iName, const ZVal_NS& iVal); Modified: trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -689,206 +689,149 @@ } template <> -bool ZVal_ZooLib::QGet_T<ZType>(ZType& oVal) const +ZQ_T<ZType> ZVal_ZooLib::QGet_T<ZType>() const { if (fType.fType == eZType_Type) - { - oVal = fData.fAs_Type; - return true; - } - return false; + return fData.fAs_Type; + return null; } template <> -bool ZVal_ZooLib::QGet_T<uint64>(uint64& oVal) const +ZQ_T<uint64> ZVal_ZooLib::QGet_T<uint64>() const { if (fType.fType == eZType_ID) - { - oVal = fData.fAs_ID; - return true; - } - return false; + return fData.fAs_ID; + return null; } template <> -bool ZVal_ZooLib::QGet_T<int8>(int8& oVal) const +ZQ_T<int8> ZVal_ZooLib::QGet_T<int8>() const { if (fType.fType == eZType_Int8) - { - oVal = fData.fAs_Int8; - return true; - } - return false; + return fData.fAs_Int8; + return null; } template <> -bool ZVal_ZooLib::QGet_T<int16>(int16& oVal) const +ZQ_T<int16> ZVal_ZooLib::QGet_T<int16>() const { if (fType.fType == eZType_Int16) - { - oVal = fData.fAs_Int16; - return true; - } - return false; + return fData.fAs_Int16; + return null; } template <> -bool ZVal_ZooLib::QGet_T<int32>(int32& oVal) const +ZQ_T<int32> ZVal_ZooLib::QGet_T<int32>() const { if (fType.fType == eZType_Int32) - { - oVal = fData.fAs_Int32; - return true; - } - return false; + return fData.fAs_Int32; + return null; } template <> -bool ZVal_ZooLib::QGet_T<int64>(int64& oVal) const +ZQ_T<int64> ZVal_ZooLib::QGet_T<int64>() const { if (fType.fType == eZType_Int64) - { - oVal = fData.fAs_Int64; - return true; - } - return false; + return fData.fAs_Int64; + return null; } template <> -bool ZVal_ZooLib::QGet_T<bool>(bool& oVal) const +ZQ_T<bool> ZVal_ZooLib::QGet_T<bool>() const { if (fType.fType == eZType_Bool) - { - oVal = fData.fAs_Bool; - return true; - } - return false; + return fData.fAs_Bool; + return null; } template <> -bool ZVal_ZooLib::QGet_T<float>(float& oVal) const +ZQ_T<float> ZVal_ZooLib::QGet_T<float>() const { if (fType.fType == eZType_Float) - { - oVal = fData.fAs_Float; - return true; - } - return false; + return fData.fAs_Float; + return null; } template <> -bool ZVal_ZooLib::QGet_T<double>(double& oVal) const +ZQ_T<double> ZVal_ZooLib::QGet_T<double>() const { if (fType.fType == eZType_Double) - { - oVal = fData.fAs_Double; - return true; - } - return false; + return fData.fAs_Double; + return null; } template <> -bool ZVal_ZooLib::QGet_T<ZTime>(ZTime& oVal) const +ZQ_T<ZTime> ZVal_ZooLib::QGet_T<ZTime>() const { if (fType.fType == eZType_Time) - { - oVal = fData.fAs_Time; - return true; - } - return false; + return fData.fAs_Time; + return null; } template <> -bool ZVal_ZooLib::QGet_T<void*>(void*& oVal) const +ZQ_T<void*> ZVal_ZooLib::QGet_T<void*>() const { if (fType.fType == eZType_Pointer) - { - oVal = fData.fAs_Pointer; - return true; - } - return false; + return fData.fAs_Pointer; + return null; } template <> -bool ZVal_ZooLib::QGet_T<ZRectPOD>(ZRectPOD& oVal) const +ZQ_T<ZRectPOD> ZVal_ZooLib::QGet_T<ZRectPOD>() const { if (fType.fType == eZType_Rect) - { - oVal = *fData.fAs_Rect; - return true; - } - return false; + return *fData.fAs_Rect; + return null; } template <> -bool ZVal_ZooLib::QGet_T<ZPointPOD>(ZPointPOD& oVal) const +ZQ_T<ZPointPOD> ZVal_ZooLib::QGet_T<ZPointPOD>() const { if (fType.fType == eZType_Point) - { - oVal = fData.fAs_Point; - return true; - } - return false; + return fData.fAs_Point; + return null; } template <> -bool ZVal_ZooLib::QGet_T<string>(string& oVal) const +ZQ_T<string> ZVal_ZooLib::QGet_T<string>() const { if (fType.fType == eZType_String) - { - sFetch_T<ValString>(fType.fBytes)->ToString(oVal); - return true; - } + return sFetch_T<ValString>(fType.fBytes)->AsString(); else if (fType.fType < 0) - { - oVal = string(fType.fBytes, -fType.fType-1); - return true; - } - return false; + return string(fType.fBytes, -fType.fType-1); + return null; } template <> -bool ZVal_ZooLib::QGet_T<ZData_ZooLib>(ZData_ZooLib& oVal) const +ZQ_T<ZData_ZooLib> ZVal_ZooLib::QGet_T<ZData_ZooLib>() const { if (fType.fType == eZType_Raw) - { - oVal = *sFetch_T<ZData_ZooLib>(fType.fBytes); - return true; - } - return false; + return *sFetch_T<ZData_ZooLib>(fType.fBytes); + return null; } template <> -bool ZVal_ZooLib::QGet_T<ZSeq_ZooLib>(ZSeq_ZooLib& oVal) const +ZQ_T<ZSeq_ZooLib> ZVal_ZooLib::QGet_T<ZSeq_ZooLib>() const { if (fType.fType == eZType_Vector) - { - oVal = *sFetch_T<ZSeq_ZooLib>(fType.fBytes); - return true; - } - return false; + return *sFetch_T<ZSeq_ZooLib>(fType.fBytes); + return null; } template <> -bool ZVal_ZooLib::QGet_T<ZMap_ZooLib>(ZMap_ZooLib& oVal) const +ZQ_T<ZMap_ZooLib> ZVal_ZooLib::QGet_T<ZMap_ZooLib>() const { if (fType.fType == eZType_Tuple) - { - oVal = *sFetch_T<ZMap_ZooLib>(fType.fBytes); - return true; - } - return false; + return *sFetch_T<ZMap_ZooLib>(fType.fBytes); + return null; } template <> -bool ZVal_ZooLib::QGet_T<ZRef<ZCounted> >(ZRef<ZCounted>& oVal) const +ZQ_T<ZRef<ZCounted> > ZVal_ZooLib::QGet_T<ZRef<ZCounted> >() const { if (fType.fType == eZType_RefCounted) - { - oVal = *sFetch_T<ZRef<ZCounted> >(fType.fBytes); - return true; - } - return false; + return *sFetch_T<ZRef<ZCounted> >(fType.fBytes); + return null; } template <> Modified: trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -121,14 +121,22 @@ void Clear(); template <class S> - bool QGet_T(S& oResult) const; + ZQ_T<S> QGet_T() const + { + S theVal; + if (this->QGet_T<S>(theVal)) + return theVal; + return null; + } template <class S> + bool QGet_T(S& oVal) const; + + template <class S> S DGet_T(const S& iDefault) const { - S result; - if (this->QGet_T(result)) - return result; + if (ZQ_T<S> theQ = this->QGet_T<S>()) + return theQ.Get(); return iDefault; } @@ -301,6 +309,7 @@ void Clear(); + ZQ_T<ZVal_ZooLib> QGet(size_t iIndex) const; bool QGet(size_t iIndex, ZVal_ZooLib& oVal) const; ZVal_ZooLib DGet(const ZVal_ZooLib& iDefault, size_t iIndex) const; ZVal_ZooLib Get(size_t iIndex) const; @@ -440,6 +449,10 @@ const ZVal_ZooLib* PGet(const char* iPropName) const; const ZVal_ZooLib* PGet(const ZTName& iPropName) const; + ZQ_T<ZVal_ZooLib> QGet(Index_t iIndex) const; + ZQ_T<ZVal_ZooLib> QGet(const char* iPropName) const; + ZQ_T<ZVal_ZooLib> QGet(const ZTName& iPropName) const; + bool QGet(Index_t iIndex, ZVal_ZooLib& oVal) const; bool QGet(const char* iPropName, ZVal_ZooLib& oVal) const; bool QGet(const ZTName& iPropName, ZVal_ZooLib& oVal) const; Modified: trunk/zoolib/source/cxx/zoolib/ZWinCOM.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWinCOM.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZWinCOM.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -185,168 +185,123 @@ } template <> -bool Variant::QGet_T<int8>(int8& oVal) const +ZQ_T<int8> Variant::QGet_T<int8>() const { if (VT_I1 == vt) - { - oVal = cVal; - return true; - } - return false; + return int8(cVal); + return null; } template <> -bool Variant::QGet_T<uint8>(uint8& oVal) const +ZQ_T<uint8> Variant::QGet_T<uint8>() const { if (VT_UI1 == vt) - { - oVal = bVal; - return true; - } - return false; + return uint8(bVal); + return null; } template <> -bool Variant::QGet_T<int16>(int16& oVal) const +ZQ_T<int16> Variant::QGet_T<int16>() const { if (VT_I2 == vt) - { - oVal = iVal; - return true; - } - return false; + return int16(iVal); + return null; } template <> -bool Variant::QGet_T<uint16>(uint16& oVal) const +ZQ_T<uint16> Variant::QGet_T<uint16>() const { if (VT_UI2 == vt) - { - oVal = uiVal; - return true; - } - return false; + return uint16(uiVal); + return null; } template <> -bool Variant::QGet_T<int32>(int32& oVal) const +ZQ_T<int32> Variant::QGet_T<int32>() const { if (VT_I4 == vt) - { - oVal = lVal; - return true; - } - return false; + return int32(lVal); + return null; } template <> -bool Variant::QGet_T<uint32>(uint32& oVal) const +ZQ_T<uint32> Variant::QGet_T<uint32>() const { if (VT_UI4 == vt) - { - oVal = ulVal; - return true; - } - return false; + return uint32(ulVal); + return null; } template <> -bool Variant::QGet_T<int64>(int64& oVal) const +ZQ_T<int64> Variant::QGet_T<int64>() const { if (VT_I8 == vt) - { - oVal = llVal; - return true; - } - return false; + return int64(llVal); + return null; } template <> -bool Variant::QGet_T<uint64>(uint64& oVal) const +ZQ_T<uint64> Variant::QGet_T<uint64>() const { if (VT_UI8 == vt) - { - oVal = ullVal; - return true; - } - return false; + return uint64(ullVal); + return null; } template <> -bool Variant::QGet_T<bool>(bool& oVal) const +ZQ_T<bool> Variant::QGet_T<bool>() const { if (VT_BOOL == vt) - { - oVal = boolVal; - return true; - } - return false; + return bool(boolVal); + return null; } template <> -bool Variant::QGet_T<float>(float& oVal) const +ZQ_T<float> Variant::QGet_T<float>() const { if (VT_R4 == vt) - { - oVal = fltVal; - return true; - } - return false; + return float(fltVal); + return null; } template <> -bool Variant::QGet_T<double>(double& oVal) const +ZQ_T<double> Variant::QGet_T<double>() const { if (VT_R8 == vt) - { - oVal = dblVal; - return true; - } - return false; + return double(dblVal); + return null; } template <> -bool Variant::QGet_T<string8>(string8& oVal) const +ZQ_T<string8> Variant::QGet_T<string8>() const { if (VT_BSTR == vt) - { - oVal = ZUnicode::sAsUTF8(bstrVal, ::SysStringLen(bstrVal)); - return true; - } - return false; + return ZUnicode::sAsUTF8(bstrVal, ::SysStringLen(bstrVal)); + return null; } template <> -bool Variant::QGet_T<string16>(string16& oVal) const +ZQ_T<string16> Variant::QGet_T<string16>() const { if (VT_BSTR == vt) - { - oVal = string16(bstrVal, ::SysStringLen(bstrVal)); - return true; - } - return false; + return string16(bstrVal, ::SysStringLen(bstrVal)); + return null; } template <> -bool Variant::QGet_T<ZRef<IUnknown> >(ZRef<IUnknown>& oVal) const +ZQ_T<ZRef<IUnknown> > Variant::QGet_T<ZRef<IUnknown> >() const { if (VT_UNKNOWN == vt) - { - oVal = punkVal; - return true; - } - return false; + return ZRef<IUnknown>(punkVal); + return null; } template <> -bool Variant::QGet_T<ZRef<IDispatch> >(ZRef<IDispatch>& oVal) const +ZQ_T<ZRef<IDispatch> > Variant::QGet_T<ZRef<IDispatch> >() const { if (VT_DISPATCH == vt) - { - oVal = pdispVal; - return true; - } - return false; + return ZRef<IDispatch>(pdispVal); + return null; } template <> Modified: trunk/zoolib/source/cxx/zoolib/ZWinCOM.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWinCOM.h 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZWinCOM.h 2010-06-16 03:18:57 UTC (rev 1433) @@ -112,14 +112,13 @@ // ZVal protocol template <class S> - bool QGet_T(S& oVal) const; + ZQ_T<S> QGet_T() const; template <class S> S DGet_T(const S& iDefault) const { - S result; - if (this->QGet_T(result)) - return result; + if (ZQ_T<S> theQ = this->QGet_T<S>()) + return theQ.Get(); return iDefault; } Modified: trunk/zoolib/source/cxx/zoolib/ZWinService.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWinService.cpp 2010-06-16 03:17:45 UTC (rev 1432) +++ trunk/zoolib/source/cxx/zoolib/ZWinService.cpp 2010-06-16 03:18:57 UTC (rev 1433) @@ -95,7 +95,7 @@ { if (fAllowPause) { - ZGuardMtx locker(fMutex_State); + ZAcqMtx acq(fMutex_State); if (fServiceStatus.dwCurrentState == SERVICE_RUNNING) { fServiceStatus.dwCurrentState = SERVICE_PAUSE_PENDING; @@ -115,7 +115,7 @@ { if (fAllowPause) { - ZGuardMtx locker(fMutex_State); + ZAcqMtx acq(fMutex_State); if (fServiceStatus.dwCurrentState == SERVICE_PAUSED) { fServiceStatus.dwCurrentState = SERVICE_CONTINUE_PENDING; @@ -133,7 +133,7 @@ } case SERVICE_CONTROL_STOP: { - ZGuardMtx locker(fMutex_State); + ZAcqMtx acq(fMutex_State); if (fServiceStatus.dwCurrentState == SERVICE_PAUSED || fServiceStatus.dwCurrentState == SERVICE_RUNNING) { @@ -173,7 +173,7 @@ void ZWinService::pServiceMain(DWORD argc, LPWSTR* argv) { { - ZGuardMtx locker(fMutex_State); + ZAcqMtx acq(fMutex_State); fServiceStatus.dwServiceType = SERVICE_WIN32; fServiceStatus.dwCurrentState = SERVICE_START_PENDING; fServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_PAUSE_CONTINUE; @@ -199,7 +199,7 @@ catch (...) {} - ZGuardMtx locker(fMutex_State); + ZAcqMtx acq(fMutex_State); fServiceStatus.dwCurrentState = SERVICE_STOPPED; ::SetServiceStatus(fServiceStatusHandle, &fServiceStatus); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2010-06-27 04:01:41
|
Revision: 1471 http://zoolib.svn.sourceforge.net/zoolib/?rev=1471&view=rev Author: agreen Date: 2010-06-27 04:01:33 +0000 (Sun, 27 Jun 2010) Log Message: ----------- Move useful, but obscure, file format stuff into zoolib/more. Added Paths: ----------- trunk/zoolib/source/cxx/more/zoolib/fileformat/ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_AppleDouble.cpp trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_AppleDouble.h trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_IFF.cpp trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_IFF.h trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_JPEG.cpp trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_JPEG.h trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime.cpp trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZFileFormat_AppleDouble.cpp trunk/zoolib/source/cxx/zoolib/ZFileFormat_AppleDouble.h trunk/zoolib/source/cxx/zoolib/ZFileFormat_IFF.cpp trunk/zoolib/source/cxx/zoolib/ZFileFormat_IFF.h trunk/zoolib/source/cxx/zoolib/ZFileFormat_JPEG.cpp trunk/zoolib/source/cxx/zoolib/ZFileFormat_JPEG.h trunk/zoolib/source/cxx/zoolib/ZFileFormat_QuickTime.cpp trunk/zoolib/source/cxx/zoolib/ZFileFormat_QuickTime.h Added: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_AppleDouble.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_AppleDouble.cpp (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_AppleDouble.cpp 2010-06-27 04:01:33 UTC (rev 1471) @@ -0,0 +1,131 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2006 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/fileformat/ZFileFormat_AppleDouble.h" +#include "zoolib/ZMemory.h" +#include "zoolib/ZStreamR_Source.h" +#include "zoolib/ZStreamRWPos_RAM.h" + +namespace ZooLib { +namespace FileFormat { +namespace IFF { + +using std::vector; + +// ================================================================================================= +#pragma mark - +#pragma mark * Writer + +Writer::Writer() + { + fIsAppleSingle = false; + } + +void Writer::SetIsAppleSingle(bool iIsAppleSingle) + { + fIsAppleSingle = iIsAppleSingle; + } + +void Writer::Append(uint32 iEntryID, ZRef<ZStreamerRPos> iStreamerRPos) + { + Entry theEntry; + theEntry.fID = iEntryID; + theEntry.fData = iStreamerRPos; + theEntry.fPadding = 0; + fEntries.push_back(theEntry); + } + +void Writer::Append(uint32 iEntryID, const ZStreamRPos& iStreamRPos) + { + ZRef<ZStreamerRWPos> theStreamer = new ZStreamerRWPos_T<ZStreamRWPos_RAM>; + theStreamer->GetStreamW().CopyAllFrom(iStreamRPos); + this->Append(iEntryID, theStreamer); + } + +void Writer::Append(uint32 iEntryID, const ZStreamR& iStreamR, size_t iSize) + { + ZRef<ZStreamerRWPos> theStreamer = new ZStreamerRWPos_T<ZStreamRWPos_RAM>; + theStreamer->GetStreamW().CopyFrom(iStreamR, iSize); + this->Append(iEntryID, theStreamer); + } + +void Writer::Append(uint32 iEntryID, const void* iSource, size_t iSize) + { + ZRef<ZStreamerRWPos> theStreamer = new ZStreamerRWPos_T<ZStreamRWPos_RAM>; + theStreamer->GetStreamWPos().Write(iSource, iSize); + this->Append(iEntryID, theStreamer); + } + +ZRef<ZStreamerRWPos> Writer::Create(uint32 iEntryID) + { + ZRef<ZStreamerRWPos> theStreamer = new ZStreamerRWPos_T<ZStreamRWPos_RAM>; + this->Append(iEntryID, theStreamer); + return theStreamer; + } + +void Writer::ToStream(const ZStreamW& iStreamW) const + { + // Magic number + if (fIsAppleSingle) + iStreamW.WriteUInt32(0x00051600); + else + iStreamW.WriteUInt32(0x00051607); + + // Version number + iStreamW.WriteUInt32(0x00020000); + + // Home file system (now just filler) + iStreamW.CopyFrom(ZStreamR_Source(), 16); + + // Number of entries + iStreamW.WriteUInt16(fEntries.size()); + + const size_t sizeHeader = 26; + const size_t sizeTOC = 12 * fEntries.size(); + size_t accumulatedOffset = sizeHeader + sizeTOC; + + for (vector<Entry>::const_iterator i = fEntries.begin(); i != fEntries.end(); ++i) + { + // Entry ID + iStreamW.WriteUInt32(i->fID); + + // Offset to data + iStreamW.WriteUInt32(accumulatedOffset); + + // Size + const size_t theSize = i->fData->GetStreamRPos().GetSize(); + iStreamW.WriteUInt32(theSize); + accumulatedOffset += theSize + i->fPadding; + } + + for (vector<Entry>::const_iterator i = fEntries.begin(); i != fEntries.end(); ++i) + { + const ZStreamRPos& theStreamRPos = i->fData->GetStreamRPos(); + uint64 oldPosition = theStreamRPos.GetPosition(); + theStreamRPos.SetPosition(0); + iStreamW.CopyAllFrom(theStreamRPos); + iStreamW.CopyFrom(ZStreamR_Source(), i->fPadding); + theStreamRPos.SetPosition(oldPosition); + } + } + +} // namespace IFF +} // namespace FileFormat +} // namespace ZooLib Added: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_AppleDouble.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_AppleDouble.h (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_AppleDouble.h 2010-06-27 04:01:33 UTC (rev 1471) @@ -0,0 +1,83 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2006 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZFileFormat_AppleDouble__ +#define __ZFileFormat_AppleDouble__ 1 +#include "zconfig.h" + +#include "zoolib/ZStreamer.h" + +#include <vector> + +namespace ZooLib { +namespace FileFormat { +namespace IFF { + +// ================================================================================================= +#pragma mark - +#pragma mark * FileFormat::AppleDouble + +static const uint32 entryID_DataFork = 1; +static const uint32 entryID_ResourceFork = 2; +static const uint32 entryID_RealName = 3; +static const uint32 entryID_Comment = 4; +static const uint32 entryID_IconBW = 5; +static const uint32 entryID_IconColor = 6; +static const uint32 entryID_FileInfo = 7; +static const uint32 entryID_FinderInfo = 9; +static const uint32 entryID_User = 0x80000000U; + +// ================================================================================================= +#pragma mark - +#pragma mark * FileFormat::AppleDouble::Writer + +class Writer + { +public: + Writer(); + + void SetIsAppleSingle(bool iIsAppleSingle); + + void Append(uint32 iEntryID, ZRef<ZStreamerRPos> iStreamerRPos); + void Append(uint32 iEntryID, const ZStreamRPos& iStreamRPos); + void Append(uint32 iEntryID, const ZStreamR& iStreamR, size_t iSize); + void Append(uint32 iEntryID, const void* iSource, size_t iSize); + + ZRef<ZStreamerRWPos> Create(uint32 iEntryID); + + void ToStream(const ZStreamW& iStreamW) const; + +private: + struct Entry + { + uint32 fID; + ZRef<ZStreamerRPos> fData; + uint32 fPadding; + }; + + bool fIsAppleSingle; + std::vector<Entry> fEntries; + }; + +} // namespace IFF +} // namespace FileFormat +} // namespace ZooLib + +#endif // __ZFileFormat_AppleDouble__ Added: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_IFF.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_IFF.cpp (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_IFF.cpp 2010-06-27 04:01:33 UTC (rev 1471) @@ -0,0 +1,408 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2002 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/fileformat/ZFileFormat_IFF.h" +#include "zoolib/ZByteSwap.h" +#include "zoolib/ZDebug.h" + +#include <string.h> // For strlen + +#ifndef kDebug_IFF +# define kDebug_IFF 1 +#endif + +namespace ZooLib { +namespace FileFormat { +namespace IFF { + +using std::min; +using std::pair; + +// ================================================================================================= +#pragma mark - +#pragma mark * Static helper functions + +static const uint8 spZeroes[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +static void spWriteZeroes(const ZStreamW& iStream, size_t iCount) + { + while (iCount) + { + size_t countWritten; + iStream.Write(spZeroes, min(iCount, countof(spZeroes)), &countWritten); + iCount -= countWritten; + } + } + +static size_t spAligned(size_t iCount, size_t iMultiple) + { return (iMultiple - (iCount % iMultiple)) % iMultiple; } + +// ================================================================================================= +#pragma mark - +#pragma mark * Writer + +Writer::Writer(bool iBigEndianSizes, size_t iPadMultiple) +: fBigEndianSizes(iBigEndianSizes), + fPadMultiple(iPadMultiple) + {} + +Writer::~Writer() + { + ZAssertStop(1, fChunks.empty()); + } + +void Writer::Begin(const ZStreamWPos& iStream, uint32 iChunkType) + { + iStream.WriteUInt32(iChunkType); + iStream.WriteUInt32(0); // Dummy for non-header-including size to be written in End + fChunks.push_back(pair<uint64, size_t>(iStream.GetPosition(), iChunkType)); + } + +void Writer::Begin(const ZStreamWPos& iStream, const char* iChunkType) + { + ZAssertStop(kDebug_IFF, ::strlen(iChunkType) == 4); + uint32 chunkType = ZByteSwap_ReadBig32(iChunkType); + this->Begin(iStream, chunkType); + } + +void Writer::End(const ZStreamWPos& iStream, uint32 iChunkType) + { + // Verify we've got a chunk open. + ZAssertStop(kDebug_IFF, fChunks.size()); + + // Grab info about the currently open chunk, and remove it from the stack. + uint64 start = fChunks.back().first; + uint32 chunkType = fChunks.back().second; + fChunks.pop_back(); + + // Verify that the chunk we're closing is the last one we opened. + ZAssertStop(kDebug_IFF, chunkType == iChunkType); + + // Write the chunk's size. + uint64 position = iStream.GetPosition(); + + iStream.SetPosition(start - 4); + + // Potential for overflow here + size_t chunkSize = position - start; + + if (fBigEndianSizes) + iStream.WriteUInt32(chunkSize); + else + iStream.WriteUInt32LE(chunkSize); + + iStream.SetPosition(position); + + // Write out any padding necessary. + spWriteZeroes(iStream, spAligned(chunkSize, fPadMultiple)); + } + +void Writer::End(const ZStreamWPos& iStream, const char* iChunkType) + { + ZAssertStop(kDebug_IFF, ::strlen(iChunkType) == 4); + uint32 chunkType = ZByteSwap_ReadBig32(iChunkType); + this->End(iStream, chunkType); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamR_Chunk + +StreamR_Chunk::StreamR_Chunk(uint32& oChunkType, const ZStreamR& iStream) +: fStream(iStream) + { this->pInit(oChunkType, true, true, 2); } + +StreamR_Chunk::StreamR_Chunk( + uint32& oChunkType, bool iSkipOnDestroy, const ZStreamR& iStream) +: fStream(iStream) + { this->pInit(oChunkType, iSkipOnDestroy, true, 2); } + +StreamR_Chunk::StreamR_Chunk(uint32& oChunkType, bool iSkipOnDestroy, + bool iBigEndianSizes, size_t iPadMultiple, const ZStreamR& iStream) +: fStream(iStream) + { this->pInit(oChunkType, iSkipOnDestroy, iBigEndianSizes, iPadMultiple); } + +StreamR_Chunk::~StreamR_Chunk() + { + if (fSkipOnDestroy) + { + try + { + fStream.Skip(fCountRemaining + fPadCount); + } + catch (...) + {} + } + } + +void StreamR_Chunk::Imp_Read(void* oDest, size_t iCount, size_t* oCountRead) + { + uint8* localDest = reinterpret_cast<uint8*>(oDest); + + while (iCount && fCountRemaining) + { + size_t countRead; + fStream.Read(localDest, min(iCount, fCountRemaining), &countRead); + if (countRead == 0) + break; + localDest += countRead; + fCountRemaining -= countRead; + iCount -= countRead; + } + + if (oCountRead) + *oCountRead = localDest - reinterpret_cast<uint8*>(oDest); + } + +size_t StreamR_Chunk::Imp_CountReadable() + { return min(fCountRemaining, fStream.CountReadable()); } + +bool StreamR_Chunk::Imp_WaitReadable(double iTimeout) + { return fStream.WaitReadable(iTimeout); } + +void StreamR_Chunk::Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten) + { + if (oCountRead) + *oCountRead = 0; + uint64 countRead; + fStream.CopyTo(iStreamW, min(iCount, uint64(fCountRemaining)), &countRead, oCountWritten); + fCountRemaining -= countRead; + if (oCountRead) + *oCountRead = countRead; + } + +void StreamR_Chunk::Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten) + { + uint64 countRead; + fStream.CopyTo(iStreamW, min(iCount, uint64(fCountRemaining)), &countRead, oCountWritten); + fCountRemaining -= countRead; + if (oCountRead) + *oCountRead = countRead; + } + +void StreamR_Chunk::Imp_Skip(uint64 iCount, uint64* oCountSkipped) + { + uint64 countSkipped; + fStream.Skip(min(iCount, uint64(fCountRemaining)), &countSkipped); + fCountRemaining -= countSkipped; + if (oCountSkipped) + *oCountSkipped = countSkipped; + } + +void StreamR_Chunk::pInit(uint32& oChunkType, bool iSkipOnDestroy, + bool iBigEndianSizes, size_t iPadMultiple) + { + try + { + fSkipOnDestroy = iSkipOnDestroy; + oChunkType = fStream.ReadUInt32(); + if (iBigEndianSizes) + fCountRemaining = fStream.ReadUInt32(); + else + fCountRemaining = fStream.ReadUInt32LE(); + + fPadCount = spAligned(fCountRemaining, iPadMultiple); + } + catch (...) + { + fSkipOnDestroy = false; + fCountRemaining = 0; + oChunkType = 0; + } + } + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamRPos_Chunk + +StreamRPos_Chunk::StreamRPos_Chunk(uint32& oChunkType, const ZStreamRPos& iStream) +: fStream(iStream) + { + this->pInit(oChunkType, true, true, 2); + } + +StreamRPos_Chunk::StreamRPos_Chunk( + uint32& oChunkType, bool iSkipOnDestroy, const ZStreamRPos& iStream) +: fStream(iStream) + { + this->pInit(oChunkType, iSkipOnDestroy, true, 2); + } + +StreamRPos_Chunk::StreamRPos_Chunk(uint32& oChunkType, bool iSkipOnDestroy, + bool iBigEndianSizes, size_t iPadMultiple, const ZStreamRPos& iStream) +: fStream(iStream) + { + this->pInit(oChunkType, iSkipOnDestroy, iBigEndianSizes, iPadMultiple); + } + +StreamRPos_Chunk::~StreamRPos_Chunk() + { + if (fSkipOnDestroy) + { + try + { + fStream.SetPosition(fStart + spAligned(fSize, fPadMultiple)); + } + catch (...) + {} + } + } + +void StreamRPos_Chunk::Imp_Read(void* oDest, size_t iCount, size_t* oCountRead) + { + uint8* localDest = reinterpret_cast<uint8*>(oDest); + size_t countRemaining = ZStream::sClampedSize(iCount, fStart + fSize, fStream.GetPosition()); + while (countRemaining) + { + size_t countRead; + fStream.Read(localDest, countRemaining, &countRead); + if (countRead == 0) + break; + localDest += countRead; + countRemaining -= countRead; + } + + if (oCountRead) + *oCountRead = localDest - reinterpret_cast<uint8*>(oDest); + } + +void StreamRPos_Chunk::Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten) + { + fStream.CopyTo(iStreamW, + min(iCount, fStart + fSize - fStream.GetPosition()), oCountRead, oCountWritten); + } + +void StreamRPos_Chunk::Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten) + { + fStream.CopyTo(iStreamW, + min(iCount, fStart + fSize - fStream.GetPosition()), oCountRead, oCountWritten); + } + +void StreamRPos_Chunk::Imp_Skip(uint64 iCount, uint64* oCountSkipped) + { + if (uint64 countToSkip = ZStream::sClampedCount(iCount, fStart + fSize, fStream.GetPosition())) + fStream.Skip(countToSkip, oCountSkipped); + else if (oCountSkipped) + *oCountSkipped = 0; + } + +uint64 StreamRPos_Chunk::Imp_GetPosition() + { return fStream.GetPosition() - fStart; } + +void StreamRPos_Chunk::Imp_SetPosition(uint64 iPosition) + { fStream.SetPosition(fStart + iPosition); } + +uint64 StreamRPos_Chunk::Imp_GetSize() + { return min(uint64(fSize), fStream.GetSize() - fStart); } + +void StreamRPos_Chunk::pInit(uint32& oChunkType, bool iSkipOnDestroy, + bool iBigEndianSizes, size_t iPadMultiple) + { + try + { + fSkipOnDestroy = iSkipOnDestroy; + fPadMultiple = iPadMultiple; + oChunkType = fStream.ReadUInt32(); + if (iBigEndianSizes) + fSize = fStream.ReadUInt32(); + else + fSize = fStream.ReadUInt32LE(); + } + catch (...) + { + fSkipOnDestroy = false; + fSize = 0; + oChunkType = 0; + } + fStart = fStream.GetPosition(); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamWPos_Chunk + +StreamWPos_Chunk::StreamWPos_Chunk(uint32 iChunkType, const ZStreamWPos& iStream) +: fStream(iStream), + fBigEndianSizes(true), + fPadMultiple(2) + { + this->pInit(iChunkType); + } + +StreamWPos_Chunk::StreamWPos_Chunk(uint32 iChunkType, bool iBigEndianSizes, + size_t iPadMultiple, const ZStreamWPos& iStream) +: fStream(iStream), + fBigEndianSizes(iBigEndianSizes), + fPadMultiple(iPadMultiple) + { + this->pInit(iChunkType); + } + +StreamWPos_Chunk::~StreamWPos_Chunk() + { + uint64 position = fStream.GetPosition(); + size_t size = position - fStart; + fStream.SetPosition(fStart - 4); + if (fBigEndianSizes) + fStream.WriteUInt32(size); + else + fStream.WriteUInt32LE(size); + fStream.SetPosition(position + spAligned(size, fPadMultiple)); + } + +void StreamWPos_Chunk::Imp_Write( + const void* iSource, size_t iCount, size_t* oCountWritten) + { fStream.Write(iSource, iCount, oCountWritten); } + +void StreamWPos_Chunk::Imp_CopyFromDispatch( + const ZStreamR& iStreamR, uint64 iCount, uint64* oCountRead, uint64* oCountWritten) + { fStream.CopyFrom(iStreamR, iCount, oCountRead, oCountWritten); } + +void StreamWPos_Chunk::Imp_CopyFrom(const ZStreamR& iStreamR, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten) + { fStream.CopyFrom(iStreamR, iCount, oCountRead, oCountWritten); } + +uint64 StreamWPos_Chunk::Imp_GetPosition() + { return fStream.GetPosition() - fStart; } + +void StreamWPos_Chunk::Imp_SetPosition(uint64 iPosition) + { fStream.SetPosition(iPosition + fStart); } + +uint64 StreamWPos_Chunk::Imp_GetSize() + { return fStream.GetSize() - fStart; } + +void StreamWPos_Chunk::Imp_SetSize(uint64 iSize) + { fStream.SetSize(iSize + fStart); } + +void StreamWPos_Chunk::pInit(uint32 iChunkType) + { + fStream.WriteUInt32(iChunkType); + fStream.WriteUInt32(0); // Dummy for non-header-including size to be written in End + + fStart = fStream.GetPosition(); + } + +} // namespace IFF +} // namespace FileFormat +} // namespace ZooLib Added: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_IFF.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_IFF.h (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_IFF.h 2010-06-27 04:01:33 UTC (rev 1471) @@ -0,0 +1,175 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2002 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZFileFormat_IFF__ +#define __ZFileFormat_IFF__ 1 +#include "zconfig.h" + +#include "zoolib/ZStream.h" +#include "zoolib/ZTypes.h" + +#include <vector> + +namespace ZooLib { +namespace FileFormat { +namespace IFF { + +// ================================================================================================= +#pragma mark - +#pragma mark * ZFileFormat_IFF::Writer + +class Writer + { +public: + Writer(bool iBigEndianSizes = true, size_t iPadMultiple = 2); + ~Writer(); + +// Our protocol + void Begin(const ZStreamWPos& iStream, uint32 iChunkType); + void Begin(const ZStreamWPos& iStream, const char* iChunkType); + + void End(const ZStreamWPos& iStream, uint32 iChunkType); + void End(const ZStreamWPos& iStream, const char* iChunkType); + +private: + bool fBigEndianSizes; + size_t fPadMultiple; + std::vector<std::pair<uint64, uint32> > fChunks; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZFileFormat_IFF::StreamR_Chunk + +class StreamR_Chunk : public ZStreamR + { +public: + StreamR_Chunk(uint32& oChunkType, const ZStreamR& iStream); + StreamR_Chunk(uint32& oChunkType, bool iSkipOnDestroy, const ZStreamR& iStream); + StreamR_Chunk(uint32& oChunkType, bool iSkipOnDestroy, + bool iBigEndianSizes, size_t iPadMultiple, const ZStreamR& iStream); + ~StreamR_Chunk(); + +// From ZStreamR + virtual void Imp_Read(void* oDest, size_t iCount, size_t* oCountRead); + virtual size_t Imp_CountReadable(); + virtual bool Imp_WaitReadable(double iTimeout); + + virtual void Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped); + +private: + void pInit( + uint32& oChunkType, bool iSkipOnDestroy, bool iBigEndianSizes, size_t iPadMultiple); + + const ZStreamR& fStream; + bool fSkipOnDestroy; + size_t fCountRemaining; + size_t fPadCount; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZFileFormat_IFF::StreamRPos_Chunk + +class StreamRPos_Chunk : public ZStreamRPos + { +public: + StreamRPos_Chunk(uint32& oChunkType, const ZStreamRPos& iStream); + StreamRPos_Chunk(uint32& oChunkType, bool iSkipOnDestroy, const ZStreamRPos& iStream); + StreamRPos_Chunk(uint32& oChunkType, bool iSkipOnDestroy, + bool iBigEndianSizes, size_t iPadMultiple, const ZStreamRPos& iStream); + ~StreamRPos_Chunk(); + +// From ZStreamR via ZStreamRPos + virtual void Imp_Read(void* oDest, size_t iCount, size_t* oCountRead); + + virtual void Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped); + +// From ZStreamR via ZStreamRPos + virtual uint64 Imp_GetPosition(); + virtual void Imp_SetPosition(uint64 iPosition); + + virtual uint64 Imp_GetSize(); + +private: + void pInit( + uint32& oChunkType, bool iSkipOnDestroy, bool iBigEndianSizes, size_t iPadMultiple); + + const ZStreamRPos& fStream; + bool fSkipOnDestroy; + uint64 fStart; + size_t fSize; + size_t fPadMultiple; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZFileFormat_IFF::StreamWPos_Chunk + +class StreamWPos_Chunk : public ZStreamWPos + { +public: + StreamWPos_Chunk(uint32 iChunkType, const ZStreamWPos& iStream); + StreamWPos_Chunk(uint32 iChunkType, bool iBigEndianSizes, + size_t iPadMultiple, const ZStreamWPos& iStream); + ~StreamWPos_Chunk(); + +// From ZStreamW via ZStreamWPos + virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten); + + virtual void Imp_CopyFromDispatch(const ZStreamR& iStreamR, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_CopyFrom(const ZStreamR& iStreamR, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + +// From ZStreamWPos + virtual uint64 Imp_GetPosition(); + virtual void Imp_SetPosition(uint64 iPosition); + + virtual uint64 Imp_GetSize(); + virtual void Imp_SetSize(uint64 iSize); + +private: + void pInit(uint32 iChunkType); + + const ZStreamWPos& fStream; + bool fBigEndianSizes; + size_t fPadMultiple; + uint64 fStart; + }; + +} // namespace IFF +} // namespace FileFormat +} // namespace ZooLib + +#endif // __ZFileFormat_IFF__ Added: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_JPEG.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_JPEG.cpp (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_JPEG.cpp 2010-06-27 04:01:33 UTC (rev 1471) @@ -0,0 +1,427 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2003 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/fileformat/ZFileFormat_JPEG.h" + +#include "zoolib/ZStream_Tee.h" +#include "zoolib/ZStreamRWPos_RAM.h" +#include "zoolib/ZStreamW_HexStrim.h" +#include "zoolib/ZStrim.h" + +namespace ZooLib { +namespace FileFormat { +namespace JPEG { + +using std::min; + +static const char* const spSegmentNames[] = + { + "SOF_0", // 0xC0 + "SOF_1", + "SOF_2", + "SOF_3", + + "DHT", + + "SOF_5", + "SOF_6", + "SOF_7", + + "JPG", + + "SOF_9", + "SOF_A", + "SOF_B", + + "DAC", + + "SOF_D", + "SOF_E", + "SOF_F", + + "RST_0", // 0xD0 + "RST_1", + "RST_2", + "RST_3", + "RST_4", + "RST_5", + "RST_6", + "RST_7", + + "SOI", + "EOI", + "SOS", + "DQT", + "DNL", + "DRI", + "DHP", + "EXP", + + "APP_0", // 0xE0 + "APP_1", + "APP_2", + "APP_3", + "APP_4", + "APP_5", + "APP_6", + "APP_7", + "APP_8", + "APP_9", + "APP_A", + "APP_B", + "APP_C", + "APP_D", + "APP_E", + "APP_F", + + "JPG_0", // 0xF0 + "JPG_1", + "JPG_2", + "JPG_3", + "JPG_4", + "JPG_5", + "JPG_6", + "JPG_7", + "JPG_8", + "JPG_9", + "JPG_A", + "JPG_B", + "JPG_C", + "JPG_D", + + "COM", // 0xFE + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZFileFormat_JPEG + +const char* sSegmentAsText(uint8 iSegment) + { + if (iSegment == 0x01) + return "TEM"; + + if (iSegment >= 0xC0 && iSegment <= 0xFE) + return spSegmentNames[iSegment - 0xC0]; + + return "??"; + } + +bool sIs_SOF(uint8 iSegment) + { + // Note that there are no segments of eJPEG_SOF_4, eJPEG_SOF_8 + // or eJPEG_SOF_C. Those bytes values (0xC4, 0xC8 and 0xCC) + // are used for other purposes. + switch (iSegment) + { + case eJPEG_SOF_0: + case eJPEG_SOF_1: + case eJPEG_SOF_2: + case eJPEG_SOF_3: + case eJPEG_SOF_5: + case eJPEG_SOF_6: + case eJPEG_SOF_7: + case eJPEG_SOF_9: + case eJPEG_SOF_A: + case eJPEG_SOF_B: + case eJPEG_SOF_D: + case eJPEG_SOF_E: + case eJPEG_SOF_F: + return true; + } + return false; + } + +bool sIs_APP(uint8 iSegment) + { + switch (iSegment) + { + case eJPEG_APP_0: + case eJPEG_APP_1: + case eJPEG_APP_2: + case eJPEG_APP_3: + case eJPEG_APP_4: + case eJPEG_APP_5: + case eJPEG_APP_6: + case eJPEG_APP_7: + case eJPEG_APP_8: + case eJPEG_APP_9: + case eJPEG_APP_A: + case eJPEG_APP_B: + case eJPEG_APP_C: + case eJPEG_APP_D: + case eJPEG_APP_E: + case eJPEG_APP_F: + return true; + } + return false; + } + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamR_Segment + +/** +A read filter stream that examines its source stream for 0xFF 0xXX sequences. If +the 0xXX byte is a valid JPEG segment start value then the constructor's \a oSegmentType +output parameter has the value written to it, and if it's one of the segments that +have a 16 bit big-endian segment length following it then the stream remembers +that value in fCountRemaining. Subsequent reads against the stream are capped +by the value of fCountRemaining. The destructor may skip the source stream to the end +of the discovered segment, thus aligning the source stream with the start of +the next segment. If that's not desired then the constructor taking a \a iSkipOnDestroy +parameter can be used, passing false to indicate that the source stream should be +left alone by the destructor. You can always call \c SkipAll if you'd like to +force the source stream to be moved to the end of the segment. If no valid segment start +sequence can be found then \a oSegmentType will be set to zero. + +\sa ZFileFormat_IFF +\sa ZFileFormat_QuickTime +*/ + +StreamR_Segment::StreamR_Segment(uint8& oSegmentType, const ZStreamR& iStreamR) +: fStreamR(iStreamR) + { + this->pInit(oSegmentType, true); + } + +StreamR_Segment::StreamR_Segment( + uint8& oSegmentType, bool iSkipOnDestroy, const ZStreamR& iStreamR) +: fStreamR(iStreamR) + { + this->pInit(oSegmentType, iSkipOnDestroy); + } + +StreamR_Segment::~StreamR_Segment() + { + if (fSkipOnDestroy && fCountRemaining) + { + try + { + fStreamR.Skip(fCountRemaining); + } + catch (...) + {} + } + } + +void StreamR_Segment::Imp_Read(void* oDest, size_t iCount, size_t* oCountRead) + { + uint8* localDest = reinterpret_cast<uint8*>(oDest); + while (iCount && fCountRemaining) + { + size_t countRead; + fStreamR.Read(localDest, min(iCount, fCountRemaining), &countRead); + if (countRead == 0) + break; + localDest += countRead; + fCountRemaining -= countRead; + iCount -= countRead; + } + if (oCountRead) + *oCountRead = localDest - reinterpret_cast<uint8*>(oDest); + } + +size_t StreamR_Segment::Imp_CountReadable() + { return min(fCountRemaining, fStreamR.CountReadable()); } + +bool StreamR_Segment::Imp_WaitReadable(double iTimeout) + { return fStreamR.WaitReadable(iTimeout); } + +void StreamR_Segment::Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten) + { + uint64 countRead; + fStreamR.CopyTo(iStreamW, min(iCount, uint64(fCountRemaining)), &countRead, oCountWritten); + fCountRemaining -= countRead; + if (oCountRead) + *oCountRead = countRead; + } + +void StreamR_Segment::Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten) + { + uint64 countRead; + fStreamR.CopyTo(iStreamW, min(iCount, uint64(fCountRemaining)), &countRead, oCountWritten); + fCountRemaining -= countRead; + if (oCountRead) + *oCountRead = countRead; + } + +void StreamR_Segment::Imp_Skip(uint64 iCount, uint64* oCountSkipped) + { + uint64 countSkipped; + fStreamR.Skip(min(iCount, uint64(fCountRemaining)), &countSkipped); + fCountRemaining -= countSkipped; + if (oCountSkipped) + *oCountSkipped = countSkipped; + } + +void StreamR_Segment::pInit(uint8& oSegmentType, bool iSkipOnDestroy) + { + fSkipOnDestroy = iSkipOnDestroy; + fCountRemaining = 0; + oSegmentType = 0; + + // Find the segment start by scanning for a 0xFF byte, + // then examine the byte that follows to see what + // kind of segment we've found, if any. + bool gotFF = false; + for (;;) + { + uint8 theByte; + if (!fStreamR.ReadByte(theByte)) + { + // The stream is truncated, return without + // updating oSegmentType or fCountRemaining. + return; + } + + if (theByte == 0xFF) + { + gotFF = true; + continue; + } + + if (!gotFF) + { + // It's a byte without a preceding 0xFF, + // just go around again. + continue; + } + + switch (theByte) + { + case eJPEG_TEM: + case eJPEG_RST_0: + case eJPEG_RST_1: + case eJPEG_RST_2: + case eJPEG_RST_3: + case eJPEG_RST_4: + case eJPEG_RST_5: + case eJPEG_RST_6: + case eJPEG_RST_7: + case eJPEG_SOI: + case eJPEG_EOI: + { + // A segment that has no following 16 bit length field. + // fCountRemaining thus does not need to be changed + // from the zero value it was initialized with. + oSegmentType = theByte; + break; + } + default: + { + if (theByte < eJPEG_RES_End) + { + // It's outside the range of valid segment markers. + // We'll assume we're in some bogus data and go around again. + gotFF = false; + continue; + } + try + { + // Read the 16 bit length field that follows. Note + // that the length includes the length field itself. + fCountRemaining = fStreamR.ReadUInt16() - sizeof(uint16); + oSegmentType = theByte; + } + catch (...) + { + // The stream was truncated. We'll drop out without + // having set oSegmentType or changed fCountRemaining, + // which will both remain zero and thus indicate that + // the stream is malformed. + } + } + } + // This is the end of the loop, which is only gone around + // by virtue of the explicit calls to continue above. + return; + } + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZFileFormat_JPEG, testing + +void sDumpSegments(const ZStreamR& iStreamR, const ZStrimW& iStrimW); +void sDumpSegments(const ZStreamR& iStreamR, const ZStrimW& iStrimW) + { + for (;;) + { + uint8 segmentType; + StreamR_Segment s(segmentType, iStreamR); + if (!segmentType) + break; + + const char* markerName = ""; + if (segmentType >= 0xC0) + markerName = sSegmentAsText(segmentType - 0xC0); + + iStrimW.Writef("Type: %02X, %s ", segmentType, markerName); + + if (sIs_SOF(segmentType)) + { + iStrimW.Writef("Precision: %d", s.ReadUInt8()); + iStrimW.Writef(", Y: %d", s.ReadUInt16()); + iStrimW.Writef(", X: %d", s.ReadUInt16()); + iStrimW.Writef(", Nf: %d", s.ReadUInt8()); + iStrimW.Writef("\n"); + } + else if (sIs_APP(segmentType) || segmentType == eJPEG_COM) + { + iStrimW.Writef("\n"); + for (;;) + { + uint64 countRead; + ZStreamRWPos_RAM theStream; + s.CopyTo(ZStreamW_Tee(theStream, + ZStreamW_HexStrim(" ", "", 100, iStrimW)), 16, &countRead, nullptr); + + if (countRead == 0) + break; + theStream.SetPosition(0); + iStrimW.Write(" |"); + for (;;) + { + uint8 theByte; + if (!theStream.ReadByte(theByte)) + break; + if (theByte < 0x20 || theByte >= 0x7f) + iStrimW.WriteCP('.'); + else + iStrimW.WriteCP(theByte); + } + iStrimW.Write("|\n"); + } + } + else + { + uint64 theSize; + s.SkipAll(&theSize); + iStrimW.Writef("size: %lld\n", theSize); + } + } + } + +} // namespace JPEG +} // namespace FileFormat +} // namespace ZooLib Added: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_JPEG.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_JPEG.h (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_JPEG.h 2010-06-27 04:01:33 UTC (rev 1471) @@ -0,0 +1,160 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2003 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZFileFormat_JPEG__ +#define __ZFileFormat_JPEG__ 1 +#include "zconfig.h" + +#include "zoolib/ZStream.h" +#include "zoolib/ZTypes.h" + +#include <vector> + +namespace ZooLib { +namespace FileFormat { +namespace JPEG { + +// ================================================================================================= +#pragma mark - +#pragma mark * ZFileFormat_JPEG + +enum + { + eJPEG_TEM = 0x01, + eJPEG_RES_Begin = 0x02, + eJPEG_RES_End = 0xC0, + + eJPEG_SOF_0 = 0xC0, + eJPEG_SOF_1 = 0xC1, + eJPEG_SOF_2 = 0xC2, + eJPEG_SOF_3 = 0xC3, + + eJPEG_DHT = 0xC4, + + eJPEG_SOF_5 = 0xC5, + eJPEG_SOF_6 = 0xC6, + eJPEG_SOF_7 = 0xC7, + + eJPEG_JPG = 0xC8, + + eJPEG_SOF_9 = 0xC9, + eJPEG_SOF_A = 0xCA, + eJPEG_SOF_B = 0xCB, + + eJPEG_DAC = 0xCC, + + eJPEG_SOF_D = 0xCD, + eJPEG_SOF_E = 0xCE, + eJPEG_SOF_F = 0xCF, + + eJPEG_RST_0 = 0xD0, + eJPEG_RST_1 = 0xD1, + eJPEG_RST_2 = 0xD2, + eJPEG_RST_3 = 0xD3, + eJPEG_RST_4 = 0xD4, + eJPEG_RST_5 = 0xD5, + eJPEG_RST_6 = 0xD6, + eJPEG_RST_7 = 0xD7, + + eJPEG_SOI = 0xD8, + eJPEG_EOI = 0xD9, + eJPEG_SOS = 0xDA, + eJPEG_DQT = 0xDB, + eJPEG_DNL = 0xDC, + eJPEG_DRI = 0xDD, + eJPEG_DHP = 0xDE, + eJPEG_EXP = 0xDF, + + eJPEG_APP_0 = 0xE0, + eJPEG_APP_1 = 0xE1, + eJPEG_APP_2 = 0xE2, + eJPEG_APP_3 = 0xE3, + eJPEG_APP_4 = 0xE4, + eJPEG_APP_5 = 0xE5, + eJPEG_APP_6 = 0xE6, + eJPEG_APP_7 = 0xE7, + eJPEG_APP_8 = 0xE8, + eJPEG_APP_9 = 0xE9, + eJPEG_APP_A = 0xEA, + eJPEG_APP_B = 0xEB, + eJPEG_APP_C = 0xEC, + eJPEG_APP_D = 0xED, + eJPEG_APP_E = 0xEE, + eJPEG_APP_F = 0xEF, + + eJPEG_JPG_0 = 0xF0, + eJPEG_JPG_1 = 0xF1, + eJPEG_JPG_2 = 0xF2, + eJPEG_JPG_3 = 0xF3, + eJPEG_JPG_4 = 0xF4, + eJPEG_JPG_5 = 0xF5, + eJPEG_JPG_6 = 0xF6, + eJPEG_JPG_7 = 0xF7, + eJPEG_JPG_8 = 0xF8, + eJPEG_JPG_9 = 0xF9, + eJPEG_JPG_A = 0xFA, + eJPEG_JPG_B = 0xFB, + eJPEG_JPG_C = 0xFC, + eJPEG_JPG_D = 0xFD, + + eJPEG_COM = 0xFE + }; + +const char* sSegmentAsText(uint8 iSegment); +bool sIs_SOF(uint8 iSegment); +bool sIs_APP(uint8 iSegment); + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamR_Segment + +class StreamR_Segment : public ZStreamR + { +public: + StreamR_Segment(uint8& oSegmentType, const ZStreamR& iStreamR); + StreamR_Segment(uint8& oSegmentType, bool iSkipOnDestroy, const ZStreamR& iStreamR); + ~StreamR_Segment(); + +// From ZStreamR + virtual void Imp_Read(void* oDest, size_t iCount, size_t* oCountRead); + virtual size_t Imp_CountReadable(); + virtual bool Imp_WaitReadable(double iTimeout); + + virtual void Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped); + +private: + void pInit(uint8& oSegmentType, bool iSkipOnDestroy); + + const ZStreamR& fStreamR; + bool fSkipOnDestroy; + size_t fCountRemaining; + }; + +} // namespace JPEG +} // namespace FileFormat +} // namespace ZooLib + +#endif // __ZFileFormat_JPEG__ Added: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime.cpp (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime.cpp 2010-06-27 04:01:33 UTC (rev 1471) @@ -0,0 +1,332 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2003 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/fileformat/ZFileFormat_QuickTime.h" +#include "zoolib/ZByteSwap.h" +#include "zoolib/ZDebug.h" + +#include <string.h> // For strlen + +#ifndef kDebug_QTFile +# define kDebug_QTFile 1 +#endif + +namespace ZooLib { +namespace FileFormat { +namespace QuickTime { + +using std::min; +using std::pair; +using std::vector; + +// ================================================================================================= +#pragma mark - +#pragma mark * Writer + +Writer::Writer() + {} + +Writer::~Writer() + { + ZAssertStop(1, fChunks.empty()); + } + +void Writer::Begin(const ZStreamWPos& iStream, uint32 iChunkType) + { + fChunks.push_back(pair<uint64, size_t>(iStream.GetPosition(), iChunkType)); + iStream.WriteUInt32(0); // Dummy for header-including size to be written in End + iStream.WriteUInt32(iChunkType); + } + +void Writer::Begin(const ZStreamWPos& iStream, const char* iChunkType) + { + ZAssertStop(kDebug_QTFile, ::strlen(iChunkType) == 4); + uint32 chunkType = ZByteSwap_ReadBig32(iChunkType); + this->Begin(iStream, chunkType); + } + +void Writer::End(const ZStreamWPos& iStream, uint32 iChunkType) + { + // Verify we've got a chunk open. + ZAssertStop(kDebug_QTFile, fChunks.size()); + + // Grab info about the currently open chunk, and remove it from the stack. + uint64 start = fChunks.back().first; + uint32 chunkType = fChunks.back().second; + fChunks.pop_back(); + + // Verify that the chunk we're closing is the last one we opened. + ZAssertStop(kDebug_QTFile, chunkType == iChunkType); + + // Write the chunk's size. + uint64 position = iStream.GetPosition(); + iStream.SetPosition(start); + iStream.WriteUInt32(position - start); + iStream.SetPosition(position); + } + +void Writer::End(const ZStreamWPos& iStream, const char* iChunkType) + { + ZAssertStop(kDebug_QTFile, ::strlen(iChunkType) == 4); + uint32 chunkType = ZByteSwap_ReadBig32(iChunkType); + this->End(iStream, chunkType); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamR_Chunk + +StreamR_Chunk::StreamR_Chunk(uint32& oChunkType, const ZStreamR& iStream) +: fStream(iStream) + { this->pInit(oChunkType, true); } + +StreamR_Chunk::StreamR_Chunk( + uint32& oChunkType, bool iSkipOnDestroy, const ZStreamR& iStream) +: fStream(iStream) + { this->pInit(oChunkType, iSkipOnDestroy); } + +StreamR_Chunk::~StreamR_Chunk() + { + if (fSkipOnDestroy) + { + try + { + fStream.Skip(fCountRemaining); + } + catch (...) + {} + } + } + +void StreamR_Chunk::Imp_Read(void* oDest, size_t iCount, size_t* oCountRead) + { + uint8* localDest = reinterpret_cast<uint8*>(oDest); + + while (iCount && fCountRemaining) + { + size_t countRead; + fStream.Read(localDest, min(iCount, fCountRemaining), &countRead); + if (countRead == 0) + break; + localDest += countRead; + fCountRemaining -= countRead; + iCount -= countRead; + } + + if (oCountRead) + *oCountRead = localDest - reinterpret_cast<uint8*>(oDest); + } + +size_t StreamR_Chunk::Imp_CountReadable() + { return min(fCountRemaining, fStream.CountReadable()); } + +bool StreamR_Chunk::Imp_WaitReadable(double iTimeout) + { return fStream.WaitReadable(iTimeout); } + +void StreamR_Chunk::Imp_CopyToDispatch( + const ZStreamW& iStreamW, uint64 iCount, uint64* oCountRead, uint64* oCountWritten) + { + uint64 countRead; + fStream.CopyTo(iStreamW, min(iCount, uint64(fCountRemaining)), &countRead, oCountWritten); + fCountRemaining -= countRead; + if (oCountRead) + *oCountRead = countRead; + } + +void StreamR_Chunk::Imp_CopyTo( + const ZStreamW& iStreamW, uint64 iCount, uint64* oCountRead, uint64* oCountWritten) + { + uint64 countRead; + fStream.CopyTo(iStreamW, min(iCount, uint64(fCountRemaining)), &countRead, oCountWritten); + fCountRemaining -= countRead; + if (oCountRead) + *oCountRead = countRead; + } + +void StreamR_Chunk::Imp_Skip(uint64 iCount, uint64* oCountSkipped) + { + uint64 countSkipped; + fStream.Skip(min(iCount, uint64(fCountRemaining)), &countSkipped); + fCountRemaining -= countSkipped; + if (oCountSkipped) + *oCountSkipped = countSkipped; + } + +void StreamR_Chunk::pInit(uint32& oChunkType, bool iSkipOnDestroy) + { + try + { + fSkipOnDestroy = iSkipOnDestroy; + fCountRemaining = fStream.ReadUInt32() - 8; + oChunkType = fStream.ReadUInt32(); + } + catch (...) + { + fSkipOnDestroy = false; + fCountRemaining = 0; + oChunkType = 0; + } + } + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamRPos_Chunk + +StreamRPos_Chunk::StreamRPos_Chunk( + uint32& oChunkType, const ZStreamRPos& iStream) +: fStream(iStream) + { this->pInit(oChunkType, true); } + +StreamRPos_Chunk::StreamRPos_Chunk( + uint32& oChunkType, bool iSkipOnDestroy, const ZStreamRPos& iStream) +: fStream(iStream) + { this->pInit(oChunkType, iSkipOnDestroy); } + +StreamRPos_Chunk::~StreamRPos_Chunk() + { + if (fSkipOnDestroy) + { + try + { + fStream.SetPosition(fStart + fSize); + } + catch (...) + {} + } + } + +void StreamRPos_Chunk::Imp_Read( + void* oDest, size_t iCount, size_t* oCountRead) + { + uint8* localDest = reinterpret_cast<uint8*>(oDest); + size_t countRemaining = ZStream::sClampedSize(iCount, fStart + fSize, fStream.GetPosition()); + while (countRemaining) + { + size_t countRead; + fStream.Read(localDest, countRemaining, &countRead); + if (countRead == 0) + break; + localDest += countRead; + countRemaining -= countRead; + } + + if (oCountRead) + *oCountRead = localDest - reinterpret_cast<uint8*>(oDest); + } + +void StreamRPos_Chunk::Imp_CopyToDispatch( + const ZStreamW& iStreamW, uint64 iCount, uint64* oCountRead, uint64* oCountWritten) + { + fStream.CopyTo(iStreamW, + min(iCount, fStart + fSize - fStream.GetPosition()), oCountRead, oCountWritten); + } + +void StreamRPos_Chunk::Imp_CopyTo( + const ZStreamW& iStreamW, uint64 iCount, uint64* oCountRead, uint64* oCountWritten) + { + fStream.CopyTo(iStreamW, + min(iCount, fStart + fSize - fStream.GetPosition()), oCountRead, oCountWritten); + } + +void StreamRPos_Chunk::Imp_Skip(uint64 iCount, uint64* oCountSkipped) + { + if (uint64 countToSkip = ZStream::sClampedCount(iCount, fStart + fSize, fStream.GetPosition())) + fStream.Skip(countToSkip, oCountSkipped); + else if (oCountSkipped) + *oCountSkipped = 0; + } + +uint64 StreamRPos_Chunk::Imp_GetPosition() + { return fStream.GetPosition() - fStart; } + +void StreamRPos_Chunk::Imp_SetPosition(uint64 iPosition) + { fStream.SetPosition(fStart + iPosition); } + +uint64 StreamRPos_Chunk::Imp_GetSize() + { return min(uint64(fSize), fStream.GetSize() - fStart); } + +void StreamRPos_Chunk::pInit(uint32& oChunkType, bool iSkipOnDestroy) + { + try + { + fSkipOnDestroy = iSkipOnDestroy; + fSize = fStream.ReadUInt32() - 8; + oChunkType = fStream.ReadUInt32(); + } + catch (...) + { + fSkipOnDestroy = false; + fSize = 0; + oChunkType = 0; + } + fStart = fStream.GetPosition(); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamWPos_Chunk + +StreamWPos_Chunk::StreamWPos_Chunk( + uint32 iChunkType, const ZStreamWPos& iStream) +: fStream(iStream) + { + fStream.WriteUInt32(0); // Dummy for header-including size to be written in End + fStream.WriteUInt32(iChunkType); + fStart = fStream.GetPosition(); + } + +StreamWPos_Chunk::~StreamWPos_Chunk() + { + uint64 position = fStream.GetPosition(); + fStream.SetPosition(fStart - 8); + fStream.WriteUInt32(position - fStart + 8); + fStream.SetPosition(position); + } + +void StreamWPos_Chunk::Imp_Write( + const void* iSource, size_t iCount, size_t* oCountWritten) + { fStream.Write(iSource, iCount, oCountWritten); } + +void StreamWPos_Chunk::Imp_CopyFromDispatch( + const ZStreamR& iStreamR, uint64 iCount, uint64* oCountRead, uint64* oCountWritten) + { fStream.CopyFrom(iStreamR, iCount, oCountRead, oCountWritten); } + +void StreamWPos_Chunk::Imp_CopyFrom( + const ZStreamR& iStreamR, uint64 iCount, uint64* oCountRead, uint64* oCountWritten) + { fStream.CopyFrom(iStreamR, iCount, oCountRead, oCountWritten); } + +void StreamWPos_Chunk::Imp_Flush() + { fStream.Flush(); } + +uint64 StreamWPos_Chunk::Imp_GetPosition() + { return fStream.GetPosition() - fStart; } + +void StreamWPos_Chunk::Imp_SetPosition(uint64 iPosition) + { fStream.SetPosition(iPosition + fStart); } + +uint64 StreamWPos_Chunk::Imp_GetSize() + { return fStream.GetSize() - fStart; } + +void StreamWPos_Chunk::Imp_SetSize(uint64 iSize) + { fStream.SetSize(iSize + fStart); } + +} // namespace QuickTime +} // namespace FileFormat +} // namespace ZooLib Added: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime.h (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime.h 2010-06-27 04:01:33 UTC (rev 1471) @@ -0,0 +1,161 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2003 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZFileFormat_QuickTime__ +#define __ZFileFormat_QuickTime__ 1 +#include "zconfig.h" + +#include "zoolib/ZStream.h" +#include "zoolib/ZTypes.h" + +#include <vector> + +namespace ZooLib { +namespace FileFormat { +namespace QuickTime { + +// ================================================================================================= +#pragma mark - +#pragma mark * FileFormat::QuickTime::Writer + +class Writer + { +public: + Writer(); + ~Writer(); + +// Our protocol + void Begin(const ZStreamWPos& iStream, uint32 iChunkType); + void Begin(const ZStreamWPos& iStream, const char* iChunkType); + + void End(const ZStreamWPos& iStream, uint32 iChunkType); + void End(const ZStreamWPos& iStream, const char* iChunkType); + +private: + std::vector<std::pair<uint64, uint32> > fChunks; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZStreamR_IFF + +class StreamR_Chunk : public ZStreamR + { +public: + StreamR_Chunk(uint32& oChunkType, const ZStreamR& iStream); + StreamR_Chunk(uint32& oChunkType, bool iSkipOnDestroy, const ZStreamR& iStream); + ~StreamR_Chunk(); + +// From ZStreamR + virtual void Imp_Read(void* oDest, size_t iCount, size_t* oCountRead); + virtual size_t Imp_CountReadable(); + virtual bool Imp_WaitReadable(double iTimeout); + + virtual void Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped); + +private: + void pInit(uint32& oChunkType, bool iSkipOnDestroy); + + const ZStreamR& fStream; + bool fSkipOnDestroy; + size_t fCountRemaining; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamRPos_Chunk + +class StreamRPos_Chunk : public ZStreamRPos + { +public: + StreamRPos_Chunk(uint32& oChunkType, const ZStreamRPos& iStream); + StreamRPos_Chunk(uint32& oChunkType, bool iSkipOnDestroy, const ZStreamRPos& iStream); + ~StreamRPos_Chunk(); + +// From ZStreamR via ZStreamRPos + virtual void Imp_Read(void* oDest, size_t iCount, size_t* oCountRead); + + virtual void Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped); + +// From ZStreamR via ZStreamRPos + virtual uint64 Imp_GetPosition(); + virtual void Imp_SetPosition(uint64 iPosition); + + virtual uint64 Imp_GetSize(); + +private: + void pInit(uint32& oChunkType, bool iSkipOnDestroy); + + const ZStreamRPos& fStream; + bool fSkipOnDestroy; + uint64 fStart; + size_t fSize; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * StreamWPos_Chunk + +class StreamWPos_Chunk : public ZStreamWPos + { +public: + StreamWPos_Chunk(uint32 iChunkType, const ZStreamWPos& iStream); + ~StreamWPos_Chunk(); + +// From ZStreamW via ZStreamWPos + virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten); + + virtual void Imp_CopyFromDispatch(const ZStreamR& iStreamR, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_CopyFrom(const ZStreamR& iStreamR, uint64 iCount, + uint64* oCountRead, uint64* oCountWritten); + + virtual void Imp_Flush(); + +// From ZStreamWPos + virtual uint64 Imp_GetPosition(); + virtual void Imp_SetPosition(uint64 iPosition); + + virtual uint64 Imp_GetSize(); + virtual void Imp_SetSize(uint64 iSize); + +private: + const ZStreamWPos& fStream; + uint64 fStart; + }; + +} // namespace QuickTime +} // namespace FileFormat +} // namespace ZooLib + +#endif // __ZFileFormat_QuickTime__ Deleted: trunk/zoolib/source/cxx/zoolib/ZFileFormat_AppleDouble.cpp =====================================================... [truncated message content] |
From: <ag...@us...> - 2010-10-25 22:18:16
|
Revision: 1700 http://zoolib.svn.sourceforge.net/zoolib/?rev=1700&view=rev Author: agreen Date: 2010-10-25 22:18:09 +0000 (Mon, 25 Oct 2010) Log Message: ----------- Rename files. Added Paths: ----------- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_DoMakeWalker_Any.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_DoMakeWalker_Any.h trunk/zoolib/source/cxx/zoolib/ZObserver.mm Removed Paths: ------------- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Any.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Any.h trunk/zoolib/source/cxx/zoolib/ZObserver.cpp Added: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_DoMakeWalker_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_DoMakeWalker_Any.cpp (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_DoMakeWalker_Any.cpp 2010-10-25 22:18:09 UTC (rev 1700) @@ -0,0 +1,66 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/zqe/ZQE_Visitor_DoMakeWalker_Any.h" +#include "zoolib/zqe/ZQE_Walker_Product.h" +#include "zoolib/zqe/ZQE_Walker_Select.h" + +namespace ZooLib { +namespace ZQE { + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_DoMakeWalker_Any + +void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Difference(ZRef<ZRA::Expr_Rel_Difference> iExpr) + { ZUnimplemented(); } + +void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Intersect(ZRef<ZRA::Expr_Rel_Intersect> iExpr) + { ZUnimplemented(); } + +void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Product(ZRef<ZRA::Expr_Rel_Product> iExpr) + { + if (ZRef<Walker> op0 = this->Do(iExpr->GetOp0())) + { + if (ZRef<Walker> op1 = this->Do(iExpr->GetOp1())) + this->pSetResult(new Walker_Product(op0, op1)); + } + } + +void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Union(ZRef<ZRA::Expr_Rel_Union> iExpr) + { ZUnimplemented(); } + +void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Project(ZRef<ZRA::Expr_Rel_Project> iExpr) + { ZUnimplemented(); } + +void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Rename(ZRef<ZRA::Expr_Rel_Rename> iExpr) + { ZUnimplemented(); } + +void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Restrict(ZRef<ZRA::Expr_Rel_Restrict> iExpr) + { ZUnimplemented(); } + +void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Select(ZRef<ZRA::Expr_Rel_Select> iExpr) + { + if (ZRef<Walker> theWalker = this->Do(iExpr->GetOp0())) + this->pSetResult(new Walker_Select(theWalker, iExpr->GetExpr_Logic())); + } + +} // namespace ZQE +} // namespace ZooLib Added: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_DoMakeWalker_Any.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_DoMakeWalker_Any.h (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Visitor_DoMakeWalker_Any.h 2010-10-25 22:18:09 UTC (rev 1700) @@ -0,0 +1,71 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZQE_Visitor_DoMakeWalker_Any__ +#define __ZQE_Visitor_DoMakeWalker_Any__ 1 +#include "zconfig.h" + +#include "zoolib/ZVisitor_Do_T.h" + +#include "zoolib/zqe/ZQE_Walker.h" + +#include "zoolib/zra/ZRA_Expr_Rel_Difference.h" +#include "zoolib/zra/ZRA_Expr_Rel_Intersect.h" +#include "zoolib/zra/ZRA_Expr_Rel_Product.h" +#include "zoolib/zra/ZRA_Expr_Rel_Union.h" +#include "zoolib/zra/ZRA_Expr_Rel_Project.h" +#include "zoolib/zra/ZRA_Expr_Rel_Rename.h" +#include "zoolib/zra/ZRA_Expr_Rel_Restrict.h" +#include "zoolib/zra/ZRA_Expr_Rel_Select.h" + +namespace ZooLib { +namespace ZQE { + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_DoMakeWalker_Any + +class Visitor_DoMakeWalker_Any +: public virtual ZVisitor_Do_T<ZRef<Walker> > +, public virtual ZRA::Visitor_Expr_Rel_Difference +, public virtual ZRA::Visitor_Expr_Rel_Intersect +, public virtual ZRA::Visitor_Expr_Rel_Product +, public virtual ZRA::Visitor_Expr_Rel_Union +, public virtual ZRA::Visitor_Expr_Rel_Project +, public virtual ZRA::Visitor_Expr_Rel_Rename +, public virtual ZRA::Visitor_Expr_Rel_Restrict +, public virtual ZRA::Visitor_Expr_Rel_Select + { +public: + virtual void Visit_Expr_Rel_Difference(ZRef<ZRA::Expr_Rel_Difference> iExpr); + virtual void Visit_Expr_Rel_Intersect(ZRef<ZRA::Expr_Rel_Intersect> iExpr); + virtual void Visit_Expr_Rel_Product(ZRef<ZRA::Expr_Rel_Product> iExpr); + virtual void Visit_Expr_Rel_Union(ZRef<ZRA::Expr_Rel_Union> iExpr); + + virtual void Visit_Expr_Rel_Project(ZRef<ZRA::Expr_Rel_Project> iExpr); + virtual void Visit_Expr_Rel_Rename(ZRef<ZRA::Expr_Rel_Rename> iExpr); + virtual void Visit_Expr_Rel_Restrict(ZRef<ZRA::Expr_Rel_Restrict> iExpr); + virtual void Visit_Expr_Rel_Select(ZRef<ZRA::Expr_Rel_Select> iExpr); + }; + +} // namespace ZQE +} // namespace ZooLib + +#endif // __ZQE_Visitor_DoMakeWalker_Any__ Deleted: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Any.cpp 2010-10-25 22:16:09 UTC (rev 1699) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Any.cpp 2010-10-25 22:18:09 UTC (rev 1700) @@ -1,66 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/zqe/ZQE_Walker_Any.h" -#include "zoolib/zqe/ZQE_Walker_Product.h" -#include "zoolib/zqe/ZQE_Walker_Select.h" - -namespace ZooLib { -namespace ZQE { - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_DoMakeWalker_Any - -void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Difference(ZRef<ZRA::Expr_Rel_Difference> iExpr) - { ZUnimplemented(); } - -void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Intersect(ZRef<ZRA::Expr_Rel_Intersect> iExpr) - { ZUnimplemented(); } - -void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Product(ZRef<ZRA::Expr_Rel_Product> iExpr) - { - if (ZRef<Walker> op0 = this->Do(iExpr->GetOp0())) - { - if (ZRef<Walker> op1 = this->Do(iExpr->GetOp1())) - this->pSetResult(new Walker_Product(op0, op1)); - } - } - -void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Union(ZRef<ZRA::Expr_Rel_Union> iExpr) - { ZUnimplemented(); } - -void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Project(ZRef<ZRA::Expr_Rel_Project> iExpr) - { ZUnimplemented(); } - -void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Rename(ZRef<ZRA::Expr_Rel_Rename> iExpr) - { ZUnimplemented(); } - -void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Restrict(ZRef<ZRA::Expr_Rel_Restrict> iExpr) - { ZUnimplemented(); } - -void Visitor_DoMakeWalker_Any::Visit_Expr_Rel_Select(ZRef<ZRA::Expr_Rel_Select> iExpr) - { - if (ZRef<Walker> theWalker = this->Do(iExpr->GetOp0())) - this->pSetResult(new Walker_Select(theWalker, iExpr->GetExpr_Logic())); - } - -} // namespace ZQE -} // namespace ZooLib Deleted: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Any.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Any.h 2010-10-25 22:16:09 UTC (rev 1699) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Any.h 2010-10-25 22:18:09 UTC (rev 1700) @@ -1,71 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZQE_Walker_Any__ -#define __ZQE_Walker_Any__ 1 -#include "zconfig.h" - -#include "zoolib/ZVisitor_Do_T.h" - -#include "zoolib/zqe/ZQE_Walker.h" - -#include "zoolib/zra/ZRA_Expr_Rel_Difference.h" -#include "zoolib/zra/ZRA_Expr_Rel_Intersect.h" -#include "zoolib/zra/ZRA_Expr_Rel_Product.h" -#include "zoolib/zra/ZRA_Expr_Rel_Union.h" -#include "zoolib/zra/ZRA_Expr_Rel_Project.h" -#include "zoolib/zra/ZRA_Expr_Rel_Rename.h" -#include "zoolib/zra/ZRA_Expr_Rel_Restrict.h" -#include "zoolib/zra/ZRA_Expr_Rel_Select.h" - -namespace ZooLib { -namespace ZQE { - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_DoMakeWalker_Any - -class Visitor_DoMakeWalker_Any -: public virtual ZVisitor_Do_T<ZRef<Walker> > -, public virtual ZRA::Visitor_Expr_Rel_Difference -, public virtual ZRA::Visitor_Expr_Rel_Intersect -, public virtual ZRA::Visitor_Expr_Rel_Product -, public virtual ZRA::Visitor_Expr_Rel_Union -, public virtual ZRA::Visitor_Expr_Rel_Project -, public virtual ZRA::Visitor_Expr_Rel_Rename -, public virtual ZRA::Visitor_Expr_Rel_Restrict -, public virtual ZRA::Visitor_Expr_Rel_Select - { -public: - virtual void Visit_Expr_Rel_Difference(ZRef<ZRA::Expr_Rel_Difference> iExpr); - virtual void Visit_Expr_Rel_Intersect(ZRef<ZRA::Expr_Rel_Intersect> iExpr); - virtual void Visit_Expr_Rel_Product(ZRef<ZRA::Expr_Rel_Product> iExpr); - virtual void Visit_Expr_Rel_Union(ZRef<ZRA::Expr_Rel_Union> iExpr); - - virtual void Visit_Expr_Rel_Project(ZRef<ZRA::Expr_Rel_Project> iExpr); - virtual void Visit_Expr_Rel_Rename(ZRef<ZRA::Expr_Rel_Rename> iExpr); - virtual void Visit_Expr_Rel_Restrict(ZRef<ZRA::Expr_Rel_Restrict> iExpr); - virtual void Visit_Expr_Rel_Select(ZRef<ZRA::Expr_Rel_Select> iExpr); - }; - -} // namespace ZQE -} // namespace ZooLib - -#endif // __ZQE_Walker_Any__ Deleted: trunk/zoolib/source/cxx/zoolib/ZObserver.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZObserver.cpp 2010-10-25 22:16:09 UTC (rev 1699) +++ trunk/zoolib/source/cxx/zoolib/ZObserver.cpp 2010-10-25 22:18:09 UTC (rev 1700) @@ -1,77 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZObserver.h" - -#if ZCONFIG_SPI_Enabled(CoreFoundation) - -#include "zoolib/ZUtil_CFType.h" - -namespace ZooLib { - -// ================================================================================================= -#pragma mark - -#pragma mark * ZObserver - -ZObserver::ZObserver(void* iObject, const std::string& iName, ZRef<Callable> iCallable) -: fObject(iObject) -, fName(iName) -, fCallable(iCallable) - {} - -ZObserver::~ZObserver() - {} - -void ZObserver::Initialize() - { - ZCounted::Initialize(); - - ::CFNotificationCenterAddObserver( - ::CFNotificationCenterGetLocalCenter(), - this, - spCallback, - ZUtil_CFType::sString(fName), - fObject, - CFNotificationSuspensionBehaviorDeliverImmediately); - } - -void ZObserver::Finalize() - { - ::CFNotificationCenterRemoveEveryObserver(::CFNotificationCenterGetLocalCenter(), this); - - ZCounted::Finalize(); - } - -void* ZObserver::GetObject() - { return fObject; } - -std::string ZObserver::GetName() - { return fName; } - -void ZObserver::spCallback(CFNotificationCenterRef center, - void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) - { - ZRef<ZObserver> theObserver = static_cast<ZObserver*>(observer); - theObserver->fCallable->Call(theObserver, userInfo); - } - -} // namespace ZooLib - -#endif // ZCONFIG_SPI_Enabled(CoreFoundation) Added: trunk/zoolib/source/cxx/zoolib/ZObserver.mm =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZObserver.mm (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZObserver.mm 2010-10-25 22:18:09 UTC (rev 1700) @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZObserver.h" + +#if ZCONFIG_SPI_Enabled(CoreFoundation) + +#include "zoolib/ZUtil_CFType.h" + +namespace ZooLib { + +// ================================================================================================= +#pragma mark - +#pragma mark * ZObserver + +ZObserver::ZObserver(void* iObject, const std::string& iName, ZRef<Callable> iCallable) +: fObject(iObject) +, fName_String(iName) +, fCallable(iCallable) + {} + +ZObserver::ZObserver(void* iObject, CFStringRef iName, ZRef<Callable> iCallable) +: fObject(iObject) +, fName_CFStringRef(iName) +, fCallable(iCallable) + {} + +ZObserver::ZObserver(void* iObject, NSString* iName, ZRef<Callable> iCallable) +: fObject(iObject) +, fName_CFStringRef((CFStringRef)iName) +, fCallable(iCallable) + {} + +ZObserver::~ZObserver() + {} + +void ZObserver::Initialize() + { + ZCounted::Initialize(); + + if (!fName_CFStringRef) + fName_CFStringRef = ZUtil_CFType::sString(fName_String.Get()); + + ::CFNotificationCenterAddObserver( + ::CFNotificationCenterGetLocalCenter(), + this, + spCallback, + fName_CFStringRef.Get(), + fObject, + CFNotificationSuspensionBehaviorDeliverImmediately); + } + +void ZObserver::Finalize() + { + ::CFNotificationCenterRemoveEveryObserver(::CFNotificationCenterGetLocalCenter(), this); + + ZCounted::Finalize(); + } + +void* ZObserver::GetObject() + { return fObject; } + +std::string ZObserver::GetName() + { + if (!fName_String) + fName_String = ZUtil_CFType::sAsUTF8(fName_CFStringRef.Get()); + return fName_String.Get(); + } + +CFStringRef ZObserver::GetName_CFStringRef() + { + if (!fName_CFStringRef) + fName_CFStringRef = ZUtil_CFType::sString(fName_String.Get()); + return fName_CFStringRef.Get(); + } + +NSString* ZObserver::GetName_NSString() + { return (NSString*)this->GetName_CFStringRef(); } + +void ZObserver::spCallback(CFNotificationCenterRef center, + void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) + { + ZRef<ZObserver> theObserver = static_cast<ZObserver*>(observer); + theObserver->fCallable->Call(theObserver, userInfo); + } + +} // namespace ZooLib + +#endif // ZCONFIG_SPI_Enabled(CoreFoundation) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2010-12-24 23:57:41
|
Revision: 1815 http://zoolib.svn.sourceforge.net/zoolib/?rev=1815&view=rev Author: agreen Date: 2010-12-24 23:57:34 +0000 (Fri, 24 Dec 2010) Log Message: ----------- Rename to fit with other "Do" classes. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Compare_Rel.cpp Added Paths: ----------- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.cpp trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.cpp trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_Compare.cpp trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_Compare.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.cpp trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.h Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Compare_Rel.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Compare_Rel.cpp 2010-12-24 23:29:03 UTC (rev 1814) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Compare_Rel.cpp 2010-12-24 23:57:34 UTC (rev 1815) @@ -19,7 +19,7 @@ ------------------------------------------------------------------------------------------------- */ #include "zoolib/ZVisitor_Do_T.h" -#include "zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.h" +#include "zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.h" #include "zoolib/zra/ZRA_Compare_Rel.h" #include "zoolib/zra/ZRA_Expr_Rel_Calc.h" #include "zoolib/zra/ZRA_Expr_Rel_Concrete.h" @@ -257,7 +257,7 @@ Comparer_Select(ZRef<Expr_Rel_Select> iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Select(ZRef<Expr_Rel_Select> iExpr) { - if (int compare = Visitor_Expr_Bool_ValPred_Any_Compare::Comparer_Bootstrap() + if (int compare = Visitor_Expr_Bool_ValPred_Any_DoCompare::Comparer_Bootstrap() .Compare(fExpr->GetExpr_Bool(), iExpr->GetExpr_Bool())) { pSetResult(compare); Deleted: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_Compare.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_Compare.cpp 2010-12-24 23:29:03 UTC (rev 1814) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_Compare.cpp 2010-12-24 23:57:34 UTC (rev 1815) @@ -1,156 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZSetRestore_T.h" -#include "zoolib/ZVisitor_Expr_Bool_Compare.h" - -namespace ZooLib { -namespace Visitor_Expr_Bool_Compare { - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_Compare::Comparer_Bootstrap - -Comparer_Bootstrap::Comparer_Bootstrap() - {} - -int Comparer_Bootstrap::Compare(ZRef<ZExpr_Bool> iLHS, ZRef<ZExpr_Bool> iRHS) - { - ZSetRestore_T<ZRef<ZExpr_Bool> > sr(fExpr, iLHS); - return this->Do(iRHS); - } - -void Comparer_Bootstrap::Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>) - { pSetResult(Comparer_True(this).Do(fExpr)); } - -void Comparer_Bootstrap::Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>) - { pSetResult(Comparer_False(this).Do(fExpr)); } - -void Comparer_Bootstrap::Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not> iExpr) - { pSetResult(Comparer_Not(this, iExpr).Do(fExpr)); } - -void Comparer_Bootstrap::Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And> iExpr) - { pSetResult(Comparer_And(this, iExpr).Do(fExpr)); } - -void Comparer_Bootstrap::Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or> iExpr) - { pSetResult(Comparer_Or(this, iExpr).Do(fExpr)); } - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_Compare::Comparer_Bootstrap - -Comparer::Comparer() -: fBootstrap(nullptr) - { ZUnimplemented(); } - -Comparer::Comparer(Comparer_Bootstrap* iBootstrap) -: fBootstrap(iBootstrap) - {} - -void Comparer::Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>) - { pSetResult(-1); } - -void Comparer::Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>) - { pSetResult(-1); } - -void Comparer::Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not>) - { pSetResult(-1); } - -void Comparer::Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And>) - { pSetResult(-1); } - -void Comparer::Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or>) - { pSetResult(-1); } - -int Comparer::CompareUnary( - ZRef<ZExpr_Op1_T<ZExpr_Bool> > iLHS, ZRef<ZExpr_Op1_T<ZExpr_Bool> > iRHS) - { return fBootstrap->Compare(iLHS->GetOp0(), iRHS->GetOp0()); } - -int Comparer::CompareBinary( - ZRef<ZExpr_Op2_T<ZExpr_Bool> > iLHS, ZRef<ZExpr_Op2_T<ZExpr_Bool> > iRHS) - { - if (int compare = fBootstrap->Compare(iLHS->GetOp0(), iRHS->GetOp0())) - return compare; - return fBootstrap->Compare(iLHS->GetOp1(), iRHS->GetOp1()); - } - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_Compare::Comparer_GT_XXX - -void Comparer_GT_True::Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>) - { pSetResult(1); } - -void Comparer_GT_False::Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>) - { pSetResult(1); } - -void Comparer_GT_Not::Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not>) - { pSetResult(1); } - -void Comparer_GT_And::Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And>) - { pSetResult(1); } - -void Comparer_GT_Or::Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or>) - { pSetResult(1); } - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_Compare::Comparer_XXX - -Comparer_True::Comparer_True(Comparer_Bootstrap* iBootstrap) -: Comparer(iBootstrap) - {} - -void Comparer_True::Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>) - { pSetResult(0); } - -Comparer_False::Comparer_False(Comparer_Bootstrap* iBootstrap) -: Comparer(iBootstrap) - {} - -void Comparer_False::Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>) - { pSetResult(0); } - -Comparer_Not::Comparer_Not(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Not> iExpr) -: Comparer(iBootstrap) -, fExpr(iExpr) - {} - -void Comparer_Not::Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not> iExpr) - { pSetResult(CompareUnary(fExpr, iExpr)); } - -Comparer_And::Comparer_And(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_And> iExpr) -: Comparer(iBootstrap) -, fExpr(iExpr) - {} - -void Comparer_And::Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And> iExpr) - { pSetResult(CompareBinary(fExpr, iExpr)); } - -Comparer_Or::Comparer_Or(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Or> iExpr) -: Comparer(iBootstrap) -, fExpr(iExpr) - {} - -void Comparer_Or::Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or> iExpr) - { pSetResult(CompareBinary(fExpr, iExpr)); } - -} // namespace Visitor_Expr_Bool_Compare -} // namespace ZooLib Deleted: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_Compare.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_Compare.h 2010-12-24 23:29:03 UTC (rev 1814) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_Compare.h 2010-12-24 23:57:34 UTC (rev 1815) @@ -1,146 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZVisitor_Expr_Bool_Compare__ -#define __ZVisitor_Expr_Bool_Compare__ 1 -#include "zconfig.h" - -#include "zoolib/ZCompare_T.h" -#include "zoolib/ZExpr_Bool.h" -#include "zoolib/ZVisitor_Do_T.h" - -namespace ZooLib { -namespace Visitor_Expr_Bool_Compare { - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_Compare::Comparer_Bootstrap - -struct Comparer_Bootstrap -: public virtual ZVisitor_Do_T<int> -, public virtual ZVisitor_Expr_Bool_True -, public virtual ZVisitor_Expr_Bool_False -, public virtual ZVisitor_Expr_Bool_Not -, public virtual ZVisitor_Expr_Bool_And -, public virtual ZVisitor_Expr_Bool_Or - { -protected: - ZRef<ZExpr_Bool> fExpr; - -public: - Comparer_Bootstrap(); - - int Compare(ZRef<ZExpr_Bool> iLHS, ZRef<ZExpr_Bool> iRHS); - - virtual void Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>); - virtual void Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>); - virtual void Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not> iExpr); - virtual void Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And> iExpr); - virtual void Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or> iExpr); - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_Compare::Comparer - -struct Comparer -: public virtual ZVisitor_Do_T<int> -, public virtual ZVisitor_Expr_Bool_True -, public virtual ZVisitor_Expr_Bool_False -, public virtual ZVisitor_Expr_Bool_Not -, public virtual ZVisitor_Expr_Bool_And -, public virtual ZVisitor_Expr_Bool_Or - { - Comparer_Bootstrap* fBootstrap; - - Comparer(); - Comparer(Comparer_Bootstrap* iBootstrap); - -// From ZVisitor_Expr_Bool_XXX - virtual void Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>); - virtual void Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>); - virtual void Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not>); - virtual void Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And>); - virtual void Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or>); - - int CompareUnary(ZRef<ZExpr_Op1_T<ZExpr_Bool> > iLHS, ZRef<ZExpr_Op1_T<ZExpr_Bool> > iRHS); - int CompareBinary(ZRef<ZExpr_Op2_T<ZExpr_Bool> > iLHS, ZRef<ZExpr_Op2_T<ZExpr_Bool> > iRHS); - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_Compare::Comparer_GT_XXX - -struct Comparer_GT_True : public virtual Comparer - { virtual void Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>); }; - -struct Comparer_GT_False : public virtual Comparer_GT_True - { virtual void Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>); }; - -struct Comparer_GT_Not : public virtual Comparer_GT_False - { virtual void Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not>); }; - -struct Comparer_GT_And : public virtual Comparer_GT_Not - { virtual void Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And>); }; - -struct Comparer_GT_Or : public virtual Comparer_GT_And - { virtual void Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or>); }; - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_Compare::Comparer_XXX - -struct Comparer_True : public virtual Comparer - { - Comparer_True(Comparer_Bootstrap* iBootstrap); - virtual void Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>); - }; - -struct Comparer_False : public virtual Comparer_GT_True - { - Comparer_False(Comparer_Bootstrap* iBootstrap); - virtual void Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>); - }; - -struct Comparer_Not : public virtual Comparer_GT_False - { - ZRef<ZExpr_Bool_Not> fExpr; - Comparer_Not(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Not> iExpr); - virtual void Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not> iExpr); - }; - -struct Comparer_And : public virtual Comparer_GT_Not - { - ZRef<ZExpr_Bool_And> fExpr; - Comparer_And(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_And> iExpr); - virtual void Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And> iExpr); - }; - -struct Comparer_Or : public virtual Comparer_GT_And - { - ZRef<ZExpr_Bool_Or> fExpr; - Comparer_Or(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Or> iExpr); - virtual void Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or> iExpr); - }; - -} // namespace Visitor_Expr_Bool_Compare -} // namespace ZooLib - -#endif // __ZVisitor_Expr_Bool_Compare__ Added: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.cpp (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.cpp 2010-12-24 23:57:34 UTC (rev 1815) @@ -0,0 +1,156 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZSetRestore_T.h" +#include "zoolib/ZVisitor_Expr_Bool_DoCompare.h" + +namespace ZooLib { +namespace Visitor_Expr_Bool_DoCompare { + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap + +Comparer_Bootstrap::Comparer_Bootstrap() + {} + +int Comparer_Bootstrap::Compare(ZRef<ZExpr_Bool> iLHS, ZRef<ZExpr_Bool> iRHS) + { + ZSetRestore_T<ZRef<ZExpr_Bool> > sr(fExpr, iLHS); + return this->Do(iRHS); + } + +void Comparer_Bootstrap::Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>) + { pSetResult(Comparer_True(this).Do(fExpr)); } + +void Comparer_Bootstrap::Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>) + { pSetResult(Comparer_False(this).Do(fExpr)); } + +void Comparer_Bootstrap::Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not> iExpr) + { pSetResult(Comparer_Not(this, iExpr).Do(fExpr)); } + +void Comparer_Bootstrap::Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And> iExpr) + { pSetResult(Comparer_And(this, iExpr).Do(fExpr)); } + +void Comparer_Bootstrap::Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or> iExpr) + { pSetResult(Comparer_Or(this, iExpr).Do(fExpr)); } + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap + +Comparer::Comparer() +: fBootstrap(nullptr) + { ZUnimplemented(); } + +Comparer::Comparer(Comparer_Bootstrap* iBootstrap) +: fBootstrap(iBootstrap) + {} + +void Comparer::Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>) + { pSetResult(-1); } + +void Comparer::Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>) + { pSetResult(-1); } + +void Comparer::Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not>) + { pSetResult(-1); } + +void Comparer::Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And>) + { pSetResult(-1); } + +void Comparer::Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or>) + { pSetResult(-1); } + +int Comparer::CompareUnary( + ZRef<ZExpr_Op1_T<ZExpr_Bool> > iLHS, ZRef<ZExpr_Op1_T<ZExpr_Bool> > iRHS) + { return fBootstrap->Compare(iLHS->GetOp0(), iRHS->GetOp0()); } + +int Comparer::CompareBinary( + ZRef<ZExpr_Op2_T<ZExpr_Bool> > iLHS, ZRef<ZExpr_Op2_T<ZExpr_Bool> > iRHS) + { + if (int compare = fBootstrap->Compare(iLHS->GetOp0(), iRHS->GetOp0())) + return compare; + return fBootstrap->Compare(iLHS->GetOp1(), iRHS->GetOp1()); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_DoCompare::Comparer_GT_XXX + +void Comparer_GT_True::Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>) + { pSetResult(1); } + +void Comparer_GT_False::Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>) + { pSetResult(1); } + +void Comparer_GT_Not::Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not>) + { pSetResult(1); } + +void Comparer_GT_And::Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And>) + { pSetResult(1); } + +void Comparer_GT_Or::Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or>) + { pSetResult(1); } + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_DoCompare::Comparer_XXX + +Comparer_True::Comparer_True(Comparer_Bootstrap* iBootstrap) +: Comparer(iBootstrap) + {} + +void Comparer_True::Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>) + { pSetResult(0); } + +Comparer_False::Comparer_False(Comparer_Bootstrap* iBootstrap) +: Comparer(iBootstrap) + {} + +void Comparer_False::Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>) + { pSetResult(0); } + +Comparer_Not::Comparer_Not(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Not> iExpr) +: Comparer(iBootstrap) +, fExpr(iExpr) + {} + +void Comparer_Not::Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not> iExpr) + { pSetResult(CompareUnary(fExpr, iExpr)); } + +Comparer_And::Comparer_And(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_And> iExpr) +: Comparer(iBootstrap) +, fExpr(iExpr) + {} + +void Comparer_And::Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And> iExpr) + { pSetResult(CompareBinary(fExpr, iExpr)); } + +Comparer_Or::Comparer_Or(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Or> iExpr) +: Comparer(iBootstrap) +, fExpr(iExpr) + {} + +void Comparer_Or::Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or> iExpr) + { pSetResult(CompareBinary(fExpr, iExpr)); } + +} // namespace Visitor_Expr_Bool_DoCompare +} // namespace ZooLib Added: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.h (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.h 2010-12-24 23:57:34 UTC (rev 1815) @@ -0,0 +1,159 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZVisitor_Expr_Bool_DoCompare__ +#define __ZVisitor_Expr_Bool_DoCompare__ 1 +#include "zconfig.h" + +#include "zoolib/ZCompare_T.h" +#include "zoolib/ZExpr_Bool.h" +#include "zoolib/ZVisitor_Do_T.h" + +namespace ZooLib { +namespace Visitor_Expr_Bool_DoCompare { + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap + +struct Comparer_Bootstrap +: public virtual ZVisitor_Do_T<int> +, public virtual ZVisitor_Expr_Bool_True +, public virtual ZVisitor_Expr_Bool_False +, public virtual ZVisitor_Expr_Bool_Not +, public virtual ZVisitor_Expr_Bool_And +, public virtual ZVisitor_Expr_Bool_Or + { +protected: + ZRef<ZExpr_Bool> fExpr; + +public: + Comparer_Bootstrap(); + + int Compare(ZRef<ZExpr_Bool> iLHS, ZRef<ZExpr_Bool> iRHS); + + virtual void Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>); + virtual void Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>); + virtual void Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not> iExpr); + virtual void Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And> iExpr); + virtual void Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or> iExpr); + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_DoCompare::Comparer + +class Comparer +: public virtual ZVisitor_Do_T<int> +, public virtual ZVisitor_Expr_Bool_True +, public virtual ZVisitor_Expr_Bool_False +, public virtual ZVisitor_Expr_Bool_Not +, public virtual ZVisitor_Expr_Bool_And +, public virtual ZVisitor_Expr_Bool_Or + { +public: + Comparer(); + Comparer(Comparer_Bootstrap* iBootstrap); + +// From ZVisitor_Expr_Bool_XXX + virtual void Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>); + virtual void Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>); + virtual void Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not>); + virtual void Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And>); + virtual void Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or>); + + int CompareUnary(ZRef<ZExpr_Op1_T<ZExpr_Bool> > iLHS, ZRef<ZExpr_Op1_T<ZExpr_Bool> > iRHS); + int CompareBinary(ZRef<ZExpr_Op2_T<ZExpr_Bool> > iLHS, ZRef<ZExpr_Op2_T<ZExpr_Bool> > iRHS); + +private: + Comparer_Bootstrap* fBootstrap; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_DoCompare::Comparer_GT_XXX + +struct Comparer_GT_True : public virtual Comparer + { virtual void Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>); }; + +struct Comparer_GT_False : public virtual Comparer_GT_True + { virtual void Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>); }; + +struct Comparer_GT_Not : public virtual Comparer_GT_False + { virtual void Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not>); }; + +struct Comparer_GT_And : public virtual Comparer_GT_Not + { virtual void Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And>); }; + +struct Comparer_GT_Or : public virtual Comparer_GT_And + { virtual void Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or>); }; + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_DoCompare::Comparer_XXX + +class Comparer_True : public virtual Comparer + { +public: + Comparer_True(Comparer_Bootstrap* iBootstrap); + virtual void Visit_Expr_Bool_True(ZRef<ZExpr_Bool_True>); + }; + +class Comparer_False : public virtual Comparer_GT_True + { +public: + Comparer_False(Comparer_Bootstrap* iBootstrap); + virtual void Visit_Expr_Bool_False(ZRef<ZExpr_Bool_False>); + }; + +class Comparer_Not : public virtual Comparer_GT_False + { +public: + Comparer_Not(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Not> iExpr); + virtual void Visit_Expr_Bool_Not(ZRef<ZExpr_Bool_Not> iExpr); + +private: + ZRef<ZExpr_Bool_Not> fExpr; + }; + +class Comparer_And : public virtual Comparer_GT_Not + { +public: + Comparer_And(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_And> iExpr); + virtual void Visit_Expr_Bool_And(ZRef<ZExpr_Bool_And> iExpr); + +private: + ZRef<ZExpr_Bool_And> fExpr; + }; + +class Comparer_Or : public virtual Comparer_GT_And + { +public: + Comparer_Or(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Or> iExpr); + virtual void Visit_Expr_Bool_Or(ZRef<ZExpr_Bool_Or> iExpr); + +private: + ZRef<ZExpr_Bool_Or> fExpr; + }; + +} // namespace Visitor_Expr_Bool_DoCompare +} // namespace ZooLib + +#endif // __ZVisitor_Expr_Bool_DoCompare__ Deleted: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.cpp 2010-12-24 23:29:03 UTC (rev 1814) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.cpp 2010-12-24 23:57:34 UTC (rev 1815) @@ -1,61 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.h" - -namespace ZooLib { -namespace Visitor_Expr_Bool_ValPred_Any_Compare { - -// ================================================================================================= -#pragma mark - -#pragma mark * ZVisitor_Expr_Bool_ValPred_Any_Compare - -void Comparer_Bootstrap::Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iExpr) - { pSetResult(Comparer_ValPred(this, iExpr).Do(fExpr)); } - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_ValPred_Any_Compare::Comparer - -void Comparer::Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iRep) - { pSetResult(-1); } - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_ValPred_Any_Compare::Comparer_GT_ValPred - -void Comparer_GT_ValPred::Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any>) - { pSetResult(1); } - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_ValPred_Any_Compare::Comparer_ValPred - -Comparer_ValPred::Comparer_ValPred( - Visitor_Expr_Bool_Compare::Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_ValPred_Any> iExpr) -: Comparer(iBootstrap) -, fExpr(iExpr) - {} - -void Comparer_ValPred::Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iExpr) - { pSetResult(sCompare_T(fExpr->GetValPred(), iExpr->GetValPred())); } - -} // namespace Visitor_Expr_Bool_ValPred_Any_Compare -} // namespace ZooLib Deleted: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.h 2010-12-24 23:29:03 UTC (rev 1814) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_Compare.h 2010-12-24 23:57:34 UTC (rev 1815) @@ -1,83 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2010 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZVisitor_Expr_Bool_ValPred_Any_Compare__ -#define __ZVisitor_Expr_Bool_ValPred_Any_Compare__ 1 -#include "zconfig.h" - -#include "zoolib/ZExpr_Bool_ValPred_Any.h" -#include "zoolib/ZVisitor_Expr_Bool_Compare.h" - -namespace ZooLib { -namespace Visitor_Expr_Bool_ValPred_Any_Compare { - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_ValPred_Any_Compare::Comparer_Bootstrap - -struct Comparer_Bootstrap -: public virtual Visitor_Expr_Bool_Compare::Comparer_Bootstrap -, public virtual ZVisitor_Expr_Bool_ValPred_T<ZVal_Any> - { -public: - virtual void Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iExpr); - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_ValPred_Any_Compare::Comparer - -struct Comparer -: public virtual Visitor_Expr_Bool_Compare::Comparer -, public virtual ZVisitor_Expr_Bool_ValPred_T<ZVal_Any> - { - virtual void Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iRep); - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_ValPred_Any_Compare::Comparer_GT_ValPred - -struct Comparer_GT_ValPred -: public virtual Visitor_Expr_Bool_Compare::Comparer_GT_Or -, public virtual ZVisitor_Expr_Bool_ValPred_T<ZVal_Any> - { - virtual void Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any>); - }; - -// ================================================================================================= -#pragma mark - -#pragma mark * Visitor_Expr_Bool_ValPred_Any_Compare::Comparer_ValPred - -struct Comparer_ValPred -: public virtual Visitor_Expr_Bool_Compare::Comparer_GT_Or -, public virtual ZVisitor_Expr_Bool_ValPred_T<ZVal_Any> - { - ZRef<ZExpr_Bool_ValPred_Any> fExpr; - Comparer_ValPred(Visitor_Expr_Bool_Compare::Comparer_Bootstrap* iBootstrap, - ZRef<ZExpr_Bool_ValPred_Any> iExpr); - - virtual void Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iExpr); - }; - -} // namespace Visitor_Expr_Bool_ValPred_Any_Compare -} // namespace ZooLib - -#endif // __ZVisitor_Expr_Bool_ValPred_Any_Compare__ Added: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.cpp (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.cpp 2010-12-24 23:57:34 UTC (rev 1815) @@ -0,0 +1,61 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.h" + +namespace ZooLib { +namespace Visitor_Expr_Bool_ValPred_Any_DoCompare { + +// ================================================================================================= +#pragma mark - +#pragma mark * ZVisitor_Expr_Bool_ValPred_Any_DoCompare + +void Comparer_Bootstrap::Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iExpr) + { pSetResult(Comparer_ValPred(this, iExpr).Do(fExpr)); } + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_ValPred_Any_DoCompare::Comparer + +void Comparer::Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iRep) + { pSetResult(-1); } + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_ValPred_Any_DoCompare::Comparer_GT_ValPred + +void Comparer_GT_ValPred::Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any>) + { pSetResult(1); } + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_ValPred_Any_DoCompare::Comparer_ValPred + +Comparer_ValPred::Comparer_ValPred( + Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_ValPred_Any> iExpr) +: Comparer(iBootstrap) +, fExpr(iExpr) + {} + +void Comparer_ValPred::Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iExpr) + { pSetResult(sCompare_T(fExpr->GetValPred(), iExpr->GetValPred())); } + +} // namespace Visitor_Expr_Bool_ValPred_Any_DoCompare +} // namespace ZooLib Added: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.h (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoCompare.h 2010-12-24 23:57:34 UTC (rev 1815) @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZVisitor_Expr_Bool_ValPred_Any_DoCompare__ +#define __ZVisitor_Expr_Bool_ValPred_Any_DoCompare__ 1 +#include "zconfig.h" + +#include "zoolib/ZExpr_Bool_ValPred_Any.h" +#include "zoolib/ZVisitor_Expr_Bool_DoCompare.h" + +namespace ZooLib { +namespace Visitor_Expr_Bool_ValPred_Any_DoCompare { + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_ValPred_Any_DoCompare::Comparer_Bootstrap + +struct Comparer_Bootstrap +: public virtual Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap +, public virtual ZVisitor_Expr_Bool_ValPred_T<ZVal_Any> + { +public: + virtual void Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iExpr); + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_ValPred_Any_DoCompare::Comparer + +struct Comparer +: public virtual Visitor_Expr_Bool_DoCompare::Comparer +, public virtual ZVisitor_Expr_Bool_ValPred_T<ZVal_Any> + { + virtual void Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iRep); + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_ValPred_Any_DoCompare::Comparer_GT_ValPred + +struct Comparer_GT_ValPred +: public virtual Visitor_Expr_Bool_DoCompare::Comparer_GT_Or +, public virtual ZVisitor_Expr_Bool_ValPred_T<ZVal_Any> + { + virtual void Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any>); + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * Visitor_Expr_Bool_ValPred_Any_DoCompare::Comparer_ValPred + +class Comparer_ValPred +: public virtual Visitor_Expr_Bool_DoCompare::Comparer_GT_Or +, public virtual ZVisitor_Expr_Bool_ValPred_T<ZVal_Any> + { +public: + Comparer_ValPred(Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap* iBootstrap, + ZRef<ZExpr_Bool_ValPred_Any> iExpr); + + virtual void Visit_Expr_Bool_ValPred(ZRef<ZExpr_Bool_ValPred_Any> iExpr); + +private: + ZRef<ZExpr_Bool_ValPred_Any> fExpr; + }; + +} // namespace Visitor_Expr_Bool_ValPred_Any_DoCompare +} // namespace ZooLib + +#endif // __ZVisitor_Expr_Bool_ValPred_Any_DoCompare__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2010-12-29 16:30:00
|
Revision: 1835 http://zoolib.svn.sourceforge.net/zoolib/?rev=1835&view=rev Author: agreen Date: 2010-12-29 16:29:53 +0000 (Wed, 29 Dec 2010) Log Message: ----------- As we're not basing ZAny on boost::any (we need voidstar) I've reorganized and simplified it. Separate ZAny coercion functions into own file. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp trunk/zoolib/source/cxx/zoolib/ZAny.cpp trunk/zoolib/source/cxx/zoolib/ZAny.h trunk/zoolib/source/cxx/zoolib/ZVal_Any.h Added Paths: ----------- trunk/zoolib/source/cxx/zoolib/ZUtil_Any.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp 2010-12-29 03:42:11 UTC (rev 1834) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp 2010-12-29 16:29:53 UTC (rev 1835) @@ -21,6 +21,7 @@ #include "zoolib/ZLog.h" #include "zoolib/ZStrim_Escaped.h" #include "zoolib/ZString.h" +#include "zoolib/ZUtil_Any.h" #include "zoolib/ZUtil_Strim.h" #include "zoolib/ZVisitor_Do_T.h" #include "zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoToStrim.h" Modified: trunk/zoolib/source/cxx/zoolib/ZAny.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZAny.cpp 2010-12-29 03:42:11 UTC (rev 1834) +++ trunk/zoolib/source/cxx/zoolib/ZAny.cpp 2010-12-29 16:29:53 UTC (rev 1835) @@ -19,215 +19,3 @@ ------------------------------------------------------------------------------------------------- */ #include "zoolib/ZAny.h" -#include "zoolib/ZString.h" - -using std::string; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZAnyBase, copied/reworked from boost::any - -namespace ZooLib { - -ZAnyBase::ZAnyBase() -: content(0) - {} - -ZAnyBase::ZAnyBase(const ZAnyBase& other) -: content(other.content ? other.content->clone() : 0) - {} - -ZAnyBase::~ZAnyBase() - { delete content; } - -ZAnyBase& ZAnyBase::operator=(ZAnyBase rhs) - { - rhs.swap(*this); - return *this; - } - -ZAnyBase& ZAnyBase::swap(ZAnyBase& rhs) - { - std::swap(content, rhs.content); - return *this; - } - -bool ZAnyBase::empty() const - { return !content; } - -const std::type_info& ZAnyBase::type() const - { return content ? content->type() : typeid(void); } - -const void* ZAnyBase::voidstar() const - { return content ? content->voidstar() : nullptr; } - -void* ZAnyBase::voidstar() - { return content ? content->voidstar() : nullptr; } - -} // namespace ZooLib - -// ================================================================================================= -#pragma mark - -#pragma mark * ZAny - -namespace ZooLib { - -ZAny::operator operator_bool_type() const - { return operator_bool_generator_type::translate(this->type() != typeid(void)); } - -void ZAny::Clear() - { - ZAny temp; - this->swap(temp); - } - -} // namespace ZooLib - -// ================================================================================================= -#pragma mark - -#pragma mark * Coercion - -namespace ZooLib { - -ZQ<bool> sQCoerceBool(const ZAny& iAny) - { - if (const bool* pBool = iAny.PGet<bool>()) - return *pBool; - - if (ZQ<int64> qInt64 = sQCoerceInt(iAny)) - return (0 != qInt64.Get()); - - if (ZQ<double> qDouble = sQCoerceReal(iAny)) - return (0.0 != qDouble.Get()); - - if (const string* pString = iAny.PGet<string>()) - { - if (pString->empty()) - return false; - - if (ZQ<double> qDouble = ZString::sQDouble(*pString)) - return (0.0 != qDouble.Get()); - - if (ZQ<int64> qInt64 = ZString::sQInt64(*pString)) - return (0 != qInt64.Get()); - - if (ZString::sEquali(*pString, "t") || ZString::sEquali(*pString, "true")) - return true; - - if (ZString::sEquali(*pString, "f") || ZString::sEquali(*pString, "false")) - return false; - } - return null; - } - -bool sQCoerceBool(const ZAny& iAny, bool& oVal) - { - if (ZQ<bool> qBool = sQCoerceBool(iAny)) - { - oVal = qBool.Get(); - return true; - } - return false; - } - -bool sDCoerceBool(bool iDefault, const ZAny& iAny) - { - bool result; - if (sQCoerceBool(iAny, result)) - return result; - return iDefault; - } - -bool sCoerceBool(const ZAny& iAny) - { - bool result; - if (sQCoerceBool(iAny, result)) - return result; - return false; - } - -ZQ<int64> sQCoerceInt(const ZAny& iAny) - { - if (false) - {} - else if (const char* theVal = iAny.PGet<char>()) - return *theVal; - else if (const signed char* theVal = iAny.PGet<signed char>()) - return *theVal; - else if (const unsigned char* theVal = iAny.PGet<unsigned char>()) - return *theVal; - else if (const wchar_t* theVal = iAny.PGet<wchar_t>()) - return *theVal; - else if (const short* theVal = iAny.PGet<short>()) - return *theVal; - else if (const unsigned short* theVal = iAny.PGet<unsigned short>()) - return *theVal; - else if (const int* theVal = iAny.PGet<int>()) - return *theVal; - else if (const unsigned int* theVal = iAny.PGet<unsigned int>()) - return *theVal; - else if (const long* theVal = iAny.PGet<long>()) - return *theVal; - else if (const unsigned long* theVal = iAny.PGet<unsigned long>()) - return *theVal; - else if (const int64* theVal = iAny.PGet<int64>()) - return *theVal; - else if (const uint64* theVal = iAny.PGet<uint64>()) - return *theVal; - - return null; - } - -bool sQCoerceInt(const ZAny& iAny, int64& oVal) - { - if (ZQ<int64> qInt64 = sQCoerceInt(iAny)) - { - oVal = qInt64.Get(); - return true; - } - return false; - } - -int64 sDCoerceInt(int64 iDefault, const ZAny& iAny) - { - if (ZQ<int64> qInt = sQCoerceInt(iAny)) - return qInt.Get(); - return iDefault; - } - -int64 sCoerceInt(const ZAny& iAny) - { return sDCoerceInt(0, iAny); } - -ZQ<double> sQCoerceReal(const ZAny& iAny) - { - if (false) - {} - else if (const float* theVal = iAny.PGet<float>()) - return *theVal; - else if (const double* theVal = iAny.PGet<double>()) - return *theVal; - - return null; - } - -bool sQCoerceReal(const ZAny& iAny, double& oVal) - { - if (ZQ<double> qDouble = sQCoerceReal(iAny)) - { - oVal = qDouble.Get(); - return true; - } - return false; - } - -double sDCoerceReal(double iDefault, const ZAny& iAny) - { - if (ZQ<double> qDouble = sQCoerceReal(iAny)) - return qDouble.Get(); - return iDefault; - } - -double sCoerceReal(const ZAny& iAny) - { return sDCoerceReal(0.0, iAny); } - -} // namespace ZooLib Modified: trunk/zoolib/source/cxx/zoolib/ZAny.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZAny.h 2010-12-29 03:42:11 UTC (rev 1834) +++ trunk/zoolib/source/cxx/zoolib/ZAny.h 2010-12-29 16:29:53 UTC (rev 1835) @@ -21,190 +21,100 @@ #ifndef __ZAny__ #define __ZAny__ #include "zconfig.h" -#include "zoolib/ZCONFIG_SPI.h" -#include "zoolib/ZCompat_algorithm.h" // For swap +#include "zoolib/ZCompat_algorithm.h" // For std::swap #include "zoolib/ZCompat_operator_bool.h" #include "zoolib/ZQ.h" -#include "zoolib/ZStdInt.h" // For int64 #include <typeinfo> // ================================================================================================= #pragma mark - -#pragma mark * ZAnyBase, copied/reworked from boost::any - -// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - #if ZCONFIG(Compiler, CodeWarrior) - #if __MWERKS__ <= 0x3206 - #define BOOST_NO_MEMBER_TEMPLATE_FRIENDS - #endif - #endif -#endif - -namespace ZooLib { - -class ZAnyBase - { -public: - ZAnyBase(); - ZAnyBase(const ZAnyBase& other); - ~ZAnyBase(); - ZAnyBase& operator=(ZAnyBase rhs); - - template<typename ValueType> - ZAnyBase(const ValueType & value) - : content(new holder<ValueType>(value)) - {} - - template<typename ValueType> - ZAnyBase& operator=(const ValueType & rhs) - { - ZAnyBase(rhs).swap(*this); - return *this; - } - - ZAnyBase& swap(ZAnyBase& rhs); - - bool empty() const; - const std::type_info & type() const; - const void* voidstar() const; - void* voidstar(); - -private: - class placeholder - { - public: - virtual ~placeholder() {} - - virtual const std::type_info& type() const = 0; - virtual placeholder* clone() const = 0; - virtual void* voidstar() = 0; - }; - - template<typename ValueType> - class holder : public placeholder - { - public: - holder(const ValueType& value) : held(value) {} - - virtual const std::type_info& type() const - { return typeid(ValueType); } - - virtual placeholder* clone() const - { return new holder(held); } - - virtual void* voidstar() - { return &held; } - - ValueType held; - - private: // intentionally left unimplemented - holder& operator=(const holder&); - }; - -#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - public: // so ZAnyBaseCast can be non-friend -#else - private: - template<typename ValueType> - friend ValueType* ZAnyBaseCast(ZAnyBase*); - - template<typename ValueType> - friend const ValueType* ZAnyBaseCast(const ZAnyBase*); -#endif - - placeholder* content; - }; - -template<typename ValueType> -ValueType* ZAnyBaseCast(ZAnyBase* operand) - { - if (!operand || operand->type() != typeid(ValueType)) - return 0; - return &static_cast<ZAnyBase::holder<ValueType>*>(operand->content)->held; - } - -template<typename ValueType> -const ValueType* ZAnyBaseCast(const ZAnyBase* operand) - { - if (!operand || operand->type() != typeid(ValueType)) - return 0; - return &static_cast<ZAnyBase::holder<ValueType>*>(operand->content)->held; - } - -} // namespace ZooLib - -// ================================================================================================= -#pragma mark - #pragma mark * ZAny namespace ZooLib { -class ZAny : private ZAnyBase +class ZAny { public: ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZAny, operator_bool_generator_type, operator_bool_type); - operator operator_bool_type() const; + operator operator_bool_type() const + { return operator_bool_generator_type::translate(fRep); } - void swap(ZAny& rhs) - { ZAnyBase::swap((ZAnyBase&)rhs); } - - const std::type_info& Type() const - { return ZAnyBase::type(); } - - const void* VoidStar() const - { return ZAnyBase::voidstar(); } - - void* VoidStar() - { return ZAnyBase::voidstar(); } - ZAny() + : fRep(0) {} - ZAny(const ZAny& other) - : ZAnyBase((const ZAnyBase&)other) + ZAny(const ZAny& iOther) + : fRep(iOther.fRep ? iOther.fRep->Clone() : 0) {} - + ~ZAny() - {} + { delete fRep; } - ZAny& operator=(const ZAny& rhs) + ZAny& operator=(ZAny iOther) { - ZAnyBase::operator=((const ZAnyBase&)rhs); + this->swap(iOther); return *this; } template <class S> explicit ZAny(const S& iVal) - : ZAnyBase(iVal) + : fRep(new Rep_T<S>(iVal)) {} template <class S> ZAny& operator=(const S& iVal) { - ZAnyBase::operator=(iVal); + ZAny(iVal).swap(*this); return *this; } + void swap(ZAny& ioOther) + { std::swap(fRep, ioOther.fRep); } + + const std::type_info& Type() const + { + if (fRep) + return fRep->Type(); + return typeid(void); + } + + const void* VoidStar() const + { + if (fRep) + return fRep->VoidStar(); + return 0; + } + + void* VoidStar() + { + if (fRep) + return fRep->VoidStar(); + return 0; + } + // ZVal protocol, for use by ZVal derivatives - void Clear(); + void Clear() + { ZAny().swap(*this); } template <class S> S* PGet() - { return ZAnyBaseCast<S>(this); } + { + if (!fRep || fRep->Type() != typeid(S)) + return 0; + return &static_cast<Rep_T<S>*>(fRep)->fValue; + } template <class S> const S* PGet() const - { return ZAnyBaseCast<S>(this); } + { + if (!fRep || fRep->Type() != typeid(S)) + return 0; + return &static_cast<Rep_T<S>*>(fRep)->fValue; + } template <class S> ZQ<S> QGet() const @@ -232,40 +142,50 @@ template <class S> void Set(const S& iVal) - { ZAnyBase::operator=(iVal); } + { ZAny(iVal).swap(*this); } // Our protocol template <class S> bool Is() const { return this->PGet<S>(); } - }; -inline void swap(ZAny& a, ZAny& b) - { a.swap(b); } +private: + class RepBase + { + public: + virtual ~RepBase() {} -} // namespace ZooLib + virtual const std::type_info& Type() const = 0; + virtual RepBase* Clone() const = 0; + virtual void* VoidStar() = 0; + }; -// ================================================================================================= -#pragma mark - -#pragma mark * ZAny coercion + template<typename S> + class Rep_T : public RepBase + { + public: + Rep_T(const S& iValue) + : fValue(iValue) + {} -namespace ZooLib { + virtual const std::type_info& Type() const + { return typeid(S); } -ZQ<bool> sQCoerceBool(const ZAny& iAny); -bool sQCoerceBool(const ZAny& iAny, bool& oVal); -bool sDCoerceBool(bool iDefault, const ZAny& iAny); -bool sCoerceBool(const ZAny& iAny); + virtual RepBase* Clone() const + { return new Rep_T(fValue); } -ZQ<int64> sQCoerceInt(const ZAny& iAny); -bool sQCoerceInt(const ZAny& iAny, int64& oVal); -int64 sDCoerceInt(int64 iDefault, const ZAny& iAny); -int64 sCoerceInt(const ZAny& iAny); + virtual void* VoidStar() + { return &fValue; } -ZQ<double> sQCoerceReal(const ZAny& iAny); -bool sQCoerceReal(const ZAny& iAny, double& oVal); -double sDCoerceReal(double iDefault, const ZAny& iAny); -double sCoerceReal(const ZAny& iAny); + S fValue; + }; + RepBase* fRep; + }; + +inline void swap(ZAny& a, ZAny& b) + { a.swap(b); } + } // namespace ZooLib #endif // __ZAny__ Added: trunk/zoolib/source/cxx/zoolib/ZUtil_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Any.cpp (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Any.cpp 2010-12-29 16:29:53 UTC (rev 1835) @@ -0,0 +1,173 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2009 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZUtil_Any.h" +#include "zoolib/ZString.h" + +using std::string; + +// ================================================================================================= +#pragma mark - +#pragma mark * Coercion + +namespace ZooLib { + +ZQ<bool> sQCoerceBool(const ZAny& iAny) + { + if (const bool* pBool = iAny.PGet<bool>()) + return *pBool; + + if (ZQ<int64> qInt64 = sQCoerceInt(iAny)) + return (0 != qInt64.Get()); + + if (ZQ<double> qDouble = sQCoerceReal(iAny)) + return (0.0 != qDouble.Get()); + + if (const string* pString = iAny.PGet<string>()) + { + if (pString->empty()) + return false; + + if (ZQ<double> qDouble = ZString::sQDouble(*pString)) + return (0.0 != qDouble.Get()); + + if (ZQ<int64> qInt64 = ZString::sQInt64(*pString)) + return (0 != qInt64.Get()); + + if (ZString::sEquali(*pString, "t") || ZString::sEquali(*pString, "true")) + return true; + + if (ZString::sEquali(*pString, "f") || ZString::sEquali(*pString, "false")) + return false; + } + return null; + } + +bool sQCoerceBool(const ZAny& iAny, bool& oVal) + { + if (ZQ<bool> qBool = sQCoerceBool(iAny)) + { + oVal = qBool.Get(); + return true; + } + return false; + } + +bool sDCoerceBool(bool iDefault, const ZAny& iAny) + { + bool result; + if (sQCoerceBool(iAny, result)) + return result; + return iDefault; + } + +bool sCoerceBool(const ZAny& iAny) + { + bool result; + if (sQCoerceBool(iAny, result)) + return result; + return false; + } + +ZQ<int64> sQCoerceInt(const ZAny& iAny) + { + if (false) + {} + else if (const char* theVal = iAny.PGet<char>()) + return *theVal; + else if (const signed char* theVal = iAny.PGet<signed char>()) + return *theVal; + else if (const unsigned char* theVal = iAny.PGet<unsigned char>()) + return *theVal; + else if (const wchar_t* theVal = iAny.PGet<wchar_t>()) + return *theVal; + else if (const short* theVal = iAny.PGet<short>()) + return *theVal; + else if (const unsigned short* theVal = iAny.PGet<unsigned short>()) + return *theVal; + else if (const int* theVal = iAny.PGet<int>()) + return *theVal; + else if (const unsigned int* theVal = iAny.PGet<unsigned int>()) + return *theVal; + else if (const long* theVal = iAny.PGet<long>()) + return *theVal; + else if (const unsigned long* theVal = iAny.PGet<unsigned long>()) + return *theVal; + else if (const int64* theVal = iAny.PGet<int64>()) + return *theVal; + else if (const uint64* theVal = iAny.PGet<uint64>()) + return *theVal; + + return null; + } + +bool sQCoerceInt(const ZAny& iAny, int64& oVal) + { + if (ZQ<int64> qInt64 = sQCoerceInt(iAny)) + { + oVal = qInt64.Get(); + return true; + } + return false; + } + +int64 sDCoerceInt(int64 iDefault, const ZAny& iAny) + { + if (ZQ<int64> qInt = sQCoerceInt(iAny)) + return qInt.Get(); + return iDefault; + } + +int64 sCoerceInt(const ZAny& iAny) + { return sDCoerceInt(0, iAny); } + +ZQ<double> sQCoerceReal(const ZAny& iAny) + { + if (false) + {} + else if (const float* theVal = iAny.PGet<float>()) + return *theVal; + else if (const double* theVal = iAny.PGet<double>()) + return *theVal; + + return null; + } + +bool sQCoerceReal(const ZAny& iAny, double& oVal) + { + if (ZQ<double> qDouble = sQCoerceReal(iAny)) + { + oVal = qDouble.Get(); + return true; + } + return false; + } + +double sDCoerceReal(double iDefault, const ZAny& iAny) + { + if (ZQ<double> qDouble = sQCoerceReal(iAny)) + return qDouble.Get(); + return iDefault; + } + +double sCoerceReal(const ZAny& iAny) + { return sDCoerceReal(0.0, iAny); } + +} // namespace ZooLib Added: trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h 2010-12-29 16:29:53 UTC (rev 1835) @@ -0,0 +1,51 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZUtil_Any__ +#define __ZUtil_Any__ +#include "zconfig.h" + +#include "zoolib/ZAny.h" +#include "zoolib/ZStdInt.h" // For int64 + +// ================================================================================================= +#pragma mark - +#pragma mark * ZAny coercion + +namespace ZooLib { + +ZQ<bool> sQCoerceBool(const ZAny& iAny); +bool sQCoerceBool(const ZAny& iAny, bool& oVal); +bool sDCoerceBool(bool iDefault, const ZAny& iAny); +bool sCoerceBool(const ZAny& iAny); + +ZQ<int64> sQCoerceInt(const ZAny& iAny); +bool sQCoerceInt(const ZAny& iAny, int64& oVal); +int64 sDCoerceInt(int64 iDefault, const ZAny& iAny); +int64 sCoerceInt(const ZAny& iAny); + +ZQ<double> sQCoerceReal(const ZAny& iAny); +bool sQCoerceReal(const ZAny& iAny, double& oVal); +double sDCoerceReal(double iDefault, const ZAny& iAny); +double sCoerceReal(const ZAny& iAny); + +} // namespace ZooLib + +#endif // __ZUtil_Any__ Property changes on: trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h ___________________________________________________________________ Added: svn:executable + * Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2010-12-29 03:42:11 UTC (rev 1834) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2010-12-29 16:29:53 UTC (rev 1835) @@ -53,7 +53,7 @@ {} ZVal_Any(const ZVal_Any& iOther) - : ZAny(iOther.AsAny()) + : ZAny((const ZAny&)(iOther)) {} ~ZVal_Any() @@ -61,7 +61,7 @@ ZVal_Any& operator=(const ZVal_Any& iOther) { - ZAny::operator=(iOther.AsAny()); + ZAny::operator=((const ZAny&)(iOther)); return *this; } @@ -76,28 +76,48 @@ return *this; } +// Overload, so a null becomes a ZVal_Any() + ZVal_Any(const null_t&) + : ZAny() + {} + + ZVal_Any& operator=(const null_t&) + { + ZAny::Clear(); + return *this; + } + // Overload, so we can init/assign from a string constant - ZVal_Any(const char* iVal) + ZVal_Any(const UTF8* iVal) : ZAny(string8(iVal)) {} - ZVal_Any& operator=(const char* iVal) + ZVal_Any& operator=(const UTF8* iVal) { ZAny::operator=(string8(iVal)); return *this; } -// Overload, so a null becomes a ZVal_Any() - ZVal_Any(const null_t&) - : ZAny() + ZVal_Any(const UTF16* iVal) + : ZAny(string16(iVal)) {} - ZVal_Any& operator=(const null_t&) + ZVal_Any& operator=(const UTF16* iVal) { - ZAny::Clear(); + ZAny::operator=(string16(iVal)); return *this; } + ZVal_Any(const UTF32* iVal) + : ZAny(string32(iVal)) + {} + + ZVal_Any& operator=(const UTF32* iVal) + { + ZAny::operator=(string32(iVal)); + return *this; + } + // Overload, as ZAny's templated constructor is explicit. template <class S> ZVal_Any(const S& iVal) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2011-01-03 03:00:42
|
Revision: 1849 http://zoolib.svn.sourceforge.net/zoolib/?rev=1849&view=rev Author: agreen Date: 2011-01-03 03:00:34 +0000 (Mon, 03 Jan 2011) Log Message: ----------- Pass const ZRef<>& more generally -- substantially reduces the amount of object code. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Result.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Result.h trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker.h trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Calc.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Calc.h trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Const.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Const.h trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.h trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.h trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.h trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.h trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Select.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Compare_Rel.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Select.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Select.h trunk/zoolib/source/cxx/zoolib/ZDelegate.h trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.cpp trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.h trunk/zoolib/source/cxx/zoolib/ZExpr_Op_T.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.cpp trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_DoCompare.cpp trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_DoCompare.h trunk/zoolib/source/cxx/zoolib/ZWorkerRunner_CFRunLoop.cpp trunk/zoolib/source/cxx/zoolib/ZWorkerRunner_CFRunLoop.h Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Result.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Result.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Result.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -69,7 +69,7 @@ } } -Result::Result(ZRef<ZQE::Result> iOther, size_t iRow) +Result::Result(const ZRef<ZQE::Result>& iOther, size_t iRow) : fRelHead(iOther->GetRelHead()) { if (iRow < iOther->Count()) Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Result.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Result.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Result.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -44,7 +44,7 @@ std::vector<ZVal_Any>* ioPackedRows, std::vector<std::vector<ZRef<ZCounted> > >* ioAnnotations); - Result(ZRef<ZQE::Result> iOther, size_t iRow); + Result(const ZRef<ZQE::Result>& iOther, size_t iRow); virtual ~Result(); Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -37,7 +37,7 @@ #pragma mark - #pragma mark * Walker_Unary -Walker_Unary::Walker_Unary(ZRef<Walker> iWalker) +Walker_Unary::Walker_Unary(const ZRef<Walker>& iWalker) : fWalker(iWalker) {} Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -62,7 +62,7 @@ class Walker_Unary : public Walker { protected: - Walker_Unary(ZRef<Walker> iWalker); + Walker_Unary(const ZRef<Walker>& iWalker); public: virtual ~Walker_Unary(); Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Calc.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Calc.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Calc.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -31,8 +31,8 @@ #pragma mark - #pragma mark * Walker_Calc -Walker_Calc::Walker_Calc(ZRef<Walker> iWalker, - const string8& iRelName, ZRef<Callable> iCallable) +Walker_Calc::Walker_Calc(const ZRef<Walker>& iWalker, + const string8& iRelName, const ZRef<Callable>& iCallable) : Walker_Unary(iWalker) , fRelName(iRelName) , fCallable(iCallable) Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Calc.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Calc.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Calc.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -35,10 +35,10 @@ class Walker_Calc : public Walker_Unary { public: - typedef ZCallable<ZVal_Any(ZMap_Any)> Callable; + typedef ZCallable<ZVal_Any(const ZMap_Any&)> Callable; - Walker_Calc(ZRef<Walker> iWalker, - const string8& iRelName, ZRef<Callable> iCallable); + Walker_Calc(const ZRef<Walker>& iWalker, + const string8& iRelName, const ZRef<Callable>& iCallable); virtual ~Walker_Calc(); @@ -54,7 +54,7 @@ private: const string8 fRelName; size_t fOutputOffset; - const ZRef<ZCallable<ZVal_Any(ZMap_Any)> > fCallable; + const ZRef<Callable> fCallable; std::map<string8,size_t> fBindingOffsets; std::map<string8,size_t> fChildOffsets; }; Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Const.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Const.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Const.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -30,7 +30,7 @@ #pragma mark - #pragma mark * Walker_Const -Walker_Const::Walker_Const(ZRef<Walker> iWalker, +Walker_Const::Walker_Const(const ZRef<Walker>& iWalker, const string8& iRelName, const ZVal_Any& iVal) : Walker_Unary(iWalker) , fRelName(iRelName) Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Const.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Const.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Const.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -35,7 +35,7 @@ class Walker_Const : public Walker_Unary { public: - Walker_Const(ZRef<Walker> iWalker, const string8& iRelName, + Walker_Const(const ZRef<Walker>& iWalker, const string8& iRelName, const ZVal_Any& iVal); virtual ~Walker_Const(); Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -32,8 +32,8 @@ #pragma mark - #pragma mark * Walker_Embed -Walker_Embed::Walker_Embed(ZRef<Walker> iWalker, - const string8& iRelName, ZRef<Walker> iWalker_Ext) +Walker_Embed::Walker_Embed(const ZRef<Walker>& iWalker, + const string8& iRelName, const ZRef<Walker>& iWalker_Ext) : Walker_Unary(iWalker) , fRelName(iRelName) , fWalker_Ext(iWalker_Ext) Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -35,8 +35,8 @@ class Walker_Embed : public Walker_Unary { public: - Walker_Embed(ZRef<Walker> iWalker, - const string8& iRelName, ZRef<Walker> iWalker_Ext); + Walker_Embed(const ZRef<Walker>& iWalker, + const string8& iRelName, const ZRef<Walker>& iWalker_Ext); virtual ~Walker_Embed(); Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -31,7 +31,7 @@ #pragma mark - #pragma mark * Walker_Product -Walker_Product::Walker_Product(ZRef<Walker> iWalker_Left, ZRef<Walker> iWalker_Right) +Walker_Product::Walker_Product(const ZRef<Walker>& iWalker_Left, const ZRef<Walker>& iWalker_Right) : fWalker_Left(iWalker_Left) , fWalker_Right(iWalker_Right) , fNeedLoadLeft(true) Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -34,7 +34,7 @@ class Walker_Product : public Walker { public: - Walker_Product(ZRef<Walker> iWalker_Left, ZRef<Walker> iWalker_Right); + Walker_Product(const ZRef<Walker>& iWalker_Left, const ZRef<Walker>& iWalker_Right); virtual ~Walker_Product(); // From ZQE::Walker Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -31,7 +31,7 @@ #pragma mark - #pragma mark * Walker_Project -Walker_Project::Walker_Project(ZRef<Walker> iWalker, const ZRA::RelHead& iRelHead) +Walker_Project::Walker_Project(const ZRef<Walker>& iWalker, const ZRA::RelHead& iRelHead) : Walker_Unary(iWalker) , fRelHead(iRelHead) {} Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -35,7 +35,7 @@ class Walker_Project : public Walker_Unary { public: - Walker_Project(ZRef<Walker> iWalker, const ZRA::RelHead& iRelHead); + Walker_Project(const ZRef<Walker>& iWalker, const ZRA::RelHead& iRelHead); virtual ~Walker_Project(); // From ZQE::Walker Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -31,7 +31,7 @@ #pragma mark - #pragma mark * Walker_Rename -Walker_Rename::Walker_Rename(ZRef<Walker> iWalker, const string8& iNew, const string8& iOld) +Walker_Rename::Walker_Rename(const ZRef<Walker>& iWalker, const string8& iNew, const string8& iOld) : Walker_Unary(iWalker) , fNew(iNew) , fOld(iOld) Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -34,7 +34,7 @@ class Walker_Rename : public Walker_Unary { public: - Walker_Rename(ZRef<Walker> iWalker, const string8& iNew, const string8& iOld); + Walker_Rename(const ZRef<Walker>& iWalker, const string8& iNew, const string8& iOld); virtual ~Walker_Rename(); // From ZQE::Walker Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Select.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Select.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Select.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -48,7 +48,7 @@ std::set<ZRef<ZCounted> >* oAnnotations); private: - ZRef<ZExpr_Bool> fExpr_Bool; + const ZRef<ZExpr_Bool> fExpr_Bool; std::map<string8,size_t> fBindingOffsets; std::map<string8,size_t> fChildOffsets; }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Compare_Rel.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Compare_Rel.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Compare_Rel.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -38,6 +38,10 @@ using namespace ZRA; +//## Note that we'll need a more complex scheme, like that in ZVisitor_Expr_Bool_DoCompare +// when we expand the range of expr_rels we're matching. + + // ================================================================================================= #pragma mark - #pragma mark * Comparer and default derivations (anonymous) @@ -73,16 +77,19 @@ virtual void Visit_Expr_Rel_Select(const ZRef<Expr_Rel_Select>&) { pSetResult(-1); } virtual void Visit_Expr_Rel_Union(const ZRef<Expr_Rel_Union>&) { pSetResult(-1); } - int CompareUnary(ZRef<ZExpr_Op1_T<Expr_Rel> > iLHS, ZRef<ZExpr_Op1_T<Expr_Rel> > iRHS); - int CompareBinary(ZRef<ZExpr_Op2_T<Expr_Rel> > iLHS, ZRef<ZExpr_Op2_T<Expr_Rel> > iRHS); + int CompareUnary( + const ZRef<ZExpr_Op1_T<Expr_Rel> >& iLHS, const ZRef<ZExpr_Op1_T<Expr_Rel> >& iRHS); + + int CompareBinary( + const ZRef<ZExpr_Op2_T<Expr_Rel> >& iLHS, const ZRef<ZExpr_Op2_T<Expr_Rel> >& iRHS); }; -int Comparer::CompareUnary(ZRef<ZExpr_Op1_T<Expr_Rel> > iLHS, ZRef<ZExpr_Op1_T<Expr_Rel> > iRHS) - { - return sCompare_T(iLHS->GetOp0(), iRHS->GetOp0()); - } +int Comparer::CompareUnary( + const ZRef<ZExpr_Op1_T<Expr_Rel> >& iLHS, const ZRef<ZExpr_Op1_T<Expr_Rel> >& iRHS) + { return sCompare_T(iLHS->GetOp0(), iRHS->GetOp0()); } -int Comparer::CompareBinary(ZRef<ZExpr_Op2_T<Expr_Rel> > iLHS, ZRef<ZExpr_Op2_T<Expr_Rel> > iRHS) +int Comparer::CompareBinary( + const ZRef<ZExpr_Op2_T<Expr_Rel> >& iLHS, const ZRef<ZExpr_Op2_T<Expr_Rel> >& iRHS) { if (int compare = sCompare_T(iLHS->GetOp0(), iRHS->GetOp0())) return compare; @@ -135,8 +142,8 @@ struct Comparer_Calc : public Comparer { - ZRef<Expr_Rel_Calc> fExpr; - Comparer_Calc(ZRef<Expr_Rel_Calc> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Calc> fExpr; + Comparer_Calc(const ZRef<Expr_Rel_Calc>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Calc(const ZRef<Expr_Rel_Calc>& iExpr) { if (int compare = sCompare_T(fExpr->GetRelName(), iExpr->GetRelName())) @@ -152,16 +159,16 @@ struct Comparer_Concrete : public Comparer_GT_Calc { - ZRef<Expr_Rel_Concrete> fExpr; - Comparer_Concrete(ZRef<Expr_Rel_Concrete> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Concrete> fExpr; + Comparer_Concrete(const ZRef<Expr_Rel_Concrete>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Concrete(const ZRef<Expr_Rel_Concrete>& iExpr) { pSetResult(sCompare_T(fExpr->GetConcreteRelHead(), iExpr->GetConcreteRelHead())); } }; struct Comparer_Const : public Comparer_GT_Concrete { - ZRef<Expr_Rel_Const> fExpr; - Comparer_Const(ZRef<Expr_Rel_Const> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Const> fExpr; + Comparer_Const(const ZRef<Expr_Rel_Const>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Const(const ZRef<Expr_Rel_Const>& iExpr) { if (int compare = sCompare_T(fExpr->GetRelName(), iExpr->GetRelName())) @@ -175,16 +182,16 @@ struct Comparer_Difference : public Comparer_GT_Const { - ZRef<Expr_Rel_Difference> fExpr; - Comparer_Difference(ZRef<Expr_Rel_Difference> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Difference> fExpr; + Comparer_Difference(const ZRef<Expr_Rel_Difference>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Difference(const ZRef<Expr_Rel_Difference>& iExpr) { pSetResult(CompareBinary(fExpr, iExpr)); } }; struct Comparer_Embed : public Comparer_GT_Difference { - ZRef<Expr_Rel_Embed> fExpr; - Comparer_Embed(ZRef<Expr_Rel_Embed> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Embed> fExpr; + Comparer_Embed(const ZRef<Expr_Rel_Embed>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Embed(const ZRef<Expr_Rel_Embed>& iExpr) { if (int compare = sCompare_T(fExpr->GetRelName(), iExpr->GetRelName())) @@ -196,24 +203,24 @@ struct Comparer_Intersect : public Comparer_GT_Embed { - ZRef<Expr_Rel_Intersect> fExpr; - Comparer_Intersect(ZRef<Expr_Rel_Intersect> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Intersect> fExpr; + Comparer_Intersect(const ZRef<Expr_Rel_Intersect>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Intersect(const ZRef<Expr_Rel_Intersect>& iExpr) { pSetResult(CompareBinary(fExpr, iExpr)); } }; struct Comparer_Product : public Comparer_GT_Intersect { - ZRef<Expr_Rel_Product> fExpr; - Comparer_Product(ZRef<Expr_Rel_Product> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Product> fExpr; + Comparer_Product(const ZRef<Expr_Rel_Product>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Product(const ZRef<Expr_Rel_Product>& iExpr) { pSetResult(CompareBinary(fExpr, iExpr)); } }; struct Comparer_Project : public Comparer_GT_Product { - ZRef<Expr_Rel_Project> fExpr; - Comparer_Project(ZRef<Expr_Rel_Project> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Project> fExpr; + Comparer_Project(const ZRef<Expr_Rel_Project>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Project(const ZRef<Expr_Rel_Project>& iExpr) { if (int compare = sCompare_T(fExpr->GetProjectRelHead(), iExpr->GetProjectRelHead())) @@ -225,8 +232,8 @@ struct Comparer_Rename : public Comparer_GT_Project { - ZRef<Expr_Rel_Rename> fExpr; - Comparer_Rename(ZRef<Expr_Rel_Rename> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Rename> fExpr; + Comparer_Rename(const ZRef<Expr_Rel_Rename>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Rename(const ZRef<Expr_Rel_Rename>& iExpr) { if (int compare = sCompare_T(fExpr->GetOld(), iExpr->GetOld())) @@ -240,8 +247,8 @@ struct Comparer_Restrict : public Comparer_GT_Rename { - ZRef<Expr_Rel_Restrict> fExpr; - Comparer_Restrict(ZRef<Expr_Rel_Restrict> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Restrict> fExpr; + Comparer_Restrict(const ZRef<Expr_Rel_Restrict>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Restrict(const ZRef<Expr_Rel_Restrict>& iExpr) { if (int compare = sCompare_T(fExpr->GetValPred(), iExpr->GetValPred())) @@ -253,11 +260,12 @@ struct Comparer_Select : public Comparer_GT_Restrict { - ZRef<Expr_Rel_Select> fExpr; - Comparer_Select(ZRef<Expr_Rel_Select> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Select> fExpr; + Comparer_Select(const ZRef<Expr_Rel_Select>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Select(const ZRef<Expr_Rel_Select>& iExpr) { - if (int compare = Visitor_Expr_Bool_ValPred_DoCompare::Comparer_Bootstrap() + if (int compare = + Visitor_Expr_Bool_ValPred_DoCompare::Comparer_Bootstrap() .Compare(fExpr->GetExpr_Bool(), iExpr->GetExpr_Bool())) { pSetResult(compare); @@ -271,8 +279,8 @@ struct Comparer_Union : public Comparer_GT_Select { - ZRef<Expr_Rel_Union> fExpr; - Comparer_Union(ZRef<Expr_Rel_Union> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel_Union> fExpr; + Comparer_Union(const ZRef<Expr_Rel_Union>& iExpr) : fExpr(iExpr) {} virtual void Visit_Expr_Rel_Union(const ZRef<Expr_Rel_Union>& iExpr) { pSetResult(CompareBinary(fExpr, iExpr)); } }; @@ -281,7 +289,7 @@ // ================================================================================================= #pragma mark - -#pragma mark * Bootstrap +#pragma mark * Comparer_Bootstrap namespace { // anonymous @@ -300,9 +308,10 @@ , public virtual Visitor_Expr_Rel_Select , public virtual Visitor_Expr_Rel_Union { - ZRef<Expr_Rel> fExpr; - Comparer_Bootstrap(ZRef<Expr_Rel> iExpr) : fExpr(iExpr) {} + const ZRef<Expr_Rel> fExpr; + Comparer_Bootstrap(const ZRef<Expr_Rel>& iExpr) : fExpr(iExpr) {} + virtual void Visit_Expr_Rel_Calc(const ZRef<Expr_Rel_Calc>& iExpr) { pSetResult(Comparer_Calc(iExpr).Do(fExpr)); } Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -72,7 +72,7 @@ theCallable->Call(iMessage); } -SetRestore_SemanticError::SetRestore_SemanticError(ZRef<Callable_SemanticError> iCallable) +SetRestore_SemanticError::SetRestore_SemanticError(const ZRef<Callable_SemanticError>& iCallable) : fCallable(iCallable) , fPrior(spGet()) { Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -68,7 +68,7 @@ class SetRestore_SemanticError { public: - SetRestore_SemanticError(ZRef<Callable_SemanticError> iCallable); + SetRestore_SemanticError(const ZRef<Callable_SemanticError>& iCallable); ~SetRestore_SemanticError(); private: Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -62,10 +62,10 @@ void Expr_Rel_Calc::Accept_Expr_Rel_Calc(Visitor_Expr_Rel_Calc& iVisitor) { iVisitor.Visit_Expr_Rel_Calc(this); } -RelName Expr_Rel_Calc::GetRelName() +const RelName& Expr_Rel_Calc::GetRelName() { return fRelName; } -ZRef<Expr_Rel_Calc::Callable> Expr_Rel_Calc::GetCallable() +const ZRef<Expr_Rel_Calc::Callable>& Expr_Rel_Calc::GetCallable() { return fCallable; } // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -42,7 +42,7 @@ { typedef ZExpr_Op1_T<Expr_Rel> inherited; public: - typedef ZCallable<ZVal_Any(ZMap_Any)> Callable; + typedef ZCallable<ZVal_Any(const ZMap_Any&)> Callable; Expr_Rel_Calc(const ZRef<Expr_Rel>& iOp0, const RelName& iRelName, const ZRef<Callable>& iCallable); @@ -61,8 +61,8 @@ // Our protocol virtual void Accept_Expr_Rel_Calc(Visitor_Expr_Rel_Calc& iVisitor); - RelName GetRelName(); - ZRef<Callable> GetCallable(); + const RelName& GetRelName(); + const ZRef<Callable>& GetCallable(); private: const RelName fRelName; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -56,7 +56,7 @@ void Expr_Rel_Concrete::Accept_Expr_Rel_Concrete(Visitor_Expr_Rel_Concrete& iVisitor) { iVisitor.Visit_Expr_Rel_Concrete(this); } -RelHead Expr_Rel_Concrete::GetConcreteRelHead() +const RelHead& Expr_Rel_Concrete::GetConcreteRelHead() const { return fRelHead; } // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -56,7 +56,7 @@ // Our protocol virtual void Accept_Expr_Rel_Concrete(Visitor_Expr_Rel_Concrete& iVisitor); - RelHead GetConcreteRelHead(); + const RelHead& GetConcreteRelHead() const; private: const RelHead fRelHead; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -63,10 +63,10 @@ void Expr_Rel_Const::Accept_Expr_Rel_Const(Visitor_Expr_Rel_Const& iVisitor) { iVisitor.Visit_Expr_Rel_Const(this); } -RelName Expr_Rel_Const::GetRelName() +const RelName& Expr_Rel_Const::GetRelName() const { return fRelName; } -const ZVal_Any& Expr_Rel_Const::GetVal() +const ZVal_Any& Expr_Rel_Const::GetVal() const { return fVal; } // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -59,8 +59,8 @@ // Our protocol virtual void Accept_Expr_Rel_Const(Visitor_Expr_Rel_Const& iVisitor); - RelName GetRelName(); - const ZVal_Any& GetVal(); + const RelName& GetRelName() const; + const ZVal_Any& GetVal() const; private: const RelName fRelName; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -58,7 +58,7 @@ void Expr_Rel_Embed::Accept_Expr_Rel_Embed(Visitor_Expr_Rel_Embed& iVisitor) { iVisitor.Visit_Expr_Rel_Embed(this); } -const RelName& Expr_Rel_Embed::GetRelName() +const RelName& Expr_Rel_Embed::GetRelName() const { return fRelName; } // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -54,7 +54,7 @@ // Our protocol virtual void Accept_Expr_Rel_Embed(Visitor_Expr_Rel_Embed& iVisitor); - const RelName& GetRelName(); + const RelName& GetRelName() const; private: const RelName fRelName; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -60,7 +60,7 @@ void Expr_Rel_Project::Accept_Expr_Rel_Project(Visitor_Expr_Rel_Project& iVisitor) { iVisitor.Visit_Expr_Rel_Project(this); } -const RelHead& Expr_Rel_Project::GetProjectRelHead() +const RelHead& Expr_Rel_Project::GetProjectRelHead() const { return fRelHead; } // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -56,7 +56,7 @@ // Our protocol virtual void Accept_Expr_Rel_Project(Visitor_Expr_Rel_Project& iVisitor); - const RelHead& GetProjectRelHead(); + const RelHead& GetProjectRelHead() const; private: const RelHead fRelHead; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -64,10 +64,10 @@ void Expr_Rel_Rename::Accept_Expr_Rel_Rename(Visitor_Expr_Rel_Rename& iVisitor) { iVisitor.Visit_Expr_Rel_Rename(this); } -const RelName& Expr_Rel_Rename::GetNew() +const RelName& Expr_Rel_Rename::GetNew() const { return fNew; } -const RelName& Expr_Rel_Rename::GetOld() +const RelName& Expr_Rel_Rename::GetOld() const { return fOld; } // ================================================================================================= Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -57,8 +57,8 @@ // Our protocol virtual void Accept_Expr_Rel_Rename(Visitor_Expr_Rel_Rename& iVisitor); - const RelName& GetNew(); - const RelName& GetOld(); + const RelName& GetNew() const; + const RelName& GetOld() const; private: const RelName fNew; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Select.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Select.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Select.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -60,7 +60,7 @@ void Expr_Rel_Select::Accept_Expr_Rel_Select( Visitor_Expr_Rel_Select& iVisitor) { iVisitor.Visit_Expr_Rel_Select(this); } -ZRef<ZExpr_Bool> Expr_Rel_Select::GetExpr_Bool() +const ZRef<ZExpr_Bool>& Expr_Rel_Select::GetExpr_Bool() const { return fExpr_Bool; } // ================================================================================================= @@ -71,7 +71,7 @@ { this->Visit_Expr_Op1(iExpr); - if (ZRef<ZExpr_Bool> theExpr_Bool = iExpr->GetExpr_Bool()) + if (const ZRef<ZExpr_Bool>& theExpr_Bool = iExpr->GetExpr_Bool()) theExpr_Bool->Accept(*this); } Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Select.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Select.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Select.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -56,7 +56,7 @@ // Our protocol virtual void Accept_Expr_Rel_Select(Visitor_Expr_Rel_Select& iVisitor); - ZRef<ZExpr_Bool> GetExpr_Bool(); + const ZRef<ZExpr_Bool>& GetExpr_Bool() const; private: const ZRef<ZExpr_Bool> fExpr_Bool; Modified: trunk/zoolib/source/cxx/zoolib/ZDelegate.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDelegate.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZDelegate.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -55,7 +55,7 @@ #ifdef __OBJC__ template <class Callable> - void Set(SEL iSEL, ZRef<Callable> iCallable); + void Set(SEL iSEL, const ZRef<Callable>& iCallable); operator id(); @@ -77,39 +77,39 @@ template <class Signature> class Wrapper_T; template <class R> - static ZRef<Wrapper> spMakeWrapper(ZRef<ZCallable<R(void)> > iCallable); + static ZRef<Wrapper> spMakeWrapper(const ZRef<ZCallable<R(void)> >& iCallable); template <class R, class P0> - static ZRef<Wrapper> spMakeWrapper(ZRef<ZCallable<R(P0)> > iCallable); + static ZRef<Wrapper> spMakeWrapper(const ZRef<ZCallable<R(P0)> >& iCallable); template <class R, class P0, class P1> - static ZRef<Wrapper> spMakeWrapper(ZRef<ZCallable<R(P0,P1)> > iCallable); + static ZRef<Wrapper> spMakeWrapper(const ZRef<ZCallable<R(P0,P1)> >& iCallable); template <class R, class P0, class P1, class P2> - static ZRef<Wrapper> spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2)> > iCallable); + static ZRef<Wrapper> spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2)> >& iCallable); template <class R, class P0, class P1, class P2, class P3> - static ZRef<Wrapper> spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3)> > iCallable); + static ZRef<Wrapper> spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3)> >& iCallable); template <class R, class P0, class P1, class P2, class P3, class P4> - static ZRef<Wrapper> spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3,P4)> > iCallable); + static ZRef<Wrapper> spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3,P4)> >& iCallable); template <class R, class P0, class P1, class P2, class P3, class P4, class P5> - static ZRef<Wrapper> spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5)> > iCallable); + static ZRef<Wrapper> spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5)> >& iCallable); template <class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6> - static ZRef<Wrapper> spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5,P6)> > iCallable); + static ZRef<Wrapper> spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5,P6)> >& iCallable); template <class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7> - static ZRef<Wrapper> spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5,P6,P7)> > iCallable); + static ZRef<Wrapper> spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5,P6,P7)> >& iCallable); #endif // __OBJC__ }; @@ -173,7 +173,7 @@ typedef ZCallable<R(void)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(R)); @@ -199,7 +199,7 @@ typedef ZCallable<void(void)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(void)); @@ -225,7 +225,7 @@ typedef ZCallable<R(P0)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(R), @@ -255,7 +255,7 @@ typedef ZCallable<void(P0)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(void), @@ -285,7 +285,7 @@ typedef ZCallable<R(P0,P1)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(R), @@ -317,7 +317,7 @@ typedef ZCallable<void(P0,P1)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(void), @@ -349,7 +349,7 @@ typedef ZCallable<R(P0,P1,P2)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(R), @@ -383,7 +383,7 @@ typedef ZCallable<void(P0,P1,P2)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(void), @@ -417,7 +417,7 @@ typedef ZCallable<R(P0,P1,P2,P3)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(R), @@ -453,7 +453,7 @@ typedef ZCallable<void(P0,P1,P2,P3)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(void), @@ -489,7 +489,7 @@ typedef ZCallable<R(P0,P1,P2,P3,P4)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(R), @@ -528,7 +528,7 @@ typedef ZCallable<void(P0,P1,P2,P3,P4)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(void), @@ -567,7 +567,7 @@ typedef ZCallable<R(P0,P1,P2,P3,P4,P5)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(R), @@ -608,7 +608,7 @@ typedef ZCallable<void(P0,P1,P2,P3,P4,P5)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(void), @@ -650,7 +650,7 @@ typedef ZCallable<R(P0,P1,P2,P3,P4,P5,P6)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(R), @@ -693,7 +693,7 @@ typedef ZCallable<void(P0,P1,P2,P3,P4,P5,P6)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(void), @@ -736,7 +736,7 @@ typedef ZCallable<R(P0,P1,P2,P3,P4,P5,P6,P7)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(R), @@ -781,7 +781,7 @@ typedef ZCallable<void(P0,P1,P2,P3,P4,P5,P6,P7)> Callable; - Wrapper_T(ZRef<Callable> iCallable) + Wrapper_T(const ZRef<Callable>& iCallable) : fCallable(iCallable) { this->pSetSignature(@encode(void), @@ -821,49 +821,49 @@ template <class R, class P0> ZRef<ZDelegate::Wrapper> -ZDelegate::spMakeWrapper(ZRef<ZCallable<R(P0)> > iCallable) +ZDelegate::spMakeWrapper(const ZRef<ZCallable<R(P0)> >& iCallable) { return new ZDelegate::Wrapper_T<R(P0)>(iCallable); } template <class R, class P0, class P1> ZRef<ZDelegate::Wrapper> -ZDelegate::spMakeWrapper(ZRef<ZCallable<R(P0,P1)> > iCallable) +ZDelegate::spMakeWrapper(const ZRef<ZCallable<R(P0,P1)> >& iCallable) { return new ZDelegate::Wrapper_T<R(P0,P1)>(iCallable); } template <class R, class P0, class P1, class P2> ZRef<ZDelegate::Wrapper> -ZDelegate::spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2)> > iCallable) +ZDelegate::spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2)> >& iCallable) { return new ZDelegate::Wrapper_T<R(P0,P1,P2)>(iCallable); } template <class R, class P0, class P1, class P2, class P3> ZRef<ZDelegate::Wrapper> -ZDelegate::spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3)> > iCallable) +ZDelegate::spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3)> >& iCallable) { return new ZDelegate::Wrapper_T<R(P0,P1,P2,P3)>(iCallable); } template <class R, class P0, class P1, class P2, class P3, class P4> ZRef<ZDelegate::Wrapper> -ZDelegate::spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3,P4)> > iCallable) +ZDelegate::spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3,P4)> >& iCallable) { return new ZDelegate::Wrapper_T<R(P0,P1,P2,P3,P4)>(iCallable); } template <class R, class P0, class P1, class P2, class P3, class P4, class P5> ZRef<ZDelegate::Wrapper> -ZDelegate::spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5)> > iCallable) +ZDelegate::spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5)> >& iCallable) { return new ZDelegate::Wrapper_T<R(P0,P1,P2,P3,P4,P5)>(iCallable); } template <class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6> ZRef<ZDelegate::Wrapper> -ZDelegate::spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5,P6)> > iCallable) +ZDelegate::spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5,P6)> >& iCallable) { return new ZDelegate::Wrapper_T<R(P0,P1,P2,P3,P4,P5,P6)>(iCallable); } template <class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7> ZRef<ZDelegate::Wrapper> -ZDelegate::spMakeWrapper(ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5,P6,P7)> > iCallable) +ZDelegate::spMakeWrapper(const ZRef<ZCallable<R(P0,P1,P2,P3,P4,P5,P6,P7)> >& iCallable) { return new ZDelegate::Wrapper_T<R(P0,P1,P2,P3,P4,P5,P6,P7)>(iCallable); } // ================================================================================================= @@ -871,7 +871,7 @@ #pragma mark * ZDelegate::Add template <class Callable> -void ZDelegate::Set(SEL iSEL, ZRef<Callable> iCallable) +void ZDelegate::Set(SEL iSEL, const ZRef<Callable>& iCallable) { if (iCallable) fWrappers[iSEL] = spMakeWrapper(iCallable); Modified: trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -111,7 +111,7 @@ #pragma mark - #pragma mark * ZExpr_Bool_Not -ZExpr_Bool_Not::ZExpr_Bool_Not(ZRef<ZExpr_Bool> iOp0) +ZExpr_Bool_Not::ZExpr_Bool_Not(const ZRef<ZExpr_Bool>& iOp0) : inherited(iOp0) {} @@ -151,7 +151,7 @@ #pragma mark - #pragma mark * ZExpr_Bool_And -ZExpr_Bool_And::ZExpr_Bool_And(ZRef<ZExpr_Bool> iOp0, ZRef<ZExpr_Bool> iOp1) +ZExpr_Bool_And::ZExpr_Bool_And(const ZRef<ZExpr_Bool>& iOp0, const ZRef<ZExpr_Bool>& iOp1) : inherited(iOp0, iOp1) {} @@ -191,7 +191,7 @@ #pragma mark - #pragma mark * ZExpr_Bool_Or -ZExpr_Bool_Or::ZExpr_Bool_Or(ZRef<ZExpr_Bool> iOp0, ZRef<ZExpr_Bool> iOp1) +ZExpr_Bool_Or::ZExpr_Bool_Or(const ZRef<ZExpr_Bool>& iOp0, const ZRef<ZExpr_Bool>& iOp1) : inherited(iOp0, iOp1) {} Modified: trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -127,7 +127,7 @@ { typedef ZExpr_Op1_T<ZExpr_Bool> inherited; public: - ZExpr_Bool_Not(ZRef<ZExpr_Bool> iOp0); + ZExpr_Bool_Not(const ZRef<ZExpr_Bool>& iOp0); // From ZVisitee virtual void Accept(ZVisitor& iVisitor); @@ -166,7 +166,7 @@ { typedef ZExpr_Op2_T<ZExpr_Bool> inherited; public: - ZExpr_Bool_And(ZRef<ZExpr_Bool> iOp0, ZRef<ZExpr_Bool> iOp1); + ZExpr_Bool_And(const ZRef<ZExpr_Bool>& iOp0, const ZRef<ZExpr_Bool>& iOp1); // From ZVisitee virtual void Accept(ZVisitor& iVisitor); @@ -205,7 +205,7 @@ { typedef ZExpr_Op2_T<ZExpr_Bool> inherited; public: - ZExpr_Bool_Or(ZRef<ZExpr_Bool> iOp0, ZRef<ZExpr_Bool> iOp1); + ZExpr_Bool_Or(const ZRef<ZExpr_Bool>& iOp0, const ZRef<ZExpr_Bool>& iOp1); // From ZVisitee virtual void Accept(ZVisitor& iVisitor); Modified: trunk/zoolib/source/cxx/zoolib/ZExpr_Op_T.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Op_T.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Op_T.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -130,7 +130,7 @@ virtual ZRef<T> Self() = 0; virtual ZRef<T> Clone(const ZRef<T>& iOp0) = 0; - const ZRef<T>& GetOp0() + const ZRef<T>& GetOp0() const { return fOp0; } private: @@ -197,10 +197,10 @@ virtual ZRef<T> Self() = 0; virtual ZRef<T> Clone(const ZRef<T>& iOp0, const ZRef<T>& iOp1) = 0; - const ZRef<T>& GetOp0() + const ZRef<T>& GetOp0() const { return fOp0; } - const ZRef<T>& GetOp1() + const ZRef<T>& GetOp1() const { return fOp1; } private: Modified: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -31,7 +31,7 @@ Comparer_Bootstrap::Comparer_Bootstrap() {} -int Comparer_Bootstrap::Compare(ZRef<ZExpr_Bool> iLHS, ZRef<ZExpr_Bool> iRHS) +int Comparer_Bootstrap::Compare(const ZRef<ZExpr_Bool>& iLHS, const ZRef<ZExpr_Bool>& iRHS) { ZSetRestore_T<ZRef<ZExpr_Bool> > sr(fExpr, iLHS); return this->Do(iRHS); @@ -128,7 +128,7 @@ void Comparer_False::Visit_Expr_Bool_False(const ZRef<ZExpr_Bool_False>&) { pSetResult(0); } -Comparer_Not::Comparer_Not(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Not> iExpr) +Comparer_Not::Comparer_Not(Comparer_Bootstrap* iBootstrap, const ZRef<ZExpr_Bool_Not>& iExpr) : Comparer(iBootstrap) , fExpr(iExpr) {} @@ -136,7 +136,7 @@ void Comparer_Not::Visit_Expr_Bool_Not(const ZRef<ZExpr_Bool_Not>& iExpr) { pSetResult(CompareUnary(fExpr, iExpr)); } -Comparer_And::Comparer_And(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_And> iExpr) +Comparer_And::Comparer_And(Comparer_Bootstrap* iBootstrap, const ZRef<ZExpr_Bool_And>& iExpr) : Comparer(iBootstrap) , fExpr(iExpr) {} @@ -144,7 +144,7 @@ void Comparer_And::Visit_Expr_Bool_And(const ZRef<ZExpr_Bool_And>& iExpr) { pSetResult(CompareBinary(fExpr, iExpr)); } -Comparer_Or::Comparer_Or(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Or> iExpr) +Comparer_Or::Comparer_Or(Comparer_Bootstrap* iBootstrap, const ZRef<ZExpr_Bool_Or>& iExpr) : Comparer(iBootstrap) , fExpr(iExpr) {} Modified: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_DoCompare.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -47,7 +47,7 @@ public: Comparer_Bootstrap(); - int Compare(ZRef<ZExpr_Bool> iLHS, ZRef<ZExpr_Bool> iRHS); + int Compare(const ZRef<ZExpr_Bool>& iLHS, const ZRef<ZExpr_Bool>& iRHS); virtual void Visit_Expr_Bool_True(const ZRef<ZExpr_Bool_True>&); virtual void Visit_Expr_Bool_False(const ZRef<ZExpr_Bool_False>&); @@ -129,31 +129,31 @@ class Comparer_Not : public virtual Comparer_GT_False { public: - Comparer_Not(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Not> iExpr); + Comparer_Not(Comparer_Bootstrap* iBootstrap, const ZRef<ZExpr_Bool_Not>& iExpr); virtual void Visit_Expr_Bool_Not(const ZRef<ZExpr_Bool_Not>& iExpr); private: - ZRef<ZExpr_Bool_Not> fExpr; + const ZRef<ZExpr_Bool_Not> fExpr; }; class Comparer_And : public virtual Comparer_GT_Not { public: - Comparer_And(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_And> iExpr); + Comparer_And(Comparer_Bootstrap* iBootstrap, const ZRef<ZExpr_Bool_And>& iExpr); virtual void Visit_Expr_Bool_And(const ZRef<ZExpr_Bool_And>& iExpr); private: - ZRef<ZExpr_Bool_And> fExpr; + const ZRef<ZExpr_Bool_And> fExpr; }; class Comparer_Or : public virtual Comparer_GT_And { public: - Comparer_Or(Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_Or> iExpr); + Comparer_Or(Comparer_Bootstrap* iBootstrap, const ZRef<ZExpr_Bool_Or>& iExpr); virtual void Visit_Expr_Bool_Or(const ZRef<ZExpr_Bool_Or>& iExpr); private: - ZRef<ZExpr_Bool_Or> fExpr; + const ZRef<ZExpr_Bool_Or> fExpr; }; } // namespace Visitor_Expr_Bool_DoCompare Modified: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_DoCompare.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_DoCompare.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_DoCompare.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -49,7 +49,8 @@ #pragma mark * Visitor_Expr_Bool_ValPred_DoCompare::Comparer_ValPred Comparer_ValPred::Comparer_ValPred( - Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap* iBootstrap, ZRef<ZExpr_Bool_ValPred> iExpr) + Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap* iBootstrap, + const ZRef<ZExpr_Bool_ValPred>& iExpr) : Comparer(iBootstrap) , fExpr(iExpr) {} Modified: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_DoCompare.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_DoCompare.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Bool_ValPred_DoCompare.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -71,13 +71,14 @@ , public virtual ZVisitor_Expr_Bool_ValPred { public: - Comparer_ValPred(Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap* iBootstrap, - ZRef<ZExpr_Bool_ValPred> iExpr); + Comparer_ValPred( + Visitor_Expr_Bool_DoCompare::Comparer_Bootstrap* iBootstrap, + const ZRef<ZExpr_Bool_ValPred>& iExpr); virtual void Visit_Expr_Bool_ValPred(const ZRef<ZExpr_Bool_ValPred>& iExpr); private: - ZRef<ZExpr_Bool_ValPred> fExpr; + const ZRef<ZExpr_Bool_ValPred> fExpr; }; } // namespace Visitor_Expr_Bool_ValPred_DoCompare Modified: trunk/zoolib/source/cxx/zoolib/ZWorkerRunner_CFRunLoop.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWorkerRunner_CFRunLoop.cpp 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZWorkerRunner_CFRunLoop.cpp 2011-01-03 03:00:34 UTC (rev 1849) @@ -65,7 +65,7 @@ 1000000, // interval, needs to be non-zero 0, // flags 0, // order - spRunLoopTimerCallBack, + spCallback, &theContext)); ::CFRunLoopAddTimer(fRunLoop, fRunLoopTimer, kCFRunLoopCommonModes); @@ -137,7 +137,7 @@ ::CFRunLoopTimerSetNextFireDate(fRunLoopTimer, iAbsoluteTime); } -void ZWorkerRunner_CFRunLoop::pRunLoopTimerCallBack() +void ZWorkerRunner_CFRunLoop::pCallback() { const CFAbsoluteTime now = ::CFAbsoluteTimeGetCurrent(); // Reset our next fire date now, so any call to pTrigger has a @@ -191,10 +191,10 @@ } } -void ZWorkerRunner_CFRunLoop::spRunLoopTimerCallBack(CFRunLoopTimerRef iTimer, void* iRefcon) +void ZWorkerRunner_CFRunLoop::spCallback(CFRunLoopTimerRef iTimer, void* iRefcon) { if (ZRef<ZWorkerRunner_CFRunLoop> theRunner = static_cast<ZWorkerRunner_CFRunLoop*>(iRefcon)) - theRunner->pRunLoopTimerCallBack(); + theRunner->pCallback(); } } // namespace ZooLib Modified: trunk/zoolib/source/cxx/zoolib/ZWorkerRunner_CFRunLoop.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWorkerRunner_CFRunLoop.h 2011-01-02 20:09:05 UTC (rev 1848) +++ trunk/zoolib/source/cxx/zoolib/ZWorkerRunner_CFRunLoop.h 2011-01-03 03:00:34 UTC (rev 1849) @@ -80,8 +80,8 @@ void pWake(ZRef<ZWorker> iWorker, CFAbsoluteTime iAbsoluteTime); void pTrigger(CFAbsoluteTime iAbsoluteTime); - void pRunLoopTimerCallBack(); - static void spRunLoopTimerCallBack(CFRunLoopTimerRef iTimer, void* iRefcon); + void pCallback(); + static void spCallback(CFRunLoopTimerRef iTimer, void* iRefcon); ZRef<CFRunLoopRef> fRunLoop; ZRef<CFRunLoopTimerRef> fRunLoopTimer; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2011-01-28 06:47:49
|
Revision: 1926 http://zoolib.svn.sourceforge.net/zoolib/?rev=1926&view=rev Author: agreen Date: 2011-01-28 06:47:42 +0000 (Fri, 28 Jan 2011) Log Message: ----------- Add ZRA_Transform_PushDownRestricts.h. Handle situations when a Dee (identity) or Dum (null) walker is returned. Some cleanup. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_Dataset.cpp trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_Union.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Search.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.cpp trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Restrict.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Dee.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Difference.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Intersect.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Product.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Restrict.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Union.h trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_ConsolidateRenames.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_Thing.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Util_Strim_Rel.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Util_Strim_RelHead.cpp trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.h trunk/zoolib/source/cxx/zoolib/ZExpr_Bool_ValPred.h trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Op_Do_Transform_T.h Added Paths: ----------- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_PushDownRestricts.cpp trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_PushDownRestricts.h trunk/zoolib/source/cxx/zoolib/ZUtil_Expr_Bool_ValPred_Rename.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_Expr_Bool_ValPred_Rename.h Modified: trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_Dataset.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_Dataset.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_Dataset.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -34,6 +34,7 @@ #include "zoolib/zra/ZRA_Expr_Rel_Concrete.h" #include "zoolib/zra/ZRA_Transform_ConsolidateRenames.h" +#include "zoolib/zra/ZRA_Transform_PushDownRestricts.h" #include "zoolib/zra/ZRA_Util_Strim_Rel.h" namespace ZooLib { @@ -232,6 +233,7 @@ { ZRef<ZRA::Expr_Rel> theRel = iAdded->GetRel(); + theRel = ZRA::Transform_PushDownRestricts().Do(theRel); theRel = ZRA::Transform_ConsolidateRenames().Do(theRel); pair<Map_RelToPSearch::iterator,bool> iterPSearchPair = Modified: trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_Union.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_Union.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_Union.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -41,6 +41,8 @@ #include "zoolib/zra/ZRA_Util_Strim_RelHead.h" #include "zoolib/zra/ZRA_Transform_ConsolidateRenames.h" +#include "zoolib/zra/ZRA_Transform_DecomposeRestricts.h" +#include "zoolib/zra/ZRA_Transform_PushDownRestricts.h" #include "zoolib/zra/ZRA_Transform_Thing.h" namespace ZooLib { @@ -62,7 +64,6 @@ : public virtual ZVisitor_Expr_Op_Do_Transform_T<ZRA::Expr_Rel> , public virtual ZRA::Visitor_Expr_Rel_Concrete { - typedef ZVisitor_Expr_Op_Do_Transform_T<ZRA::Expr_Rel> inherited; public: InsertPrefix(const string8& iPrefix); @@ -158,7 +159,6 @@ class Source_Union::Visitor_Proxy : public virtual ZVisitor_Expr_Op0_T<ZRA::Expr_Rel> { - typedef ZVisitor_Expr_Op0_T<ZRA::Expr_Rel> inherited; public: virtual void Visit_Proxy(const ZRef<Proxy>& iExpr) { this->Visit_Expr_Op0(iExpr); } @@ -327,7 +327,6 @@ , public virtual ZRA::Visitor_Expr_Rel_Concrete , public virtual ZRA::Visitor_Expr_Rel_Const { - typedef ZVisitor_Expr_Op_Do_Transform_T<ZRA::Expr_Rel> inherited; public: Analyze(Source_Union* iSource_Union, PSearch* iPSearch); @@ -657,7 +656,10 @@ ZRA::Util_Strim_Rel::sToStrim(theRel, s); } -#if 1 + theRel = ZRA::Transform_DecomposeRestricts().Do(theRel); + theRel = ZRA::Transform_PushDownRestricts().Do(theRel); +#if 0 + ZRA::Transform_Thing theTT; theRel = theTT.TopLevelDo(theRel); if (ZLOGF(s, eDebug)) @@ -668,13 +670,13 @@ } theRel = ZRA::Transform_ConsolidateRenames().Do(theRel); +#endif if (ZLOGPF(s, eDebug)) { s << "Thingified:\n"; ZRA::Util_Strim_Rel::sToStrim(theRel, s); } -#endif thePSearch->fRel_Analyzed = Analyze(this, thePSearch).TopLevelDo(theRel); fPSearch_NeedsWork.Insert(thePSearch);//?? Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Search.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Search.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Search.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -41,7 +41,7 @@ size_t baseOffset = 0; iWalker = iWalker->Prime(map<string8,size_t>(), offsets, baseOffset); - ZLOGF(s, eDebug); + ZLOGF(s, eDebug + 1); s << "\n"; for (map<string8,size_t>::iterator i = offsets.begin(); i != offsets.end(); ++i) @@ -50,27 +50,30 @@ vector<ZVal_Any> thePackedRows; vector<vector<ZRef<ZCounted> > > theAnnotationsVector; vector<ZVal_Any> theRow(baseOffset, ZVal_Any()); - for (;;) + if (iWalker) { - set<ZRef<ZCounted> > theAnnotations; - if (!iWalker->ReadInc(&theRow[0], &theAnnotations)) - break; - - theAnnotationsVector.push_back( - vector<ZRef<ZCounted> >(theAnnotations.begin(), theAnnotations.end())); - - for (map<string8,size_t>::iterator i = offsets.begin(); i != offsets.end(); ++i) - thePackedRows.push_back(theRow[i->second]); + for (;;) + { + set<ZRef<ZCounted> > theAnnotations; + if (!iWalker->ReadInc(&theRow[0], &theAnnotations)) + break; + + theAnnotationsVector.push_back( + vector<ZRef<ZCounted> >(theAnnotations.begin(), theAnnotations.end())); + + for (map<string8,size_t>::iterator i = offsets.begin(); i != offsets.end(); ++i) + thePackedRows.push_back(theRow[i->second]); - s << "\n"; - for (map<string8,size_t>::iterator i = offsets.begin(); i != offsets.end(); ++i) - { - ZYad_ZooLibStrim::sToStrim(sMakeYadR(theRow[i->second]), s); - s << ", "; + s << "\n"; + for (map<string8,size_t>::iterator i = offsets.begin(); i != offsets.end(); ++i) + { + ZYad_ZooLibStrim::sToStrim(sMakeYadR(theRow[i->second]), s); + s << ", "; + } + + if (int theAnnoCount = theAnnotations.size()) + s << "annotations: " << theAnnoCount; } - - if (int theAnnoCount = theAnnotations.size()) - s << "annotations: " << theAnnoCount; } s << "\n"; Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Embed.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -80,6 +80,9 @@ return false; fExhausted = true; + if (!fWalker_Child) + return false; + fWalker_Child->Rewind(); vector<ZVal_Any> thePackedRows; Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Product.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -18,6 +18,7 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------------------------- */ +#include "zoolib/zqe/ZQE_Walker_Dee.h" #include "zoolib/zqe/ZQE_Walker_Product.h" namespace ZooLib { @@ -52,6 +53,11 @@ size_t& ioBaseOffset) { fWalker_Left = fWalker_Left->Prime(iOffsets, fLeftOffsets, ioBaseOffset); + if (!fWalker_Left) + return null; + + // Could also check for Walker_Dee. + fResults_Left.resize(ioBaseOffset); oOffsets.insert(fLeftOffsets.begin(), fLeftOffsets.end()); @@ -59,7 +65,14 @@ combined.insert(fLeftOffsets.begin(), fLeftOffsets.end()); fWalker_Right = fWalker_Right->Prime(combined, oOffsets, ioBaseOffset); + if (!fWalker_Right) + return null; + if (fWalker_Left.DynamicCast<Walker_Dee>()) + return fWalker_Right; + else if (fWalker_Right.DynamicCast<Walker_Dee>()) + return fWalker_Left; + return this; } Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Project.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -52,6 +52,8 @@ { map<string8,size_t> childOffsets; fWalker = fWalker->Prime(iOffsets, childOffsets, ioBaseOffset); + if (!fWalker) + return null; for (ZRA::RelHead::iterator i = fRelHead.begin(); i != fRelHead.end(); ++i) { Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Rename.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -52,6 +52,8 @@ newBindingOffsets[fOld] = theQ.Get(); fWalker = fWalker->Prime(newBindingOffsets, oOffsets, ioBaseOffset); + if (!fWalker) + return null; sInsertMustNotContain(1, oOffsets, fNew, sEraseAndReturn(1, oOffsets, fOld)); Modified: trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Restrict.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Restrict.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zqe/ZQE_Walker_Restrict.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -49,6 +49,8 @@ size_t& ioBaseOffset) { fWalker = fWalker->Prime(iOffsets, fChildOffsets, ioBaseOffset); + if (!fWalker) + return null; oOffsets.insert(fChildOffsets.begin(), fChildOffsets.end()); fChildOffsets.insert(iOffsets.begin(), iOffsets.end()); return this; @@ -78,10 +80,11 @@ theMap.Set(theName, theVal); } -#if 0 - if (ZLOGF(s, eDebug)) + if (ZLOGF(s, eDebug+2)) + { + s << this << " "; ZYad_ZooLibStrim::sToStrim(sMakeYadR(theMap), s); -#endif + } if (sMatches(fExpr_Bool, theMap)) { Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -22,15 +22,14 @@ #include "zoolib/ZStrim_Escaped.h" #include "zoolib/ZString.h" #include "zoolib/ZUtil_Any.h" +#include "zoolib/ZUtil_Expr_Bool_ValPred_Rename.h" #include "zoolib/ZUtil_Strim.h" #include "zoolib/ZUtil_STL_map.h" #include "zoolib/ZVisitor_Do_T.h" #include "zoolib/ZVisitor_Expr_Bool_ValPred_Any_ToStrim.h" #include "zoolib/ZVisitor_Expr_Op_Do_Transform_T.h" #include "zoolib/ZValPred_Any.h" -#include "zoolib/ZValPred_Rename.h" - #include "zoolib/zra/ZRA_AsSQL.h" #include "zoolib/zra/ZRA_Expr_Rel_Concrete.h" #include "zoolib/zra/ZRA_Expr_Rel_Product.h" @@ -49,33 +48,7 @@ using std::set; using std::string; -// ================================================================================================= -#pragma mark - -#pragma mark * DoRename (anonymous) -namespace { // anonymous - -class DoRename -: public virtual ZVisitor_Expr_Op_Do_Transform_T<ZExpr_Bool> -, public virtual ZVisitor_Expr_Bool_ValPred - { -public: - DoRename(const Rename& iRename); - - virtual void Visit_Expr_Bool_ValPred(const ZRef<ZExpr_Bool_ValPred>& iExpr); -private: - const Rename& fRename; - }; - -DoRename::DoRename(const Rename& iRename) -: fRename(iRename) - {} - -void DoRename::Visit_Expr_Bool_ValPred(const ZRef<ZExpr_Bool_ValPred>& iExpr) - { this->pSetResult(new ZExpr_Bool_ValPred(sRenamed(fRename, iExpr->GetValPred()))); } - -} // anonymous namespace - // ================================================================================================= #pragma mark - #pragma mark * Analysis (anonymous) @@ -181,7 +154,7 @@ void Analyzer::Visit_Expr_Rel_Restrict(const ZRef<Expr_Rel_Restrict>& iExpr) { Analysis theAnalysis = this->Do(iExpr->GetOp0()); - theAnalysis.fCondition &= DoRename(theAnalysis.fRename).Do(iExpr->GetExpr_Bool()); + theAnalysis.fCondition &= Util_Expr_Bool::sRenamed(theAnalysis.fRename, iExpr->GetExpr_Bool()); this->pSetResult(theAnalysis); } Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Calc.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -79,7 +79,6 @@ class Visitor_Expr_Rel_Calc : public virtual ZVisitor_Expr_Op0_T<Expr_Rel> { - typedef ZVisitor_Expr_Op0_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Calc(const ZRef<Expr_Rel_Calc>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Concrete.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -69,7 +69,6 @@ class Visitor_Expr_Rel_Concrete : public virtual ZVisitor_Expr_Op0_T<Expr_Rel> { - typedef ZVisitor_Expr_Op0_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Concrete(const ZRef<Expr_Rel_Concrete>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Const.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -72,7 +72,6 @@ class Visitor_Expr_Rel_Const : public virtual ZVisitor_Expr_Op0_T<Expr_Rel> { - typedef ZVisitor_Expr_Op0_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Const(const ZRef<Expr_Rel_Const>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Dee.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Dee.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Dee.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -66,7 +66,6 @@ class Visitor_Expr_Rel_Dee : public virtual ZVisitor_Expr_Op0_T<Expr_Rel> { - typedef ZVisitor_Expr_Op0_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Dee(const ZRef<Expr_Rel_Dee>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Difference.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Difference.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Difference.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -59,7 +59,6 @@ class Visitor_Expr_Rel_Difference : public virtual ZVisitor_Expr_Op2_T<Expr_Rel> { - typedef ZVisitor_Expr_Op2_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Difference(const ZRef<Expr_Rel_Difference>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Embed.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -70,7 +70,6 @@ class Visitor_Expr_Rel_Embed : public virtual ZVisitor_Expr_Op1_T<Expr_Rel> { - typedef ZVisitor_Expr_Op1_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Embed(const ZRef<Expr_Rel_Embed>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Intersect.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Intersect.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Intersect.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -59,7 +59,6 @@ class Visitor_Expr_Rel_Intersect : public virtual ZVisitor_Expr_Op2_T<Expr_Rel> { - typedef ZVisitor_Expr_Op2_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Intersect(const ZRef<Expr_Rel_Intersect>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Product.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Product.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Product.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -62,7 +62,6 @@ class Visitor_Expr_Rel_Product : public virtual ZVisitor_Expr_Op2_T<Expr_Rel> { - typedef ZVisitor_Expr_Op2_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Product(const ZRef<Expr_Rel_Product>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Project.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -69,7 +69,6 @@ class Visitor_Expr_Rel_Project : public virtual ZVisitor_Expr_Op1_T<Expr_Rel> { - typedef ZVisitor_Expr_Op1_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Project(const ZRef<Expr_Rel_Project>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Rename.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -72,7 +72,6 @@ class Visitor_Expr_Rel_Rename : public virtual ZVisitor_Expr_Op1_T<Expr_Rel> { - typedef ZVisitor_Expr_Op1_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Rename(const ZRef<Expr_Rel_Rename>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Restrict.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Restrict.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Restrict.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -69,7 +69,6 @@ class Visitor_Expr_Rel_Restrict : public virtual ZVisitor_Expr_Op1_T<Expr_Rel> { - typedef ZVisitor_Expr_Op1_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Restrict(const ZRef<Expr_Rel_Restrict>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Union.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Union.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Expr_Rel_Union.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -59,7 +59,6 @@ class Visitor_Expr_Rel_Union : public virtual ZVisitor_Expr_Op2_T<Expr_Rel> { - typedef ZVisitor_Expr_Op2_T<Expr_Rel> inherited; public: virtual void Visit_Expr_Rel_Union(const ZRef<Expr_Rel_Union>& iExpr); }; Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_ConsolidateRenames.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_ConsolidateRenames.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_ConsolidateRenames.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -53,7 +53,6 @@ ZRef<Expr_Rel> oldOp0 = iExpr->GetOp0(); const string8 oldName = iExpr->GetOld(); string8 newName = iExpr->GetNew(); - if (ZQ<string8> theQ = sEraseAndReturnIfContains(fRename, newName)) newName = theQ.Get(); @@ -64,9 +63,11 @@ if (ZQ<string8> theQ2 = sGetIfContains(fRename, oldName)) { if (theQ2.Get() == newName) - newOp0 = sRename(newOp0, newName, oldName); + { + if (newName != oldName) + newOp0 = sRename(newOp0, newName, oldName); + } } - this->pSetResult(newOp0); } Added: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_PushDownRestricts.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_PushDownRestricts.cpp (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_PushDownRestricts.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -0,0 +1,147 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2011 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZUtil_Expr_Bool_ValPred_Rename.h" +//#include "zoolib/ZUtil_STL_map.h" +#include "zoolib/ZVisitor_Expr_Bool_ValPred_Do_GetNames.h" + +#include "zoolib/zra/ZRA_Transform_PushDownRestricts.h" + +namespace ZooLib { +namespace ZRA { + +using std::vector; + +// ================================================================================================= +#pragma mark - +#pragma mark * Transform_PushDownRestricts + +void Transform_PushDownRestricts::Visit_Expr_Rel_Rename(const ZRef<Expr_Rel_Rename>& iExpr) + { + const RelName& oldName = iExpr->GetOld(); + const RelName& newName = iExpr->GetNew(); + + Rename new2Old; + new2Old[newName] = oldName; + + for (vector<Restrict*>::iterator iter = fRestricts.begin(); iter != fRestricts.end(); ++iter) + (*iter)->fExpr_Bool = Util_Expr_Bool::sRenamed(new2Old, (*iter)->fExpr_Bool); + + Visitor_Expr_Rel_Rename::Visit_Expr_Rel_Rename(iExpr); + + Rename old2New; + old2New[oldName] = newName; + + for (vector<Restrict*>::iterator iter = fRestricts.begin(); iter != fRestricts.end(); ++iter) + (*iter)->fExpr_Bool = Util_Expr_Bool::sRenamed(old2New, (*iter)->fExpr_Bool); + + } + +void Transform_PushDownRestricts::Visit_Expr_Rel_Embed(const ZRef<Expr_Rel_Embed>& iExpr) + { + ZRef<Expr_Rel> oldOp0 = iExpr->GetOp0(); + ZRef<Expr_Rel> newOp0; + + { + ZSetRestore_T<vector<Restrict*> > sr(fRestricts); + newOp0 = this->Do(oldOp0); + } + + if (oldOp0 == newOp0) + this->pHandleIt(iExpr->GetRelName(), iExpr); + else + this->pHandleIt(iExpr->GetRelName(), iExpr->Clone(newOp0)); + } + +void Transform_PushDownRestricts::Visit_Expr_Rel_Restrict(const ZRef<Expr_Rel_Restrict>& iExpr) + { + Restrict theRestrict; + theRestrict.fExpr_Bool = iExpr->GetExpr_Bool(); + theRestrict.fCountTouching = 0; + theRestrict.fCountSubsuming = 0; + fRestricts.push_back(&theRestrict); + + ZRef<Expr_Rel> oldOp0 = iExpr->GetOp0(); + ZRef<Expr_Rel> newOp0 = this->Do(oldOp0); + + ZAssertStop(1, fRestricts.back() == &theRestrict); + fRestricts.pop_back(); + + if (theRestrict.fCountTouching == 0) + { + // Superfluous condition? Should have been pulled up the tree + // and then possibly excised. Or we should return null, as nothing can + // satisfy the criteria. + this->pSetResult(oldOp0); + } + else if (theRestrict.fCountTouching == theRestrict.fCountSubsuming) + { + // Every descendant that touches the restriction handles it completely + // and we can drop this restriction out of the tree. + this->pSetResult(newOp0); + } + else + { + // Descendants may have added our restriction into the + // tree, but they didn't all do so. + if (newOp0 == oldOp0) + { + // No changes in our descendants at all. + this->pSetResult(iExpr->Self()); + } + else + { + this->pSetResult(iExpr->Clone(newOp0)); + } + } + } + +void Transform_PushDownRestricts::Visit_Expr_Rel_Calc(const ZRef<Expr_Rel_Calc>& iExpr) + { this->pHandleIt(iExpr->GetRelName(), iExpr); } + +void Transform_PushDownRestricts::Visit_Expr_Rel_Concrete(const ZRef<Expr_Rel_Concrete>& iExpr) + { this->pHandleIt(iExpr->GetConcreteRelHead(), iExpr); } + +void Transform_PushDownRestricts::Visit_Expr_Rel_Const(const ZRef<Expr_Rel_Const>& iExpr) + { this->pHandleIt(iExpr->GetRelName(), iExpr); } + +void Transform_PushDownRestricts::pHandleIt(const RelHead& iRH, const ZRef<Expr_Rel>& iExpr) + { + ZRef<Expr_Rel> result = iExpr; + for (vector<Restrict*>::iterator iter = fRestricts.begin(); iter != fRestricts.end(); ++iter) + { + Restrict& theRestrict = **iter; + const RelHead exprNames = sGetNames(theRestrict.fExpr_Bool); + const RelHead intersection = exprNames & iRH; + if (intersection.size()) + { + ++theRestrict.fCountTouching; + if (intersection.size() == exprNames.size()) + { + ++theRestrict.fCountSubsuming; + result = result & theRestrict.fExpr_Bool; + } + } + } + this->pSetResult(result); + } + +} // namespace ZRA +} // namespace ZooLib Added: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_PushDownRestricts.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_PushDownRestricts.h (rev 0) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_PushDownRestricts.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2011 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZRA_Transform_PushDownRestricts__ +#define __ZRA_Transform_PushDownRestricts__ +#include "zconfig.h" + +#include "zoolib/ZVisitor_Expr_Op_Do_Transform_T.h" +#include "zoolib/zra/ZRA_Expr_Rel_Calc.h" +#include "zoolib/zra/ZRA_Expr_Rel_Concrete.h" +#include "zoolib/zra/ZRA_Expr_Rel_Const.h" +#include "zoolib/zra/ZRA_Expr_Rel_Embed.h" +#include "zoolib/zra/ZRA_Expr_Rel_Rename.h" +#include "zoolib/zra/ZRA_Expr_Rel_Restrict.h" + +#include <vector> + +namespace ZooLib { +namespace ZRA { + +// ================================================================================================= +#pragma mark - +#pragma mark * ZRA::Transform_PushDownRestricts + +class Transform_PushDownRestricts +: public virtual ZVisitor_Expr_Op_Do_Transform_T<Expr_Rel> +, public virtual Visitor_Expr_Rel_Rename +, public virtual Visitor_Expr_Rel_Restrict +, public virtual Visitor_Expr_Rel_Embed +, public virtual Visitor_Expr_Rel_Calc +, public virtual Visitor_Expr_Rel_Concrete +, public virtual Visitor_Expr_Rel_Const + { +public: +// From Visitor_Expr_Rel_XXX + virtual void Visit_Expr_Rel_Embed(const ZRef<Expr_Rel_Embed>& iExpr); + virtual void Visit_Expr_Rel_Rename(const ZRef<Expr_Rel_Rename>& iExpr); + virtual void Visit_Expr_Rel_Restrict(const ZRef<Expr_Rel_Restrict>& iExpr); + + virtual void Visit_Expr_Rel_Calc(const ZRef<Expr_Rel_Calc>& iExpr); + virtual void Visit_Expr_Rel_Concrete(const ZRef<Expr_Rel_Concrete>& iExpr); + virtual void Visit_Expr_Rel_Const(const ZRef<Expr_Rel_Const>& iExpr); + +protected: + void pHandleIt(const RelHead& iRH, const ZRef<Expr_Rel>& iRel); + + struct Restrict + { + ZRef<ZExpr_Bool> fExpr_Bool; + size_t fCountTouching; + size_t fCountSubsuming; + }; + std::vector<Restrict*> fRestricts; + }; + +} // namespace ZRA +} // namespace ZooLib + +#endif // __ZRA_Transform_PushDownRestricts__ Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_Thing.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_Thing.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Transform_Thing.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -18,11 +18,9 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------------------------- */ -#include "zoolib/ZExpr_Bool_ValPred.h" #include "zoolib/ZString.h" +#include "zoolib/ZUtil_Expr_Bool_ValPred_Rename.h" #include "zoolib/ZUtil_STL_map.h" -#include "zoolib/ZValPred_Rename.h" -#include "zoolib/ZVisitor_Expr_Op_Do_Transform_T.h" #include "zoolib/zra/ZRA_Transform_Thing.h" @@ -35,33 +33,6 @@ // ================================================================================================= #pragma mark - -#pragma mark * DoRename (anonymous) - -namespace { // anonymous - -class DoRename -: public virtual ZVisitor_Expr_Op_Do_Transform_T<ZExpr_Bool> -, public virtual ZVisitor_Expr_Bool_ValPred - { -public: - DoRename(const Rename& iRename); - - virtual void Visit_Expr_Bool_ValPred(const ZRef<ZExpr_Bool_ValPred>& iExpr); -private: - const Rename& fRename; - }; - -DoRename::DoRename(const Rename& iRename) -: fRename(iRename) - {} - -void DoRename::Visit_Expr_Bool_ValPred(const ZRef<ZExpr_Bool_ValPred>& iExpr) - { this->pSetResult(new ZExpr_Bool_ValPred(sRenamed(fRename, iExpr->GetValPred()))); } - -} // anonymous namespace - -// ================================================================================================= -#pragma mark - #pragma mark * Transform_Thing Transform_Thing::Transform_Thing() @@ -160,7 +131,8 @@ { ZRef<Expr_Rel> newOp0 = this->Do(iExpr->GetOp0()); - ZRef<ZExpr_Bool> newExpr_Bool = DoRename(fRename_Concrete2Temp).Do(iExpr->GetExpr_Bool()); + ZRef<ZExpr_Bool> newExpr_Bool = + Util_Expr_Bool::sRenamed(fRename_Concrete2Temp, iExpr->GetExpr_Bool()); this->pSetResult(sRestrict(newOp0, newExpr_Bool)); } Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Util_Strim_Rel.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Util_Strim_Rel.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Util_Strim_Rel.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -46,30 +46,6 @@ // ================================================================================================= #pragma mark - -#pragma mark * Static helpers - -namespace { // anonymous - -void spWrite(const string& iString, const ZStrimW& s) - { s.Write(iString); } - -void spWrite(const UTF8* iString, const ZStrimW& s) - { s.Write(iString); } - -void spWrite_RelHead(const RelHead& iRelHead, const ZStrimW& iStrimW) - { Util_Strim_RelHead::sWrite_RelHead(iRelHead, iStrimW); } - -void spWrite_EffectiveRelHeadComment(ZRef<Expr_Rel> iExpr, const ZStrimW& iStrimW) - { - iStrimW.Write(" /*"); - Util_Strim_RelHead::sWrite_RelHead(sGetRelHead(iExpr), iStrimW); - iStrimW.Write("*/"); - } - -} // anonymous namespace - -// ================================================================================================= -#pragma mark - #pragma mark * Visitor_ToStrim namespace { // anonymous @@ -126,120 +102,63 @@ void Visitor_ToStrim::Visit_Expr_Rel_Embed(const ZRef<Expr_Rel_Embed>& iExpr) { const ZStrimW& w = pStrimW(); - w << "Embed"; - - if (pOptions().fDebuggingOutput) - spWrite_EffectiveRelHeadComment(iExpr->Self(), w); - -// this->pWriteLFIndent(); - w << "("; - + w << "Embed("; Util_Strim_RelHead::sWrite_PropName(iExpr->GetRelName(), w); - w << ", "; - w << iExpr->GetBindings(); - w << ","; + w << ", " << iExpr->GetBindings() << ","; this->pWriteLFIndent(); this->pToStrim(iExpr->GetOp0()); -//## this->pWriteLFIndent(); w << ")"; } void Visitor_ToStrim::Visit_Expr_Rel_Project(const ZRef<Expr_Rel_Project>& iExpr) { const ZStrimW& w = pStrimW(); - spWrite("Project", w); - -// if (pOptions().fDebuggingOutput) -// spWrite_EffectiveRelHeadComment(iExpr, w); - -// this->pWriteLFIndent(); - w << "("; - -// this->pWriteLFIndent(); - spWrite_RelHead(iExpr->GetProjectRelHead(), w); - w << ","; - + w << "Project(" << iExpr->GetProjectRelHead() << ","; this->pWriteLFIndent(); this->pToStrim(iExpr->GetOp0()); - -//## this->pWriteLFIndent(); w << ")"; } void Visitor_ToStrim::Visit_Expr_Rel_Rename(const ZRef<Expr_Rel_Rename>& iExpr) { const ZStrimW& w = pStrimW(); - spWrite("Rename", w); - -// if (pOptions().fDebuggingOutput) -// spWrite_EffectiveRelHeadComment(iExpr, w); - -// this->pWriteLFIndent(); - w << "("; - -// this->pWriteLFIndent(); + w << "Rename("; Util_Strim_RelHead::sWrite_PropName(iExpr->GetNew(), w); - spWrite("<--", w); + w << "<--"; Util_Strim_RelHead::sWrite_PropName(iExpr->GetOld(), w); w << ","; - this->pWriteLFIndent(); this->pToStrim(iExpr->GetOp0()); - -//## this->pWriteLFIndent(); w << ")"; } void Visitor_ToStrim::Visit_Expr_Rel_Restrict(const ZRef<Expr_Rel_Restrict>& iExpr) { const ZStrimW& w = pStrimW(); - w << "Restrict"; - - if (pOptions().fDebuggingOutput) - spWrite_EffectiveRelHeadComment(iExpr, w); - -// this->pWriteLFIndent(); - w << "("; -// this->pWriteLFIndent(); + w << "Restrict("; this->pToStrim(iExpr->GetExpr_Bool()); w << ","; - this->pWriteLFIndent(); this->pToStrim(iExpr->GetOp0()); - -//## this->pWriteLFIndent(); w << ")"; } void Visitor_ToStrim::Visit_Expr_Rel_Calc(const ZRef<Expr_Rel_Calc>& iExpr) { const ZStrimW& w = pStrimW(); - spWrite("Calc", w); - - w << "("; + w << "Calc("; Util_Strim_RelHead::sWrite_PropName(iExpr->GetRelName(), w); - w << "<--"; - - w << "/*Some function of*/ "; - w << iExpr->GetBindings(); -// Util_Strim_RelHead::sWrite_RelHead(iExpr->GetBindings(), w); + w << " = /*Some function of*/ " << iExpr->GetBindings(); w << ")"; } void Visitor_ToStrim::Visit_Expr_Rel_Concrete(const ZRef<Expr_Rel_Concrete>& iExpr) - { - const ZStrimW& w = pStrimW(); + { pStrimW() << "Concrete(" << iExpr->GetConcreteRelHead() << ")"; } - w << "Concrete("; - Util_Strim_RelHead::sWrite_RelHead(iExpr->GetConcreteRelHead(), w); - w << ")"; - } - void Visitor_ToStrim::Visit_Expr_Rel_Const(const ZRef<Expr_Rel_Const>& iExpr) { const ZStrimW& w = pStrimW(); - spWrite("Const", w); - w << "("; + w << "Const("; Util_Strim_RelHead::sWrite_PropName(iExpr->GetRelName(), w); w << ","; ZYad_ZooLibStrim::sToStrim(sMakeYadR(iExpr->GetVal()), w); @@ -247,37 +166,25 @@ } void Visitor_ToStrim::Visit_Expr_Rel_Dee(const ZRef<Expr_Rel_Dee>& iExpr) - { - const ZStrimW& w = pStrimW(); - w << "Dee()"; - } + { pStrimW() << "Dee()"; } void Visitor_ToStrim::pWriteBinary( const string& iFunctionName, const ZRef<ZExpr_Op2_T<Expr_Rel> >& iExpr) { const ZStrimW& w = pStrimW(); - w << iFunctionName; + w << iFunctionName << "("; - if (pOptions().fDebuggingOutput) - spWrite_EffectiveRelHeadComment(iExpr->Self(), w); - -// this->pWriteLFIndent(); - w << "("; - this->pWriteLFIndent(); this->pToStrim(iExpr->GetOp0()); w << ","; - this->pWriteLFIndent(); this->pToStrim(iExpr->GetOp1()); - -//## this->pWriteLFIndent(); w << ")"; } // ================================================================================================= #pragma mark - -#pragma mark * ZUtil_Strim_TQL +#pragma mark * ZRA_Util_Strim_Rel void sToStrim(const ZRef<ZRA::Expr_Rel>& iRel, const ZStrimW& iStrimW) { Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Util_Strim_RelHead.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Util_Strim_RelHead.cpp 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_Util_Strim_RelHead.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -65,6 +65,7 @@ const ZStrimW& operator<<(const ZStrimW& w, const ZRA::Rename& iRename) { + w << "["; bool isFirst = true; for (ZRA::Rename::const_iterator i = iRename.begin(); i != iRename.end(); ++i) { @@ -73,6 +74,7 @@ isFirst = false; w << i->second << "<--" << i->first; } + w << "]"; return w; } Modified: trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Bool.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -77,7 +77,6 @@ class ZVisitor_Expr_Bool_True : public virtual ZVisitor_Expr_Op0_T<ZExpr_Bool> { - typedef ZVisitor_Expr_Op0_T<ZExpr_Bool> inherited; public: virtual void Visit_Expr_Bool_True(const ZRef<ZExpr_Bool_True>& iExpr); }; @@ -123,7 +122,6 @@ class ZVisitor_Expr_Bool_False : public virtual ZVisitor_Expr_Op0_T<ZExpr_Bool> { - typedef ZVisitor_Expr_Op0_T<ZExpr_Bool> inherited; public: virtual void Visit_Expr_Bool_False(const ZRef<ZExpr_Bool_False>& iExpr); }; @@ -165,7 +163,6 @@ class ZVisitor_Expr_Bool_Not : public virtual ZVisitor_Expr_Op1_T<ZExpr_Bool> { - typedef ZVisitor_Expr_Op1_T<ZExpr_Bool> inherited; public: virtual void Visit_Expr_Bool_Not(const ZRef<ZExpr_Bool_Not>& iExpr); }; @@ -207,7 +204,6 @@ class ZVisitor_Expr_Bool_And : public virtual ZVisitor_Expr_Op2_T<ZExpr_Bool> { - typedef ZVisitor_Expr_Op2_T<ZExpr_Bool> inherited; public: virtual void Visit_Expr_Bool_And(const ZRef<ZExpr_Bool_And>& iExpr); }; @@ -249,7 +245,6 @@ class ZVisitor_Expr_Bool_Or : public virtual ZVisitor_Expr_Op2_T<ZExpr_Bool> { - typedef ZVisitor_Expr_Op2_T<ZExpr_Bool> inherited; public: virtual void Visit_Expr_Bool_Or(const ZRef<ZExpr_Bool_Or>& iExpr); }; Modified: trunk/zoolib/source/cxx/zoolib/ZExpr_Bool_ValPred.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZExpr_Bool_ValPred.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/zoolib/ZExpr_Bool_ValPred.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -70,7 +70,6 @@ class ZVisitor_Expr_Bool_ValPred : public virtual ZVisitor_Expr_Op0_T<ZExpr_Bool> { - typedef ZVisitor_Expr_Op0_T<ZExpr_Bool> inherited; public: virtual void Visit_Expr_Bool_ValPred(const ZRef<ZExpr_Bool_ValPred >& iExpr); }; Added: trunk/zoolib/source/cxx/zoolib/ZUtil_Expr_Bool_ValPred_Rename.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Expr_Bool_ValPred_Rename.cpp (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Expr_Bool_ValPred_Rename.cpp 2011-01-28 06:47:42 UTC (rev 1926) @@ -0,0 +1,68 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2011 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZExpr_Bool_ValPred.h" +#include "zoolib/ZUtil_Expr_Bool_ValPred_Rename.h" +#include "zoolib/ZValPred_Rename.h" +#include "zoolib/ZVisitor_Expr_Op_Do_Transform_T.h" + +using std::map; +using std::string; + +namespace ZooLib { +namespace Util_Expr_Bool { + +// ================================================================================================= +#pragma mark - +#pragma mark * DoRename (anonymous) + +namespace { // anonymous + +class DoRename +: public virtual ZVisitor_Expr_Op_Do_Transform_T<ZExpr_Bool> +, public virtual ZVisitor_Expr_Bool_ValPred + { +public: + DoRename(const map<string,string>& iRename); + + virtual void Visit_Expr_Bool_ValPred(const ZRef<ZExpr_Bool_ValPred>& iExpr); +private: + const map<string,string>& fRename; + }; + +DoRename::DoRename(const map<string,string>& iRename) +: fRename(iRename) + {} + +void DoRename::Visit_Expr_Bool_ValPred(const ZRef<ZExpr_Bool_ValPred>& iExpr) + { this->pSetResult(new ZExpr_Bool_ValPred(sRenamed(fRename, iExpr->GetValPred()))); } + +} // anonymous namespace + +// ================================================================================================= +#pragma mark - +#pragma mark * Util_Expr_Bool + +ZRef<ZExpr_Bool> sRenamed(const std::map<std::string,std::string>& iRename, + const ZRef<ZExpr_Bool>& iExpr) + { return DoRename(iRename).Do(iExpr); } + +} // namespace Util_Expr_Bool +} // namespace ZooLib Added: trunk/zoolib/source/cxx/zoolib/ZUtil_Expr_Bool_ValPred_Rename.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Expr_Bool_ValPred_Rename.h (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Expr_Bool_ValPred_Rename.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -0,0 +1,42 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2011 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZUtil_Expr_Bool_ValPred_Rename__ +#define __ZUtil_Expr_Bool_ValPred_Rename__ +#include "zconfig.h" + +#include "zoolib/ZExpr_Bool.h" + +#include <map> + +namespace ZooLib { +namespace Util_Expr_Bool { + +// ================================================================================================= +#pragma mark - +#pragma mark * Util_Expr_Bool + +ZRef<ZExpr_Bool> sRenamed(const std::map<std::string,std::string>& iRename, + const ZRef<ZExpr_Bool>& iExpr); + +} // namespace Util_Expr_Bool +} // namespace ZooLib + +#endif // __ZUtil_Expr_Bool_ValPred_Rename__ Modified: trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Op_Do_Transform_T.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Op_Do_Transform_T.h 2011-01-27 22:47:55 UTC (rev 1925) +++ trunk/zoolib/source/cxx/zoolib/ZVisitor_Expr_Op_Do_Transform_T.h 2011-01-28 06:47:42 UTC (rev 1926) @@ -39,9 +39,11 @@ , public virtual ZVisitor_Expr_Op2_T<T> { public: +// From ZVisitor_Expr_Op0_T virtual void Visit_Expr_Op0(const ZRef<ZExpr_Op0_T<T> >& iExpr) { this->pSetResult(iExpr->Self()); } +// From ZVisitor_Expr_Op1_T virtual void Visit_Expr_Op1(const ZRef<ZExpr_Op1_T<T> >& iExpr) { ZRef<T> oldOp0 = iExpr->GetOp0(); @@ -52,6 +54,7 @@ this->pSetResult(iExpr->Clone(newOp0)); } +// From ZVisitor_Expr_Op2_T virtual void Visit_Expr_Op2(const ZRef<ZExpr_Op2_T<T> >& iExpr) { ZRef<T> oldOp0 = iExpr->GetOp0(); @@ -63,6 +66,7 @@ else this->pSetResult(iExpr->Clone(newOp0, newOp1)); } + }; } // namespace ZooLib This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2011-07-24 03:58:13
|
Revision: 2424 http://zoolib.svn.sourceforge.net/zoolib/?rev=2424&view=rev Author: agreen Date: 2011-07-24 03:58:05 +0000 (Sun, 24 Jul 2011) Log Message: ----------- Move into old. Added Paths: ----------- trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.h trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLib.cpp trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLib.h trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStream.cpp trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStream.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.cpp trunk/zoolib/source/cxx/zoolib/ZVal_ZooLib.h trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.cpp trunk/zoolib/source/cxx/zoolib/ZYad_ZooLib.h trunk/zoolib/source/cxx/zoolib/ZYad_ZooLibStream.cpp trunk/zoolib/source/cxx/zoolib/ZYad_ZooLibStream.h Added: trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp (rev 0) +++ trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp 2011-07-24 03:58:05 UTC (rev 2424) @@ -0,0 +1,2580 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2009 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZCompare_Vector.h" +#include "zoolib/ZMemory.h" +#include "zoolib/ZStream_Data_T.h" +#include "zoolib/ZVal_ZooLib.h" + +#include "zoolib/ZDebug.h" +#include "zoolib/ZLog.h" + +#include <map> +#include <string.h> +#include <typeinfo> + +using std::map; +using std::min; +using std::pair; +using std::string; +using std::type_info; +using std::vector; + +#define kDebug_Tuple 1 + +namespace ZooLib { + +static ZTName spNilName; +static ZMap_ZooLib::PropList spEmptyProperties; +static ZVal_ZooLib spNilVal; +static ZSeq_ZooLib spNilSeq; +static vector<ZVal_ZooLib> spNilVector; + +// ================================================================================================= + +/** +Provides standard textual versions of ZType values. +*/ +static const char* const spZTypeAsString[eZType_Max] = + { + "Null", + "String", + "!!NOTVALID!!", // Needed to maintain correct offsets. + "Int8", + "Int16", + "Int32", + "Int64", + "Float", + "Double", + "Bool", + "Pointer", + "Raw", + "Tuple", + "RefCounted", + "Rect", + "Point", + "Region", + "ID", + "Vector", + "Type", + "Time", +//## "Name" + }; + +const char* ZTypeAsString(ZType iType) + { + if (iType <= eZType_Time) + return spZTypeAsString[iType]; + return "Unknown"; + } + +// ================================================================================================= +#pragma mark - +#pragma mark * Helper functions + +static inline bool spIsSpecialString(size_t iSize) + { return iSize <= ZVal_ZooLib::kBytesSize; } + +// ================================================================================================= +#pragma mark - +#pragma mark * ValString + +namespace { // anonymous + +/** ValString is a lighterweight implementation of immutable strings, used +for holding longer string properties in ZVal_ZooLib instances. */ + +class ValString + { + ValString(); // Not implemented + ValString& operator=(const ValString&); // Not implemented + +public: + ~ValString(); + + ValString(const ValString& iOther); + + explicit ValString(const string& iOther); + + ValString(const char* iString, size_t iLength); + + ValString(const ZStreamR& iStreamR, size_t iSize); + + int Compare(const ValString& iOther) const; + + int Compare(const char* iString, size_t iSize) const; + + int Compare(const string& iString) const; + + bool Empty() const; + + void ToStream(const ZStreamW& iStreamW) const; + + void ToString(string& oString) const; + + string AsString() const; + +private: + const size_t fSize; + char* fBuffer; + }; + +} // anonymous namespace + +inline ValString::~ValString() + { delete[] fBuffer; } + +inline bool ValString::Empty() const + { return !fSize; } + +inline string ValString::AsString() const + { return string(fBuffer, fSize); } + +ValString::ValString(const ValString& iOther) +: fSize(iOther.fSize) + { + fBuffer = new char[fSize]; + ZMemCopy(fBuffer, iOther.fBuffer, fSize); + } + +ValString::ValString(const string& iOther) +: fSize(iOther.size()) + { + fBuffer = new char[fSize]; + if (fSize) + ZMemCopy(fBuffer, iOther.data(), fSize); + } + +ValString::ValString(const char* iString, size_t iLength) +: fSize(iLength) + { + fBuffer = new char[fSize]; + ZMemCopy(fBuffer, iString, fSize); + } + +ValString::ValString(const ZStreamR& iStreamR, size_t iSize) +: fSize(iSize) + { + fBuffer = new char[iSize]; + try + { + iStreamR.Read(fBuffer, iSize); + } + catch (...) + { + delete fBuffer; + throw; + } + } + +inline int ValString::Compare(const ValString& iOther) const + { return ZMemCompare(fBuffer, fSize, iOther.fBuffer, iOther.fSize); } + +inline int ValString::Compare(const char* iString, size_t iSize) const + { return ZMemCompare(fBuffer, fSize, iString, iSize); } + +inline int ValString::Compare(const string& iString) const + { + if (size_t otherSize = iString.size()) + return ZMemCompare(fBuffer, fSize, iString.data(), otherSize); + + // iString is empty. If fSize is zero, then fSize!=0 is true, and + // will convert to 1. Otherwise it will be false, and convert + // to zero, so we always return the correct result. + return fSize != 0; + } + +void ValString::ToStream(const ZStreamW& iStreamW) const + { + iStreamW.WriteCount(fSize); + iStreamW.Write(fBuffer, fSize); + } + +void ValString::ToString(string& oString) const + { + oString.resize(fSize); + if (fSize) + ZMemCopy(const_cast<char*>(oString.data()), fBuffer, fSize); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZVal_ZooLib::Ex_IllegalType + +ZVal_ZooLib::Ex_IllegalType::Ex_IllegalType(int iType) +: runtime_error("Ex_IllegalType"), + fType(iType) + {} + +// ================================================================================================= +#pragma mark - +#pragma mark * ZVal_ZooLib + +/** \class ZVal_ZooLib +\nosubgrouping +*/ + +bool ZVal_ZooLib::sQFromAny(const ZAny& iAny, ZVal_ZooLib& oVal) + { + if (false) + {} + else if (not iAny) + { + oVal = ZVal_ZooLib(); + } + else if (const string* theValue = iAny.PGet<string>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const ZType* theValue = iAny.PGet<ZType>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const uint64* theValue = iAny.PGet<uint64>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const char* theValue = iAny.PGet<char>()) + { + oVal = ZVal_ZooLib(int8(*theValue)); + } + else if (const unsigned char* theValue = iAny.PGet<unsigned char>()) + { + oVal = ZVal_ZooLib(int8(*theValue)); + } + else if (const signed char* theValue = iAny.PGet<signed char>()) + { + oVal = ZVal_ZooLib(int8(*theValue)); + } + else if (const short* theValue = iAny.PGet<short>()) + { + oVal = ZVal_ZooLib(int16(*theValue)); + } + else if (const unsigned short* theValue = iAny.PGet<unsigned short>()) + { + oVal = ZVal_ZooLib(int16(*theValue)); + } + else if (const int* theValue = iAny.PGet<int>()) + { + if (ZIntIs32Bit) + oVal = ZVal_ZooLib(int32(*theValue)); + else + oVal = ZVal_ZooLib(int64(*theValue)); + } + else if (const unsigned int* theValue = iAny.PGet<unsigned int>()) + { + if (ZIntIs32Bit) + oVal = ZVal_ZooLib(int32(*theValue)); + else + oVal = ZVal_ZooLib(int64(*theValue)); + } + else if (const long* theValue = iAny.PGet<long>()) + { + if (ZLongIs32Bit) + oVal = ZVal_ZooLib(int32(*theValue)); + else + oVal = ZVal_ZooLib(int64(*theValue)); + } + else if (const unsigned long* theValue = iAny.PGet<unsigned long>()) + { + if (ZLongIs32Bit) + oVal = ZVal_ZooLib(int32(*theValue)); + else + oVal = ZVal_ZooLib(int64(*theValue)); + } + else if (const int64* theValue = iAny.PGet<int64>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const bool* theValue = iAny.PGet<bool>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const float* theValue = iAny.PGet<float>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const double* theValue = iAny.PGet<double>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const ZTime* theValue = iAny.PGet<ZTime>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const VoidStar_t* theValue = iAny.PGet<VoidStar_t>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const ZRectPOD* theValue = iAny.PGet<ZRectPOD>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const ZPointPOD* theValue = iAny.PGet<ZPointPOD>()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const ZRef<ZCounted>* theValue = + iAny.PGet<ZRef<ZCounted> >()) + { + oVal = ZVal_ZooLib(*theValue); + } + else if (const vector<char>* theValue = iAny.PGet<vector<char> >()) + { + if (size_t theSize = theValue->size()) + oVal = ZData_ZooLib(&(*theValue)[0], theSize); + else + oVal = ZData_ZooLib(); + } + else if (const ZData_Any* theValue = iAny.PGet<ZData_Any>()) + { + // This relies on the fact that ZData_ZooLib is a typedef of ZData_Any. + oVal = *theValue; + } + else if (const vector<ZAny>* theValue = iAny.PGet<vector<ZAny> >()) + { + ZSeq_ZooLib theSeq; + for (vector<ZAny>::const_iterator i = theValue->begin(), end = theValue->end(); + i != end; ++i) + { + ZVal_ZooLib local; + if (sQFromAny(*i, local)) + theSeq.Append(local); + else + theSeq.Append(ZVal_ZooLib()); + } + oVal = theSeq; + } + else if (const ZSeq_Any* theValue = iAny.PGet<ZSeq_Any>()) + { + ZSeq_ZooLib theSeq; + for (int x = 0, count = theValue->Count(); x < count; ++x) + { + ZVal_ZooLib local; + if (sQFromAny(theValue->Get(x), local)) + theSeq.Append(local); + else + theSeq.Append(ZVal_ZooLib()); + } + oVal = theSeq; + } + else if (const map<string, ZAny>* theValue = iAny.PGet<map<string, ZAny> >()) + { + ZMap_ZooLib theMap; + for (map<string, ZAny>::const_iterator i = theValue->begin(), end = theValue->end(); + i != end; ++i) + { + ZVal_ZooLib local; + if (sQFromAny((*i).second, local)) + theMap.Set((*i).first, local); + } + oVal = theMap; + } + else if (const ZMap_Any* theValue = iAny.PGet<ZMap_Any>()) + { + ZMap_ZooLib theMap; + for (ZMap_Any::Index_t i = theValue->Begin(), end = theValue->End(); + i != end; ++i) + { + ZVal_ZooLib local; + if (sQFromAny(theValue->Get(i), local)) + theMap.Set((*i).first, local); + } + oVal = theMap; + } + else + { + return false; + } + return true; + } + +ZVal_ZooLib ZVal_ZooLib::sDFromAny(const ZVal_ZooLib& iDefault, const ZAny& iAny) + { + ZVal_ZooLib result; + if (sQFromAny(iAny, result)) + return result; + return iDefault; + } + +ZVal_ZooLib ZVal_ZooLib::sFromAny(const ZAny& iAny) + { + ZVal_ZooLib result; + if (sQFromAny(iAny, result)) + return result; + return ZVal_ZooLib(); + } + +ZAny ZVal_ZooLib::AsAny() const + { return this->DAsAny(ZAny()); } + +ZAny ZVal_ZooLib::DAsAny(const ZAny& iDefault) const + { + switch (fType.fType) + { + case eZType_Null: + { + return ZAny(); + } + case eZType_Type: + { + return ZAny(fData.fAs_Type); + } + case eZType_ID: + { + return ZAny(fData.fAs_ID); + } + case eZType_Int8: + { + return ZAny(fData.fAs_Int8); + } + case eZType_Int16: + { + return ZAny(fData.fAs_Int16); + } + case eZType_Int32: + { + return ZAny(fData.fAs_Int32); + } + case eZType_Int64: + { + return ZAny(fData.fAs_Int64); + } + case eZType_Bool: + { + return ZAny(fData.fAs_Bool); + } + case eZType_Float: + { + return ZAny(fData.fAs_Float); + } + case eZType_Double: + { + return ZAny(fData.fAs_Double); + } + case eZType_Time: + { + return ZAny(ZTime(fData.fAs_Time)); + } + case eZType_Pointer: + { + return ZAny(fData.fAs_Pointer); + } + case eZType_Rect: + { + return ZAny(fData.fAs_Rect); + } + case eZType_Point: + { + return ZAny(fData.fAs_Point); + } + case eZType_String: + { + return ZAny(sFetch_T<ValString>(fType.fBytes)->AsString()); + } +#if 0//## + case eZType_Name: + { + sFetch_T<ZTName>(fType.fBytes)->ToStream(iStreamW)); + break; + } +#endif//## + case eZType_Tuple: + { + return ZAny(sFetch_T<ZMap_ZooLib>(fType.fBytes)->AsMap_Any(iDefault)); + } + case eZType_RefCounted: + { + // Just do nothing. We'll construct a nil refcounted when we read. + break; + } + case eZType_Raw: + { + return sFetch_T<ZData_ZooLib>(fType.fBytes)->AsAny(); + } + case eZType_Vector: + { + return ZAny(sFetch_T<ZSeq_ZooLib>(fType.fBytes)->AsSeq_Any(iDefault)); + } + default: + { + if (fType.fType < 0) + return ZAny(string(fType.fBytes, -fType.fType-1)); + } + } + return iDefault; + } + +ZVal_ZooLib::operator operator_bool_type() const + { return operator_bool_generator_type::translate(fType.fType != eZType_Null); } + +void ZVal_ZooLib::swap(ZVal_ZooLib& iOther) + { std::swap(fFastCopy, iOther.fFastCopy); } + +ZVal_ZooLib::ZVal_ZooLib() + { fType.fType = eZType_Null; } + +ZVal_ZooLib::~ZVal_ZooLib() + { this->pRelease(); } + +ZVal_ZooLib::ZVal_ZooLib(const ZVal_ZooLib& iOther) + { this->pCopy(iOther); } + +ZVal_ZooLib& ZVal_ZooLib::operator=(const ZVal_ZooLib& iOther) + { + if (this != &iOther) + { + this->pRelease(); + this->pCopy(iOther); + } + return *this; + } + +ZVal_ZooLib::ZVal_ZooLib(const ZStreamR& iStreamR) + { + fType.fType = eZType_Null; + this->pFromStream((ZType)iStreamR.ReadUInt8(), iStreamR); + } + +ZVal_ZooLib::ZVal_ZooLib(ZType iType, const ZStreamR& iStreamR) + { + fType.fType = eZType_Null; + this->pFromStream(iType, iStreamR); + } + +ZVal_ZooLib::ZVal_ZooLib(const ZVal_ZooLib& iVal, bool iAsVector) + { + ZAssertStop(kDebug_Tuple, iAsVector); + sCtor_T<ZSeq_ZooLib>(fType.fBytes, 1, iVal); + fType.fType = eZType_Vector; + } + +ZVal_ZooLib::ZVal_ZooLib(ZType iVal) + { + fType.fType = eZType_Type; + fData.fAs_Type = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(uint64 iVal, bool iIsID) + { + ZAssertStop(kDebug_Tuple, iIsID); + fType.fType = eZType_ID; + fData.fAs_ID = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(uint64 iVal) + { + fType.fType = eZType_ID; + fData.fAs_ID = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(int8 iVal) + { + fType.fType = eZType_Int8; + fData.fAs_Int8 = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(int16 iVal) + { + fType.fType = eZType_Int16; + fData.fAs_Int16 = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(int32 iVal) + { + fType.fType = eZType_Int32; + fData.fAs_Int32 = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(int64 iVal) + { + fType.fType = eZType_Int64; + fData.fAs_Int64 = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(bool iVal) + { + fType.fType = eZType_Bool; + fData.fAs_Bool = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(float iVal) + { + fType.fType = eZType_Float; + fData.fAs_Float = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(double iVal) + { + fType.fType = eZType_Double; + fData.fAs_Double = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(ZTime iVal) + { + fType.fType = eZType_Time; + fData.fAs_Time = iVal.fVal; + } + +ZVal_ZooLib::ZVal_ZooLib(void* inPointer) + { + fType.fType = eZType_Pointer; + fData.fAs_Pointer = inPointer; + } + +ZVal_ZooLib::ZVal_ZooLib(const ZRectPOD& iVal) + { + fType.fType = eZType_Rect; + fData.fAs_Rect = new ZRectPOD(iVal); + } + +ZVal_ZooLib::ZVal_ZooLib(const ZPointPOD& iVal) + { + fType.fType = eZType_Point; + fData.fAs_Point = iVal; + } + +ZVal_ZooLib::ZVal_ZooLib(const char* iVal) + { + size_t theSize = strlen(iVal); + if (spIsSpecialString(theSize)) + { + fType.fType = -int(theSize)-1; + if (theSize) + ZMemCopy(fType.fBytes, iVal, theSize); + } + else + { + fType.fType = eZType_String; + sCtor_T<ValString>(fType.fBytes, iVal, theSize); + } + } + +ZVal_ZooLib::ZVal_ZooLib(const string& iVal) + { + size_t theSize = iVal.size(); + if (spIsSpecialString(theSize)) + { + fType.fType = -int(theSize)-1; + if (theSize) + ZMemCopy(fType.fBytes, iVal.data(), theSize); + } + else + { + fType.fType = eZType_String; + sCtor_T<ValString>(fType.fBytes, iVal); + } + } + +ZVal_ZooLib::ZVal_ZooLib(const ZData_ZooLib& iVal) + { + fType.fType = eZType_Raw; + sCtor_T<ZData_ZooLib, ZData_ZooLib>(fType.fBytes, iVal); + } + +ZVal_ZooLib::ZVal_ZooLib(const ZSeq_ZooLib& iVal) + { + fType.fType = eZType_Vector; + sCtor_T<ZSeq_ZooLib, ZSeq_ZooLib>(fType.fBytes, iVal); + } + +ZVal_ZooLib::ZVal_ZooLib(const ZMap_ZooLib& iVal) + { + fType.fType = eZType_Tuple; + sCtor_T<ZMap_ZooLib, ZMap_ZooLib>(fType.fBytes, iVal); + } + +ZVal_ZooLib::ZVal_ZooLib(const ZRef<ZCounted>& iVal) + { + fType.fType = eZType_RefCounted; + sCtor_T<ZRef<ZCounted>, ZRef<ZCounted> >(fType.fBytes, iVal); + } + +ZVal_ZooLib::ZVal_ZooLib(const void* iSource, size_t iSize) + { + fType.fType = eZType_Raw; + sCtor_T<ZData_ZooLib>(fType.fBytes, iSource, iSize); + } + +ZVal_ZooLib::ZVal_ZooLib(const ZStreamR& iStreamR, size_t iSize) + { + fType.fType = eZType_Raw; + ZData_ZooLib* theRaw = sCtor_T<ZData_ZooLib>(fType.fBytes); + sRead_T(*theRaw, iStreamR, iSize); + } + +void ZVal_ZooLib::Clear() + { + this->pRelease(); + fType.fType = eZType_Null; + } + +template <> +ZQ<ZType> ZVal_ZooLib::QGet<ZType>() const + { + if (fType.fType == eZType_Type) + return fData.fAs_Type; + return null; + } + +template <> +ZQ<uint64> ZVal_ZooLib::QGet<uint64>() const + { + if (fType.fType == eZType_ID) + return fData.fAs_ID; + return null; + } + +template <> +ZQ<int8> ZVal_ZooLib::QGet<int8>() const + { + if (fType.fType == eZType_Int8) + return fData.fAs_Int8; + return null; + } + +template <> +ZQ<int16> ZVal_ZooLib::QGet<int16>() const + { + if (fType.fType == eZType_Int16) + return fData.fAs_Int16; + return null; + } + +template <> +ZQ<int32> ZVal_ZooLib::QGet<int32>() const + { + if (fType.fType == eZType_Int32) + return fData.fAs_Int32; + return null; + } + +template <> +ZQ<int64> ZVal_ZooLib::QGet<int64>() const + { + if (fType.fType == eZType_Int64) + return fData.fAs_Int64; + return null; + } + +template <> +ZQ<bool> ZVal_ZooLib::QGet<bool>() const + { + if (fType.fType == eZType_Bool) + return fData.fAs_Bool; + return null; + } + +template <> +ZQ<float> ZVal_ZooLib::QGet<float>() const + { + if (fType.fType == eZType_Float) + return fData.fAs_Float; + return null; + } + +template <> +ZQ<double> ZVal_ZooLib::QGet<double>() const + { + if (fType.fType == eZType_Double) + return fData.fAs_Double; + return null; + } + +template <> +ZQ<ZTime> ZVal_ZooLib::QGet<ZTime>() const + { + if (fType.fType == eZType_Time) + return fData.fAs_Time; + return null; + } + +template <> +ZQ<void*> ZVal_ZooLib::QGet<void*>() const + { + if (fType.fType == eZType_Pointer) + return fData.fAs_Pointer; + return null; + } + +template <> +ZQ<ZRectPOD> ZVal_ZooLib::QGet<ZRectPOD>() const + { + if (fType.fType == eZType_Rect) + return *fData.fAs_Rect; + return null; + } + +template <> +ZQ<ZPointPOD> ZVal_ZooLib::QGet<ZPointPOD>() const + { + if (fType.fType == eZType_Point) + return fData.fAs_Point; + return null; + } + +template <> +ZQ<string> ZVal_ZooLib::QGet<string>() const + { + if (fType.fType == eZType_String) + return sFetch_T<ValString>(fType.fBytes)->AsString(); + else if (fType.fType < 0) + return string(fType.fBytes, -fType.fType-1); + return null; + } + +template <> +ZQ<ZData_ZooLib> ZVal_ZooLib::QGet<ZData_ZooLib>() const + { + if (fType.fType == eZType_Raw) + return *sFetch_T<ZData_ZooLib>(fType.fBytes); + return null; + } + +template <> +ZQ<ZSeq_ZooLib> ZVal_ZooLib::QGet<ZSeq_ZooLib>() const + { + if (fType.fType == eZType_Vector) + return *sFetch_T<ZSeq_ZooLib>(fType.fBytes); + return null; + } + +template <> +ZQ<ZMap_ZooLib> ZVal_ZooLib::QGet<ZMap_ZooLib>() const + { + if (fType.fType == eZType_Tuple) + return *sFetch_T<ZMap_ZooLib>(fType.fBytes); + return null; + } + +template <> +ZQ<ZRef<ZCounted> > ZVal_ZooLib::QGet<ZRef<ZCounted> >() const + { + if (fType.fType == eZType_RefCounted) + return *sFetch_T<ZRef<ZCounted> >(fType.fBytes); + return null; + } + +template <> +void ZVal_ZooLib::Set<ZType>(const ZType& iVal) + { + this->pRelease(); + fType.fType = eZType_Type; + fData.fAs_Type = iVal; + } + +template <> +void ZVal_ZooLib::Set<uint64>(const uint64& iVal) + { + this->pRelease(); + fType.fType = eZType_ID; + fData.fAs_ID = iVal; + } + +template <> +void ZVal_ZooLib::Set<int8>(const int8& iVal) + { + this->pRelease(); + fType.fType = eZType_Int8; + fData.fAs_Int8 = iVal; + } + +template <> +void ZVal_ZooLib::Set<int16>(const int16& iVal) + { + this->pRelease(); + fType.fType = eZType_Int16; + fData.fAs_Int16 = iVal; + } + +template <> +void ZVal_ZooLib::Set<int32>(const int32& iVal) + { + this->pRelease(); + fType.fType = eZType_Int32; + fData.fAs_Int32 = iVal; + } + +template <> +void ZVal_ZooLib::Set<int64>(const int64& iVal) + { + this->pRelease(); + fType.fType = eZType_Int64; + fData.fAs_Int64 = iVal; + } + +template <> +void ZVal_ZooLib::Set<bool>(const bool& iVal) + { + this->pRelease(); + fType.fType = eZType_Bool; + fData.fAs_Bool = iVal; + } + +template <> +void ZVal_ZooLib::Set<float>(const float& iVal) + { + this->pRelease(); + fType.fType = eZType_Float; + fData.fAs_Float = iVal; + } + +template <> +void ZVal_ZooLib::Set<double>(const double& iVal) + { + this->pRelease(); + fType.fType = eZType_Double; + fData.fAs_Double = iVal; + } + +template <> +void ZVal_ZooLib::Set<ZTime>(const ZTime& iVal) + { + this->pRelease(); + fType.fType = eZType_Time; + fData.fAs_Time = iVal.fVal; + } + +template <> +void ZVal_ZooLib::Set<VoidStar_t>(const VoidStar_t& iVal) + { + this->pRelease(); + fType.fType = eZType_Pointer; + fData.fAs_Pointer = iVal; + } + +template <> +void ZVal_ZooLib::Set<ZRectPOD>(const ZRectPOD& iVal) + { + this->pRelease(); + fType.fType = eZType_Rect; + fData.fAs_Rect = new ZRectPOD(iVal); + } + +template <> +void ZVal_ZooLib::Set<ZPointPOD>(const ZPointPOD& iVal) + { + this->pRelease(); + fType.fType = eZType_Point; + fData.fAs_Point = iVal; + } + +typedef const char* ConstCharStar_t; +template <> +void ZVal_ZooLib::Set<ConstCharStar_t>(const ConstCharStar_t& iVal) + { + this->pRelease(); + size_t theSize = strlen(iVal); + if (spIsSpecialString(theSize)) + { + fType.fType = -int(theSize)-1; + if (theSize) + ZMemCopy(fType.fBytes, iVal, theSize); + } + else + { + fType.fType = eZType_String; + sCtor_T<ValString>(fType.fBytes, iVal, theSize); + } + } + +template <> +void ZVal_ZooLib::Set<string>(const string& iVal) + { + this->pRelease(); + size_t theSize = iVal.size(); + if (spIsSpecialString(theSize)) + { + fType.fType = -int(theSize)-1; + if (theSize) + ZMemCopy(fType.fBytes, iVal.data(), theSize); + } + else + { + fType.fType = eZType_String; + sCtor_T<ValString>(fType.fBytes, iVal); + } + } + +template <> +void ZVal_ZooLib::Set<ZData_ZooLib>(const ZData_ZooLib& iVal) + { + this->pRelease(); + sCtor_T<ZData_ZooLib, ZData_ZooLib>(fType.fBytes, iVal); + fType.fType = eZType_Raw; + } + +template <> +void ZVal_ZooLib::Set<ZSeq_ZooLib>(const ZSeq_ZooLib& iVal) + { + this->pRelease(); + sCtor_T<ZSeq_ZooLib, ZSeq_ZooLib>(fType.fBytes, iVal); + fType.fType = eZType_Vector; + } + +template <> +void ZVal_ZooLib::Set<ZMap_ZooLib>(const ZMap_ZooLib& iVal) + { + this->pRelease(); + sCtor_T<ZMap_ZooLib, ZMap_ZooLib>(fType.fBytes, iVal); + fType.fType = eZType_Tuple; + } + +template <> +void ZVal_ZooLib::Set<ZRef<ZCounted> >(const ZRef<ZCounted>& iVal) + { + this->pRelease(); + fType.fType = eZType_RefCounted; + sCtor_T<ZRef<ZCounted>, ZRef<ZCounted> >(fType.fBytes, iVal); + } + +int ZVal_ZooLib::Compare(const ZVal_ZooLib& iOther) const + { + if (this == &iOther) + return 0; + + if (fType.fType < 0) + { + // We're a special string. + if (iOther.fType.fType < 0) + { + // So is iOther + return ZMemCompare(fType.fBytes, -fType.fType-1, + iOther.fType.fBytes, -iOther.fType.fType-1); + } + else if (iOther.fType.fType == eZType_String) + { + // iOther is a regular string. + return -sFetch_T<ValString>(iOther.fType.fBytes) + ->Compare(fType.fBytes, -fType.fType-1); + } + else + { + return int(eZType_String) - int(iOther.fType.fType); + } + } + else + { + // We're not a special string. + if (iOther.fType.fType < 0) + { + // iOther is a special string. + if (fType.fType == eZType_String) + { + // We're a regular string. + return sFetch_T<ValString>(fType.fBytes) + ->Compare(iOther.fType.fBytes, -iOther.fType.fType-1); + } + else + { + return int(fType.fType) - int(eZType_String); + } + } + } + + if (fType.fType < iOther.fType.fType) + return -1; + + if (fType.fType > iOther.fType.fType) + return 1; + + return this->pUncheckedCompare(iOther); + } + +bool ZVal_ZooLib::operator==(const ZVal_ZooLib& iOther) const + { return this->Compare(iOther) == 0; } + +bool ZVal_ZooLib::operator<(const ZVal_ZooLib& iOther) const + { return this->Compare(iOther) < 0; } + +ZSeq_ZooLib& ZVal_ZooLib::MutableSeq() + { + if (fType.fType != eZType_Vector) + { + this->pRelease(); + sCtor_T<ZSeq_ZooLib>(fType.fBytes); + fType.fType = eZType_Vector; + } + return *sFetch_T<ZSeq_ZooLib>(fType.fBytes); + } + +ZMap_ZooLib& ZVal_ZooLib::MutableMap() + { + if (fType.fType != eZType_Tuple) + { + this->pRelease(); + sCtor_T<ZMap_ZooLib>(fType.fBytes); + fType.fType = eZType_Tuple; + } + return *sFetch_T<ZMap_ZooLib>(fType.fBytes); + } + +ZType ZVal_ZooLib::TypeOf() const + { return fType.fType < 0 ? eZType_String : ZType(fType.fType); } + +void ZVal_ZooLib::ToStream(const ZStreamW& iStreamW) const + { + if (fType.fType < 0) + { + iStreamW.WriteUInt8(eZType_String); + size_t theSize = -fType.fType-1; + ZAssertStop(kDebug_Tuple, spIsSpecialString(theSize)); + iStreamW.WriteCount(theSize); + if (theSize) + iStreamW.Write(fType.fBytes, theSize); + return; + } + + iStreamW.WriteUInt8(fType.fType); + switch (fType.fType) + { + case eZType_Null: + { + // No data to write. + break; + } + case eZType_Type: + { + iStreamW.WriteUInt8(fData.fAs_Type); + break; + } + case eZType_ID: + { + iStreamW.WriteUInt64(fData.fAs_ID); + break; + } + case eZType_Int8: + { + iStreamW.WriteUInt8(fData.fAs_Int8); + break; + } + case eZType_Int16: + { + iStreamW.WriteUInt16(fData.fAs_Int16); + break; + } + case eZType_Int32: + { + iStreamW.WriteUInt32(fData.fAs_Int32); + break; + } + case eZType_Int64: + { + iStreamW.WriteUInt64(fData.fAs_Int64); + break; + } + case eZType_Bool: + { + iStreamW.WriteUInt8(fData.fAs_Bool ? 1 : 0); + break; + } + case eZType_Float: + { + iStreamW.WriteFloat(fData.fAs_Float); + break; + } + case eZType_Double: + { + iStreamW.WriteDouble(fData.fAs_Double); + break; + } + case eZType_Time: + { + iStreamW.WriteDouble(fData.fAs_Time); + break; + } + case eZType_Pointer: + { + if (sizeof(intptr_t) != sizeof(uint32)) + ZUnimplemented(); + else + iStreamW.WriteUInt32(reinterpret_cast<intptr_t>(fData.fAs_Pointer)); + break; + } + case eZType_Rect: + { + iStreamW.WriteUInt32(fData.fAs_Rect->left); + iStreamW.WriteUInt32(fData.fAs_Rect->top); + iStreamW.WriteUInt32(fData.fAs_Rect->right); + iStreamW.WriteUInt32(fData.fAs_Rect->bottom); + break; + } + case eZType_Point: + { + iStreamW.WriteUInt32(fData.fAs_Point.h); + iStreamW.WriteUInt32(fData.fAs_Point.v); + break; + } + case eZType_String: + { + sFetch_T<ValString>(fType.fBytes)->ToStream(iStreamW); + break; + } +#if 0//## + case eZType_Name: + { + sFetch_T<ZTName>(fType.fBytes)->ToStream(iStreamW); + break; + } +#endif//## + case eZType_Tuple: + { + sFetch_T<ZMap_ZooLib>(fType.fBytes)->ToStream(iStreamW); + break; + } + case eZType_RefCounted: + { + // Just do nothing. We'll construct a nil refcounted when we read. + break; + } + case eZType_Raw: + { + const ZData_ZooLib* theMemoryBlock = sFetch_T<ZData_ZooLib>(fType.fBytes); + iStreamW.WriteCount(theMemoryBlock->GetSize()); + if (theMemoryBlock->GetSize()) + iStreamW.Write(theMemoryBlock->GetData(), theMemoryBlock->GetSize()); + break; + } + case eZType_Vector: + { + sFetch_T<ZSeq_ZooLib>(fType.fBytes)->ToStream(iStreamW); + break; + } + default: + { + ZDebugStopf(kDebug_Tuple, ("Unknown type (%d)", fType.fType)); + } + } + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZVal_ZooLib typename accessors + +ZMACRO_ZValAccessors_Def_Std(ZVal_ZooLib) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, ID, uint64) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Type, ZType) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Time, ZTime) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Rect, ZRectPOD) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Point, ZPointPOD) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, RefCounted, ZRef<ZCounted>) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Pointer, VoidStar_t) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Data, ZData_ZooLib) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Seq, ZSeq_ZooLib) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Map, ZMap_ZooLib) + +// Backwards compatibility +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Raw, ZData_ZooLib) +ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Tuple, ZMap_ZooLib) + +// ================================================================================================= +#pragma mark - +#pragma mark * ZVal_ZooLib internal implementation + +int ZVal_ZooLib::pUncheckedCompare(const ZVal_ZooLib& iOther) const + { + // Our types are assumed to be the same, and not special strings. + ZAssertStop(kDebug_Tuple, fType.fType == iOther.fType.fType); + switch (fType.fType) + { + case eZType_Null: return 0; + case eZType_Type: return sCompare_T(fData.fAs_Type, iOther.fData.fAs_Type); + case eZType_ID: return sCompare_T(fData.fAs_ID, iOther.fData.fAs_ID); + case eZType_Int8: return sCompare_T(fData.fAs_Int8, iOther.fData.fAs_Int8); + case eZType_Int16: return sCompare_T(fData.fAs_Int16, iOther.fData.fAs_Int16); + case eZType_Int32: return sCompare_T(fData.fAs_Int32, iOther.fData.fAs_Int32); + case eZType_Int64: return sCompare_T(fData.fAs_Int64, iOther.fData.fAs_Int64); + case eZType_Bool: return sCompare_T(fData.fAs_Bool, iOther.fData.fAs_Bool); + case eZType_Float: return sCompare_T(fData.fAs_Float, iOther.fData.fAs_Float); + case eZType_Double: return sCompare_T(fData.fAs_Double, iOther.fData.fAs_Double); + case eZType_Time: return sCompare_T(fData.fAs_Time, iOther.fData.fAs_Time); + case eZType_Pointer: return sCompare_T(fData.fAs_Pointer, iOther.fData.fAs_Pointer); + case eZType_Rect: return sCompare_T(*fData.fAs_Rect, *iOther.fData.fAs_Rect); + case eZType_Point: return sCompare_T(fData.fAs_Point, iOther.fData.fAs_Point); + case eZType_String: + { + return sFetch_T<ValString>(fType.fBytes) + ->Compare(*sFetch_T<ValString>(iOther.fType.fBytes)); + } +#if 0//## + case eZType_Name: + { + return sFetch_T<ZTName>(fType.fBytes)->Compare(*sFetch_T<ZTName>(iOther.fType.fBytes)); + } +#endif//## + case eZType_Tuple: + { + return sFetch_T<ZMap_ZooLib>(fType.fBytes) + ->Compare(*sFetch_T<ZMap_ZooLib>(iOther.fType.fBytes)); + } + case eZType_RefCounted: + { + const ZRef<ZCounted>* thisZRef = + sFetch_T<ZRef<ZCounted> >(fType.fBytes); + + const ZRef<ZCounted>* otherZRef = + sFetch_T<ZRef<ZCounted> >(iOther.fType.fBytes); + + if (*thisZRef < *otherZRef) + return -1; + else if (*otherZRef < *thisZRef) + return 1; + return 0; + } + case eZType_Raw: + { + return sFetch_T<ZData_ZooLib>(fType.fBytes) + ->Compare(*sFetch_T<ZData_ZooLib>(iOther.fType.fBytes)); + } + case eZType_Vector: + { + return sFetch_T<ZSeq_ZooLib>(fType.fBytes) + ->Compare(*sFetch_T<ZSeq_ZooLib>(iOther.fType.fBytes)); + } + } + ZDebugStopf(kDebug_Tuple, ("Unknown type (%d)", fType.fType)); + return 0; + } + +bool ZVal_ZooLib::pUncheckedLess(const ZVal_ZooLib& iOther) const + { + // Our types are assumed to be the same, and not special strings. + ZAssertStop(kDebug_Tuple, fType.fType == iOther.fType.fType); + switch (fType.fType) + { + case eZType_Null: return false; + case eZType_Type: return fData.fAs_Type < iOther.fData.fAs_Type; + case eZType_ID: return fData.fAs_ID < iOther.fData.fAs_ID; + case eZType_Int8: return fData.fAs_Int8 < iOther.fData.fAs_Int8; + case eZType_Int16: return fData.fAs_Int16 < iOther.fData.fAs_Int16; + case eZType_Int32: return fData.fAs_Int32 < iOther.fData.fAs_Int32; + case eZType_Int64: return fData.fAs_Int64 < iOther.fData.fAs_Int64; + case eZType_Bool: return fData.fAs_Bool < iOther.fData.fAs_Bool; + case eZType_Float: return fData.fAs_Float < iOther.fData.fAs_Float; + case eZType_Double: return fData.fAs_Double < iOther.fData.fAs_Double; + case eZType_Time: return fData.fAs_Time < iOther.fData.fAs_Time; + case eZType_Pointer: return fData.fAs_Pointer < iOther.fData.fAs_Pointer; + case eZType_Rect: return sCompare_T(*fData.fAs_Rect, *iOther.fData.fAs_Rect) < 0; + case eZType_Point: return sCompare_T(fData.fAs_Point, iOther.fData.fAs_Point) < 0; + + case eZType_String: + { + return 0 > sFetch_T<ValString>(fType.fBytes) + ->Compare(*sFetch_T<ValString>(iOther.fType.fBytes)); + } +#if 0//## + case eZType_Name: + { + return *sFetch_T<ZTName>(fType.fBytes) < *sFetch_T<ZTName>(iOther.fType.fBytes); + } +#endif//## + case eZType_Tuple: + { + return *sFetch_T<ZMap_ZooLib>(fType.fBytes) < *sFetch_T<ZMap_ZooLib>(iOther.fType.fBytes); + } + case eZType_RefCounted: + { + return *sFetch_T<ZRef<ZCounted> >(fType.fBytes) + < *sFetch_T<ZRef<ZCounted> >(iOther.fType.fBytes); + } + case eZType_Raw: + { + return *sFetch_T<ZData_ZooLib>(fType.fBytes) + < *sFetch_T<ZData_ZooLib>(iOther.fType.fBytes); + } + case eZType_Vector: + { + return *sFetch_T<ZSeq_ZooLib>(fType.fBytes) + < *sFetch_T<ZSeq_ZooLib>(iOther.fType.fBytes); + } + } + ZDebugStopf(kDebug_Tuple, ("Unknown type (%d)", fType.fType)); + return false; + } + +bool ZVal_ZooLib::pUncheckedEqual(const ZVal_ZooLib& iOther) const + { + // Our types are assumed to be the same, and not special strings. + ZAssertStop(kDebug_Tuple, fType.fType == iOther.fType.fType); + switch (fType.fType) + { + case eZType_Null: return true; + case eZType_Type: return fData.fAs_Type == iOther.fData.fAs_Type; + case eZType_ID: return fData.fAs_ID == iOther.fData.fAs_ID; + case eZType_Int8: return fData.fAs_Int8 == iOther.fData.fAs_Int8; + case eZType_Int16: return fData.fAs_Int16 == iOther.fData.fAs_Int16; + case eZType_Int32: return fData.fAs_Int32 == iOther.fData.fAs_Int32; + case eZType_Int64: return fData.fAs_Int64 == iOther.fData.fAs_Int64; + case eZType_Bool: return fData.fAs_Bool == iOther.fData.fAs_Bool; + case eZType_Float: return fData.fAs_Float == iOther.fData.fAs_Float; + case eZType_Double: return fData.fAs_Double == iOther.fData.fAs_Double; + case eZType_Time: return fData.fAs_Time == iOther.fData.fAs_Time; + case eZType_Pointer: return fData.fAs_Pointer == iOther.fData.fAs_Pointer; + case eZType_Rect: return fData.fAs_Rect->left == iOther.fData.fAs_Rect->left + && fData.fAs_Rect->top == iOther.fData.fAs_Rect->top + && fData.fAs_Rect->right == iOther.fData.fAs_Rect->right + && fData.fAs_Rect->bottom == iOther.fData.fAs_Rect->bottom; + case eZType_Point: return fData.fAs_Point.h == iOther.fData.fAs_Point.h + && fData.fAs_Point.v == iOther.fData.fAs_Point.v; + + case eZType_String: + { + return 0 == sFetch_T<ValString>(fType.fBytes) + ->Compare(*sFetch_T<ValString>(iOther.fType.fBytes)); + } +#if 0//## + case eZType_Name: + { + return *sFetch_T<ZTName>(fType.fBytes) == *sFetch_T<ZTName>(iOther.fType.fBytes); + } +#endif//## + case eZType_Tuple: + { + return *sFetch_T<ZMap_ZooLib>(fType.fBytes) + == *sFetch_T<ZMap_ZooLib>(iOther.fType.fBytes); + } + case eZType_RefCounted: + { + return *sFetch_T<ZRef<ZCounted> >(fType.fBytes) + == *sFetch_T<ZRef<ZCounted> >(iOther.fType.fBytes); + } + case eZType_Raw: + { + return *sFetch_T<ZData_ZooLib>(fType.fBytes) + == *sFetch_T<ZData_ZooLib>(iOther.fType.fBytes); + } + case eZType_Vector: + { + return *sFetch_T<ZSeq_ZooLib>(fType.fBytes) + == *sFetch_T<ZSeq_ZooLib>(iOther.fType.fBytes); + } + } + ZDebugStopf(kDebug_Tuple, ("Unknown type (%d)", fType.fType)); + return false; + } + +void ZVal_ZooLib::pRelease() + { + switch (fType.fType) + { + case eZType_Null: + case eZType_Type: + case eZType_ID: + case eZType_Int8: + case eZType_Int16: + case eZType_Int32: + case eZType_Int64: + case eZType_Bool: + case eZType_Float: + case eZType_Double: + case eZType_Time: + case eZType_Pointer: + case eZType_Point: + break; + case eZType_Rect: delete fData.fAs_Rect; break; + + case eZType_String: sDtor_T<ValString>(fType.fBytes); break; +//## case eZType_Name: sDtor_T<ZTName>(fType.fBytes); break; + case eZType_Tuple: sDtor_T<ZMap_ZooLib>(fType.fBytes); break; + case eZType_RefCounted: + { + sDtor_T<ZRef<ZCounted> >(fType.fBytes); + break; + } + case eZType_Raw: sDtor_T<ZData_ZooLib>(fType.fBytes); break; + case eZType_Vector: sDtor_T<ZSeq_ZooLib>(fType.fBytes); break; + default: + { + if (fType.fType >= 0) + ZDebugStopf(kDebug_Tuple, ("Unknown type (%d)", fType.fType)); + } + } + } + +void ZVal_ZooLib::pCopy(const ZVal_ZooLib& iOther) + { + if (iOther.fType.fType < 0) + { + fFastCopy = iOther.fFastCopy; + } + else + { + fType.fType = iOther.fType.fType; + switch (fType.fType) + { + case eZType_Null: + // No data to be copied. + break; + case eZType_Type: + fData.fAs_Type = iOther.fData.fAs_Type; + break; + case eZType_ID: + fData.fAs_ID = iOther.fData.fAs_ID; + break; + case eZType_Int8: + fData.fAs_Int8 = iOther.fData.fAs_Int8; + break; + case eZType_Int16: + fData.fAs_Int16 = iOther.fData.fAs_Int16; + break; + case eZType_Int32: + fData.fAs_Int32 = iOther.fData.fAs_Int32; + break; + case eZType_Int64: + fData.fAs_Int64 = iOther.fData.fAs_Int64; + break; + case eZType_Bool: + fData.fAs_Bool = iOther.fData.fAs_Bool; + break; + case eZType_Float: + fData.fAs_Float = iOther.fData.fAs_Float; + break; + case eZType_Double: + fData.fAs_Double = iOther.fData.fAs_Double; + break; + case eZType_Time: + fData.fAs_Time = iOther.fData.fAs_Time; + break; + case eZType_Pointer: + fData.fAs_Pointer = iOther.fData.fAs_Pointer; + break; + case eZType_Rect: + fData.fAs_Rect = new ZRectPOD(*iOther.fData.fAs_Rect); + break; + case eZType_Point: + fData.fAs_Point = iOther.fData.fAs_Point; + break; + case eZType_String: + sCtorFromVoidStar_T<ValString>(fType.fBytes, iOther.fType.fBytes); + break; +#if 0//## + case eZType_Name: + sCtorFromVoidStar_T<ZTName>(fType.fBytes, iOther.fType.fBytes); + break; +#endif//## + case eZType_Tuple: + sCtorFromVoidStar_T<ZMap_ZooLib>(fType.fBytes, iOther.fType.fBytes); + break; + case eZType_RefCounted: + sCtorFromVoidStar_T<ZRef<ZCounted> > + (fType.fBytes, iOther.fType.fBytes); + break; + case eZType_Raw: + sCtorFromVoidStar_T<ZData_ZooLib>(fType.fBytes, iOther.fType.fBytes); + break; + case eZType_Vector: + sCtorFromVoidStar_T<ZSeq_ZooLib>(fType.fBytes, iOther.fType.fBytes); + break; + default: + ZDebugStopf(kDebug_Tuple, ("Unknown type (%d)", fType.fType)); + } + } + } + +void ZVal_ZooLib::pFromStream(ZType iType, const ZStreamR& iStreamR) + { + switch (iType) + { + case eZType_Null: + { + // No data to read. + break; + } + case eZType_Type: + { + fData.fAs_Type = ZType(iStreamR.ReadUInt8()); + break; + } + case eZType_ID: + { + fData.fAs_ID = iStreamR.ReadUInt64(); + break; + } + case eZType_Int8: + { + fData.fAs_Int8 = iStreamR.ReadUInt8(); + break; + } + case eZType_Int16: + { + fData.fAs_Int16 = iStreamR.ReadUInt16(); + break; + } + case eZType_Int32: + { + fData.fAs_Int32 = iStreamR.ReadUInt32(); + break; + } + case eZType_Int64: + { + fData.fAs_Int64 = iStreamR.ReadUInt64(); + break; + } + case eZType_Bool: + { + fData.fAs_Bool = iStreamR.ReadUInt8(); + break; + } + case eZType_Float: + { + fData.fAs_Float = iStreamR.ReadFloat(); + break; + } + case eZType_Double: + { + fData.fAs_Double = iStreamR.ReadDouble(); + break; + } + case eZType_Time: + { + fData.fAs_Time = iStreamR.ReadDouble(); + break; + } + case eZType_Pointer: + { + fData.fAs_Pointer = reinterpret_cast<void*>(iStreamR.ReadUInt32()); + break; + } + case eZType_Rect: + { + ZRectPOD* theRect = new ZRectPOD; + try + { + theRect->left = iStreamR.ReadUInt32(); + theRect->top = iStreamR.ReadUInt32(); + theRect->right = iStreamR.ReadUInt32(); + theRect->bottom = iStreamR.ReadUInt32(); + } + catch (...) + { + delete theRect; + throw; + } + fData.fAs_Rect = theRect; + break; + } + case eZType_Point: + { + fData.fAs_Point.h = iStreamR.ReadUInt32(); + fData.fAs_Point.v = iStreamR.ReadUInt32(); + break; + } + case eZType_String: + { + uint32 theSize = iStreamR.ReadCount(); + if (spIsSpecialString(theSize)) + { + iType = (ZType)(-int(theSize)-1); + if (theSize) + iStreamR.Read(fType.fBytes, theSize); + } + else + { + sCtor_T<ValString>(fType.fBytes, iStreamR, theSize); + } + break; + } +#if 0//## + case eZType_Name: + { + sCtor_T<ZTName>(fType.fBytes, iStreamR); + break; + } +#endif//## + case eZType_Tuple: + { + sCtor_T<ZMap_ZooLib>(fType.fBytes, iStreamR); + break; + } + case eZType_RefCounted: + { + // Construct a nil refcounted. + sCtor_T<ZRef<ZCounted> >(fType.fBytes); + break; + } + case eZType_Raw: + { + uint32 size = iStreamR.ReadCount(); + ZData_ZooLib* theRaw = sCtor_T<ZData_ZooLib>(fType.fBytes, size); + if (size) + { + try + { + iStreamR.Read(theRaw->GetDataMutable(), size); + } + catch (...) + { + delete theRaw; + throw; + } + } + break; + } + case eZType_Vector: + { + sCtor_T<ZSeq_ZooLib>(fType.fBytes, iStreamR); + break; + } + default: + { + throw Ex_IllegalType(iType); + } + } + fType.fType = ZType(iType); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZSeq_ZooLib::Rep + +class ZSeq_ZooLib::Rep : public ZCountedWithoutFinalize + { +public: + Rep(); + Rep(const std::vector<ZVal_ZooLib>& iOther); + virtual ~Rep(); + + std::vector<ZVal_ZooLib> fVector; + }; + +ZSeq_ZooLib::Rep::Rep() + {} + +ZSeq_ZooLib::Rep::Rep(const vector<ZVal_ZooLib>& iOther) +: fVector(iOther) + {} + +ZSeq_ZooLib::Rep::~Rep() + {} + +// ================================================================================================= +#pragma mark - +#pragma mark * ZSeq_ZooLib + +ZSeq_Any ZSeq_ZooLib::AsSeq_Any(const ZAny& iDefault) const + { + ZSeq_Any theSeq; + if (fRep) + { + if (size_t theCount = fRep->fVector.size()) + { + for (size_t x = 0; x < theCount; ++x) + theSeq.Append(fRep->fVector[x].DAsAny(iDefault)); + } + } + return theSeq; + } + +ZSeq_ZooLib::operator operator_bool_type() const + { return operator_bool_generator_type::translate(fRep && !fRep->fVector.empty()); } + +ZSeq_ZooLib::ZSeq_ZooLib() + {} + +ZSeq_ZooLib::ZSeq_ZooLib(const ZSeq_ZooLib& iOther) +: fRep(iOther.fRep) + {} + +ZSeq_ZooLib::~ZSeq_ZooLib() + {} + +ZSeq_ZooLib& ZSeq_ZooLib::operator=(const ZSeq_ZooLib& iOther) + { + fRep = iOther.fRep; + return *this; + } + +ZSeq_ZooLib::ZSeq_ZooLib(const ZStreamR& iStreamR) + { + if (uint32 theCount = iStreamR.ReadCount()) + { + fRep = new Rep; + fRep->fVector.reserve(theCount); + for (size_t x = 0; x < theCount; ++x) + fRep->fVector.push_back(ZVal_ZooLib(iStreamR)); + } + } + +ZSeq_ZooLib::ZSeq_ZooLib(size_t iCount, const ZVal_ZooLib& iSingleton) +: fRep(new Rep(vector<ZVal_ZooLib>(iCount, iSingleton))) + {} + +ZSeq_ZooLib::ZSeq_ZooLib(const vector<ZVal_ZooLib>& iOther) +: fRep(new Rep(vector<ZVal_ZooLib>(iOther))) + {} + +size_t ZSeq_ZooLib::Count() const + { + if (fRep) + return fRep->fVector.size(); + return 0; + } + +void ZSeq_ZooLib::Clear() + { fRep.Clear(); } + +bool ZSeq_ZooLib::QGet(size_t iIndex, ZVal_ZooLib& oVal) const + { + if (fRep && iIndex < fRep->fVector.size()) + { + oVal = fRep->fVector.at(iIndex); + return true; + } + return false; + } + +ZVal_ZooLib ZSeq_ZooLib::DGet(const ZVal_ZooLib& iDefault, size_t iIndex) const + { + if (fRep && iIndex < fRep->fVector.size()) + return fRep->fVector.at(iIndex); + return iDefault; + } + +ZVal_ZooLib ZSeq_ZooLib::Get(size_t iIndex) const + { + if (fRep && iIndex < fRep->fVector.size()) + return fRep->fVector.at(iIndex); + return spNilVal; + } + +const ZVal_ZooLib& ZSeq_ZooLib::RGet(size_t iIndex) const + { + if (fRep && iIndex < fRep->fVector.size()) + return fRep->fVector.at(iIndex); + return spNilVal; + } + +ZSeq_ZooLib& ZSeq_ZooLib::Set(size_t iIndex, const ZVal_ZooLib& iVal) + { + this->pTouch(); + vector<ZVal_ZooLib>& theVec = fRep->fVector; + if (iIndex < theVec.size()) + *(theVec.begin() + iIndex) = iVal; + return *this; + } + +ZSeq_ZooLib& ZSeq_ZooLib::Erase(size_t iIndex) + { + this->pTouch(); + vector<ZVal_ZooLib>& theVec = fRep->fVector; + if (iIndex < theVec.size()) + theVec.erase(theVec.begin() + iIndex); + return *this; + } + +ZSeq_ZooLib& ZSeq_ZooLib::Insert(size_t iIndex, const ZVal_ZooLib& iVal) + { + this->pTouch(); + vector<ZVal_ZooLib>& theVec = fRep->fVector; + if (iIndex <= theVec.size()) + theVec.insert(theVec.begin() + iIndex, iVal); + return *this; + } + +ZSeq_ZooLib& ZSeq_ZooLib::Append(const ZVal_ZooLib& iVal) + { + this->pTouch(); + fRep->fVector.push_back(iVal); + return *this; + } + +int ZSeq_ZooLib::Compare(const ZSeq_ZooLib& iOther) const + { + if (fRep) + { + if (iOther.fRep) + { + return sCompare_T(fRep->fVector, iOther.fRep->fVector); + } + else + { + return 1; + } + } + else if (iOther.fRep) + { + return -1; + } + else + { + return 0; + } + } + +bool ZSeq_ZooLib::operator==(const ZSeq_ZooLib& iOther) const + { return this->Compare(iOther) == 0; } + +bool ZSeq_ZooLib::operator<(const ZSeq_ZooLib& iOther) const + { return this->Compare(iOther) < 0; } + +ZVal_ZooLib& ZSeq_ZooLib::Mutable(size_t iIndex) + { + ZAssert(fRep && iIndex < fRep->fVector.size()); + return fRep->fVector.at(iIndex); + } + +vector<ZVal_ZooLib>& ZSeq_ZooLib::MutableVector() + { + this->pTouch(); + return fRep->fVector; + } + +const vector<ZVal_ZooLib>& ZSeq_ZooLib::GetVector() const + { + if (fRep) + return fRep->fVector; + return spNilVector; + } + +void ZSeq_ZooLib::ToStream(const ZStreamW& iStreamW) const + { + if (fRep) + { + const vector<ZVal_ZooLib>& theVec = fRep->fVector; + if (size_t theCount = theVec.size()) + { + iStreamW.WriteCount(theCount); + for (size_t x = 0; x < theCount; ++x) + { + // Sigh, older linux headers don't have vector::at + // theVector->at(x).ToStream(iStreamW); + theVec.operator[](x).ToStream(iStreamW); + } + return; + } + } + iStreamW.WriteCount(0); + } + +void ZSeq_ZooLib::pTouch() + { + if (fRep) + { + if (fRep->IsShared()) + fRep = new Rep(fRep->fVector); + } + else + { + fRep = new Rep; + } + } + +// ================================================================================================= +#pragma mark - +#pragma mark * NameVal inlines + +NameVal::NameVal(const ZStreamR& iStreamR) +: fName(iStreamR) + { + // We have to load the val here, because for layout reasons we need fVal + // to come before fName, but for streaming we write fName before fVal. + fVal = ZVal_ZooLib(iStreamR); + } + +inline NameVal::NameVal() + {} + +inline NameVal::NameVal(const NameVal& iOther) +: fVal(iOther.fVal), + fName(iOther.fName) + {} + +inline NameVal::NameVal(const char* iName, const ZVal_ZooLib& iVal) +: fVal(iVal), + fName(iName) + {} + +inline NameVal::NameVal(const ZTName& iName, const ZVal_ZooLib& iVal) +: fVal(iVal), + fName(iName) + {} + +inline NameVal::NameVal(const char* iName) +: fName(iName) + {} + +inline NameVal::NameVal(const ZTName& iName) +: fName(iName) + {} + +void NameVal::ToStream(const ZStreamW& iStreamW) const + { + fName.ToStream(iStreamW); + fVal.ToStream(iStreamW); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZMap_ZooLib::Rep + +class ZMap_ZooLib::Rep : public ZCountedWithoutFinalize + { +public: + Rep(); + Rep(const ZMap_ZooLib::PropList& iProperties); + virtual ~Rep(); + + ZMap_ZooLib::PropList fProperties; + }; + +ZMap_ZooLib::Rep::Rep() + {} + +ZMap_ZooLib::Rep::Rep(const ZMap_ZooLib::PropList& iProperties) +: fProperties(iProperties) + {} + +ZMap_ZooLib::Rep::~Rep() + {} + +// ================================================================================================= +#pragma mark - +#pragma mark * ZMap_ZooLib + +ZMap_Any ZMap_ZooLib::AsMap_Any(const ZAny& iDefault) const + { + ZMap_Any theMap; + if (fRep) + { + for (Index_t i = fRep->fProperties.begin(), end = fRep->fProperties.end(); + i != end; ++i) + { + theMap.Set((*i).fName.AsString(), (*i).fVal.DAsAny(iDefault)); + } + } + return theMap; + } + +ZMap_ZooLib::operator operator_bool_type() const + { return operator_bool_generator_type::translate(fRep && !fRep->fProperties.empty()); } + +ZMap_ZooLib::ZMap_ZooLib() + {} + +ZMap_ZooLib::ZMap_ZooLib(const ZMap_ZooLib& iOther) +: fRep(iOther.fRep) + {} + +ZMap_ZooLib::~ZMap_ZooLib() + {} + +ZMap_ZooLib& ZMap_ZooLib::operator=(const ZMap_ZooLib& iOther) + { + fRep = iOther.fRep; + return *this; + } + +ZMap_ZooLib::ZMap_ZooLib(const ZStreamR& iStreamR) +: fRep(sRepFromStream(iStreamR)) + {} + +ZMap_ZooLib::ZMap_ZooLib(ZRef<Rep> iRep) +: fRep(iRep) + {} + +void ZMap_ZooLib::Clear() + { fRep.Clear(); } + +ZVal_ZooLib* ZMap_ZooLib::PGet(Index_t iIndex) + { + if (fRep && iIndex != fRep->fProperties.end()) + { + iIndex = this->pTouch(iIndex); + return &(*iIndex).fVal; + } + return nullptr; + } + +ZVal_ZooLib* ZMap_ZooLib::PGet(const char* iPropName) + { + this->pTouch(); + + ZAssertStop(kDebug_Tuple, fRep); + + size_t propNameLength = strlen(iPropName); + for (PropList::iterator i = fRep->fProperties.begin(), + theEnd = fRep->fProperties.end(); + i != theEnd; ++i) + { + if ((*i).fName.Equals(iPropName, propNameLength)) + return &(*i).fVal; + } + + return nullptr; + } + +ZVal_ZooLib* ZMap_ZooLib::PGet(const ZTName& iPropName) + { + this->pTouch(); + + ZAssertStop(kDebug_Tuple, fRep); + + for (PropList::iterator i = fRep->fProperties.begin(), + theEnd = fRep->fProperties.end(); + i != theEnd; ++i) + { + if ((*i).fName.Equals(iPropName)) + return &(*i).fVal; + } + + return nullptr; + } + +const ZVal_ZooLib* ZMap_ZooLib::PGet(Index_t iIndex) const + { + if (fRep && iIndex != fRep->fProperties.end()) + return &(*iIndex).fVal; + return nullptr; + } + +const ZVal_ZooLib* ZMap_ZooLib::PGet(const char* iPropName) const + { + if (fRep) + { + size_t propNameLength = strlen(iPropName); + for (PropList::const_iterator i = fRep->fProperties.begin(), + theEnd = fRep->fProperties.end(); + i != theEnd; ++i) + { + if ((*i).fName.Equals(iPropName, propNameLength)) + return &(*i).fVal; + } + } + return nullptr; + } + +const ZVal_ZooLib* ZMap_ZooLib::PGet(const ZTName& iPropName) const + { + if (fRep) + { + for (PropList::const_iterator i = fRep->fProperties.begin(), + theEnd = fRep->fProperties.end(); + i != theEnd; ++i) + { + if ((*i).fName.Equals(iPropName)) + return &(*i).fVal; + } + } + return nullptr; + } + +bool ZMap_ZooLib::QGet(Index_t iIndex, ZVal_ZooLib& oVal) const + { + if (const ZVal_ZooLib* theValue = this->PGet(iIndex)) + { + oVal = *theValue; + return true; + } + return false; + } + +bool ZMap_ZooLib::QGet(const char* iPropName, ZVal_ZooLib& oVal) const + { + if (const ZVal_ZooLib* theValue = this->PGet(iPropName)) + { + oVal = *theValue; + return true; + } + return false; + } + +bool ZMap_ZooLib::QGet(const ZTName& iPropName, ZVal_ZooLib& oVal) const + { + if (const ZVal_ZooLib* theValue = this->PGet(iPropName)) + { + oVal = *theValue; + return true; + } + return false; + } + +ZVal_ZooLib ZMap_ZooLib::DGet(const ZVal_ZooLib& iDefault, Index_t iIndex) const + { + if (const ZVal_ZooLib* theValue = this->PGet(iIndex)) + return *theValue; + return iDefault; + } + +ZVal_ZooLib ZMap_ZooLib::DGet(const ZVal_ZooLib& iDefault, const char* iPropName) const + { + if (const ZVal_ZooLib* theValue = this->PGet(iPropName)) + return *theValue; + return iDefault; + } + +ZVal_ZooLib ZMap_ZooLib::DGet(const ZVal_ZooLib& iDefault, const ZTName& iPropName) const + { + if (const ZVal_ZooLib* theValue = this->PGet(iPropName)) + return *theValue; + return iDefault; + } + +ZVal_ZooLib ZMap_ZooLib::Get(Index_t iIndex) const + { + if (const ZVal_ZooLib* theValue = this->PGet(iIndex)) + return *theValue; + return spNilVal; + } + +ZVal_ZooLib ZMap_ZooLib::Get(const char* iPropName) const + { + if (const ZVal_ZooLib* theValue = this->PGet(iPropName)) + return *theValue; + return spNilVal; + } + +ZVal_ZooLib ZMap_ZooLib::Get(const ZTName& iPropName) const + { + if (const ZVal_ZooLib* theValue = this->PGet(iPropName)) + return *theValue; + return spNilVal; + } + +ZMap_ZooLib& ZMap_ZooLib::Set(Index_t iIndex, const ZVal_ZooLib& iVal) + { + this->pSet(iIndex, iVal); + return *this; + } + +ZMap_ZooLib& ZMap_ZooLib::Set(const char* iPropName, const ZVal_ZooLib& iVal) + { + this->pSet(iPropName, iVal); + return *this; + } + +ZMap_ZooLib& ZMap_ZooLib::Set(const ZTName& iPropName, const ZVal_ZooLib& iVal) + { + this->pSet(iPropName, iVal); + return *this; + } + +ZMap_ZooLib& ZMap_ZooLib::Erase(Index_t iIndex) + { + if (fRep) + this->pErase(iIndex); + return *this; + } + +ZMap_ZooLib& ZMap_ZooLib::Erase(const char* iPropName) + { + if (fRep) + this->pErase(this->IndexOf(iPropName)); + return *this; + } + +ZMap_ZooLib& ZMap_ZooLib::Erase(const ZTName& iPropName) + { + if (fRep) + this->pErase(this->IndexOf(iPropName)); + return *this; + } + +int ZMap_ZooLib::Compare(const ZMap_ZooLib& iOther) const + { + if (fRep == iOther.fRep) + { + // We share the same rep, so we're identical. + return 0; + } + + if (!fRep) + { + // We have no rep, and iOther must have a rep (or fRep would be == iOther.fRep). + if (iOther.fRep->fProperties.empty()) + { + // And iOther's property list is empty, we're equivalent. + return 0; + } + else + { + // iOther has properties, so we're less than it. + return -1; + } + } + + if (not iOther.fRep) + { + // iOther has no rep. + if (fRep->fProperties.empty()) + { + // And our property list is empty, so we're equivalent. + return 0; + } + else + { + // We have properties, so we're greater than iOther. + return 1; + } + } + + for (PropList::const_iterator iterThis = fRep->fProperties.begin(), + iterOther = iOther.fRep->fProperties.begin(), + endThis = fRep->fProperties.end(), + endOther = iOther.fRep->fProperties.end(); + /*no test*/; ++iterThis, ++iterOther) + { + if (iterThis != endThis) + { + // This is not exhausted. + if (iterOther != endOther) + { + // Other is not exhausted either, so we compare their current values. + if (int compare = (*iterThis).fName.Compare((*iterOther).fName)) + { + // The names are different. + return compare; + } + if (int compare = (*iterThis).fVal.Compare((*iterOther).fVal)) + { + // The values are different. + return compare; + } + } + else + { + // Exhausted other, but still have this + // remaining, so this is greater than other. + return 1; + } + } + else + { + // Exhausted this. + if (iterOther != endOther) + { + // Still have other remaining, so this is less than other. + return -1; + } + else + { + // Exhausted other. And as this is also + // exhausted this equals other. + return 0; + } + } + } + } + +bool ZMap_ZooLib::operator==(const ZMap_ZooLib& iOther) const + { return this->Compare(iOther) == 0; } + +bool ZMap_ZooLib::operator<(const ZMap_ZooLib& iOther) const + { return this->Compare(iOther) < 0; } + +ZVal_ZooLib& ZMap_ZooLib::Mutable(Index_t iIndex) + { + ZAssert(fRep && iIndex != fRep->fProperties.end()); + iIndex = this->pTouch(iIndex); + return (*iIndex).fVal; + } + +ZVal_ZooLib& ZMap_ZooLib::Mutable(const char* iPropName) + { return *this->pFindOrAllocate(iPropName); } + +ZVal_ZooLib& ZMap_ZooLib::Mutable(const ZTName& iPropName) + { return *this->pFindOrAllocate(iPropName); } + +ZMap_ZooLib::Index_t ZMap_ZooLib::Begin() const + { + if (fRep) + return fRep->fProperties.begin(); + return spEmptyProperties.end(); + } + +ZMap_ZooLib::Index_t ZMap_ZooLib::End() const + { + if (fRep) + return fRep->fProperties.end(); + return spEmptyProperties.end(); + } + +bool ZMap_ZooLib::Empty() const + { return !fRep || fRep->fProperties.empty(); } + +size_t ZMap_ZooLib::Count() const + { + if (fRep) + return fRep->fProperties.size(); + return 0; + } + +const ZTName& ZMap_ZooLib::NameOf(Index_t iIndex) const + { + if (fRep && iIndex != fRep->fProperties.end()) + return (*iIndex).fName; + return spNilName; + } + +ZMap_ZooLib::Index_t ZMap_ZooLib::IndexOf(const char* iPropName) const + { + if (fRep) + { + size_t propNameLength = strlen(iPropName); + Index_t end = fRep->fProperties.end(); + for (Index_t i = fRep->fProperties.begin(); i != end; ++i) + { + if ((*i).fName.Equals(iPropName, propNameLength)) + return i; + } + return end; + } + return spEmptyProperties.end(); + } + +ZMap_ZooLib::Index_t ZMap_ZooLib::IndexOf(const ZTName& iPropName) const + { + if (fRep) + { + Index_t end = fRep->fProperties.end(); + for (Index_t i = fRep->fProperties.begin(); i != end; ++i) + { + if ((*i).fName.Equals(iPropName)) + return i; + } + return end; + } + return spEmptyProperties.end(); + } + +ZMap_ZooLib::Index_t ZMap_ZooLib::IndexOf + (const ZMap_ZooLib& iOther, const Index_t& iOtherIndex) const + { + if (fRep == iOther.fRep) + return iOtherIndex; + + return this->IndexOf(iOther.NameOf(iOtherIndex)); + } + +bool ZMap_ZooLib::Has(const char* iPropName) const + { return this->PGet(iPropName); } + +bool ZMap_ZooLib::Has(const ZTName& iPropName) const + { return this->PGet(iPropName); } + +void ZMap_ZooLib::ToStream(const ZStreamW& iStreamW) const + { + if (!fRep || fRep->fProperties.empty()) + { + iStreamW.WriteCount(0); + } + else + { + const PropList& properties = fRep->fProperties; + iStreamW.WriteCount(properties.size()); + for (PropList::const_iterator i = properties.begin(); i != properties.end(); ++i) + (*i).ToStream(iStreamW); + } + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZMap_ZooLib internal implementation + +void ZMap_ZooLib::pSet(Index_t iIndex, const ZVal_ZooLib& iVal) + { + if (ZVal_ZooLib* theVal = this->PGet(iIndex)) + *theVal = iVal; + } + +void ZMap_ZooLib::pSet(const char* iPropName, const ZVal_ZooLib& iVal) + { *pFindOrAllocate(iPropName) = iVal; } + +void ZMap_ZooLib::pSet(const ZTName& iPropName, const ZVal_ZooLib& iVal) + { *pFindOrAllocate(iPropName) = iVal; } + +ZVal_ZooLib* ZMap_ZooLib::pFin... [truncated message content] |
From: <ag...@us...> - 2011-07-25 00:40:08
|
Revision: 2426 http://zoolib.svn.sourceforge.net/zoolib/?rev=2426&view=rev Author: agreen Date: 2011-07-25 00:40:00 +0000 (Mon, 25 Jul 2011) Log Message: ----------- Move to old. Added Paths: ----------- trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStrim.cpp trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStrim.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZYad_ZooLibStrim.cpp trunk/zoolib/source/cxx/zoolib/ZYad_ZooLibStrim.h Added: trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStrim.cpp =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStrim.cpp (rev 0) +++ trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStrim.cpp 2011-07-25 00:40:00 UTC (rev 2426) @@ -0,0 +1,1183 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2008 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZGeomPOD.h" +#include "zoolib/ZStreamW_HexStrim.h" +#include "zoolib/ZStrimR_Boundary.h" +#include "zoolib/ZStrim_Escaped.h" +#include "zoolib/ZUnicode.h" +#include "zoolib/ZUtil_Strim.h" +#include "zoolib/ZUtil_Strim_Operators.h" +#include "zoolib/ZUtil_Time.h" +#include "zoolib/ZYad_ZooLibStrim.h" + +#include "../old/zoolib/ZVal_ZooLib.h" // For ZType enum + +#include <vector> + +namespace ZooLib { + +using std::min; +using std::string; +using std::vector; + +// ================================================================================================= +#pragma mark - +#pragma mark * Static parsing functions + +static void spThrowParseException(const string& iMessage) + { + throw ZYadParseException_ZooLibStrim(iMessage); + } + +static bool spTryRead_PropertyName(const ZStrimU& iStrimU, string& oName) + { + using namespace ZUtil_Strim; + + if (!sTryRead_EscapedString(iStrimU, '"', oName)) + { + if (!sTryRead_EscapedString(iStrimU, '\'', oName)) + { + if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, nullptr, &oName)) + return false; + } + } + + return true; + } + +static int64 spMustRead_GenericInteger(const ZStrimU& iStrimU) + { + using namespace ZUtil_Strim; + int64 theInteger; + if (!sTryRead_SignedGenericInteger(iStrimU, theInteger)) + spThrowParseException("Expected an integer"); + return theInteger; + } + +static void spMustRead_WSCommaWS(const ZStrimU& iStrimU) + { + using namespace ZUtil_Strim; + sSkip_WSAndCPlusPlusComments(iStrimU); + + if (!sTryRead_CP(iStrimU, ',')) + spThrowParseException("Expected a ','"); + + sSkip_WSAndCPlusPlusComments(iStrimU); + } + +static bool spFromStrim_Value(const ZStrimU& iStrimU, ZAny& oVal) + { + using namespace ZUtil_Strim; + + sSkip_WSAndCPlusPlusComments(iStrimU); + + if (false) + {} +#if 0//## + else if (sTryRead_CP(iStrimU, '@')) + { + // It's a property name. + string propertyName; + if (!sTryRead_EscapedString(iStrimU, '"', propertyName)) + { + if (!sTryRead_EscapedString(iStrimU, '\'', propertyName)) + { + if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, nullptr, &propertyName)) + spThrowParseException("Expected a property name after '#'"); + } + } + oVal.SetName(propertyName); + } +#endif + else + { + string theTypeLC, theType; + if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, &theTypeLC, &theType)) + { + // We couldn't find any of the special characters, nor could + // we read a type designator, so we fail to read a value, + // which is not a parse error at this stage -- it might be for our caller. + return false; + } + + if (theTypeLC == "null") + { + oVal = ZAny(); + } + else if (theTypeLC == "false") + { + oVal = false; + } + else if (theTypeLC == "true") + { + oVal = true; + } + else + { + sSkip_WSAndCPlusPlusComments(iStrimU); + if (!sTryRead_CP(iStrimU, '(')) + spThrowParseException("Expected '(' following a type designator"); + + sSkip_WSAndCPlusPlusComments(iStrimU); + + if (theTypeLC == "type") + { + string typeValueLC, typeValue; + if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, &typeValueLC, &typeValue)) + spThrowParseException("Expected a type name"); + + if (typeValueLC == "null") oVal = eZType_Null; + else if (typeValueLC == "string") oVal = eZType_String; +// AG 2007-08-06. cstring has never been used. Not even sure what it's point was. +// else if (typeValueLC == "cstring") oVal = eZType_CString; + else if (typeValueLC == "int8") oVal = eZType_Int8; + else if (typeValueLC == "int16") oVal = eZType_Int16; + else if (typeValueLC == "int32") oVal = eZType_Int32; + else if (typeValueLC == "int64") oVal = eZType_Int64; + else if (typeValueLC == "float") oVal = eZType_Float; + else if (typeValueLC == "double") oVal = eZType_Double; + else if (typeValueLC == "time") oVal = eZType_Time; + else if (typeValueLC == "bool") oVal = eZType_Bool; + else if (typeValueLC == "pointer") oVal = eZType_Pointer; + else if (typeValueLC == "raw") oVal = eZType_Raw; + else if (typeValueLC == "tuple") oVal = eZType_Tuple; + else if (typeValueLC == "refcounted") oVal = eZType_RefCounted; + else if (typeValueLC == "rect") oVal = eZType_Rect; + else if (typeValueLC == "point") oVal = eZType_Point; + else if (typeValueLC == "region") oVal = eZType_Region; + else if (typeValueLC == "id") oVal = eZType_ID; + else if (typeValueLC == "vector") oVal = eZType_Vector; + else if (typeValueLC == "type") oVal = eZType_Type; + else if (typeValueLC == "time") oVal = eZType_Time; +//## else if (typeValueLC == "name") oVal = eZType_Name; + else + spThrowParseException("Unknown type name '" + typeValue + "'"); + } + else if (theTypeLC == "id") + { + oVal = uint64(spMustRead_GenericInteger(iStrimU)); + } + else if (theTypeLC == "int8") + { + oVal = int8(spMustRead_GenericInteger(iStrimU)); + } + else if (theTypeLC == "int16") + { + oVal = int16(spMustRead_GenericInteger(iStrimU)); + } + else if (theTypeLC == "int32") + { + oVal = int32(spMustRead_GenericInteger(iStrimU)); + } + else if (theTypeLC == "int64") + { + oVal = int64(spMustRead_GenericInteger(iStrimU)); + } + else if (theTypeLC == "bool") + { + string theBool; + if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, &theBool, nullptr)) + spThrowParseException("Expected 'false' or 'true'"); + + if (theBool == "true") + oVal = true; + else if (theBool == "false") + oVal = false; + else + spThrowParseException("Expected 'false' or 'true'"); + } + else if (theTypeLC == "float") + { + double theDouble; + if (!sTryRead_SignedDouble(iStrimU, theDouble)) + spThrowParseException("Expected a floating point number"); + oVal = float(theDouble); + } + else if (theTypeLC == "double") + { + double theDouble; + if (!sTryRead_SignedDouble(iStrimU, theDouble)) + spThrowParseException("Expected a floating point number"); + oVal = theDouble; + } + else if (theTypeLC == "time") + { + if (sTryRead_CP(iStrimU, ')')) + { + // It's a time with no content, hence an invalid time. + oVal = ZTime(); + + // We'll take an early exit so the normal code that + // looks for a closing parenthesis doesn't choke. + return true; + } + + // Read up till the closing paren, if any. + const string8 theContent = sRead_Until(iStrimU, ')'); + if (const ZTime theTime = ZUtil_Time::sFromString_ISO8601(theContent)) + { + oVal = theTime; + return true; + } + + double theDouble; + if (sTryRead_SignedDouble(ZStrimU_String(theContent), theDouble)) + { + oVal = ZTime(theDouble); + return true; + } + + spThrowParseException("Expected a floating point time"); + } + else if (theTypeLC == "rect") + { + ZRectPOD theRect; + + theRect.left = spMustRead_GenericInteger(iStrimU); + + spMustRead_WSCommaWS(iStrimU); + + theRect.top = spMustRead_GenericInteger(iStrimU); + + spMustRead_WSCommaWS(iStrimU); + + theRect.right = spMustRead_GenericInteger(iStrimU); + + spMustRead_WSCommaWS(iStrimU); + + theRect.bottom = spMustRead_GenericInteger(iStrimU); + + oVal = theRect; + } + else if (theTypeLC == "point") + { + ZPointPOD thePoint; + + thePoint.h = spMustRead_GenericInteger(iStrimU); + + spMustRead_WSCommaWS(iStrimU); + + thePoint.v = spMustRead_GenericInteger(iStrimU); + + oVal = thePoint; + } + else + { + spThrowParseException("Unknown type designator '" + theType + "'"); + } + + sSkip_WSAndCPlusPlusComments(iStrimU); + + if (!sTryRead_CP(iStrimU, ')')) + spThrowParseException("Expected ')' to close a value"); + } + } + return true; + } + +static ZRef<ZYadR> spMakeYadR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU) + { + using namespace ZUtil_Strim; + + const ZStrimU& theStrimU = iStrimmerU->GetStrimU(); + + sSkip_WSAndCPlusPlusComments(theStrimU); + + if (sTryRead_CP(theStrimU, '[')) + { + return new ZYadSeqR_ZooLibStrim(iStrimmerU, true); + } + else if (sTryRead_CP(theStrimU, '{')) + { + return new ZYadMapR_ZooLibStrim(iStrimmerU, true); + } + else if (sTryRead_CP(theStrimU, '(')) + { + return new ZYadStreamR_ZooLibStrim(iStrimmerU, true); + } + else if (sTryRead_CP(theStrimU, '"')) + { + return new ZYadStrimR_ZooLibStrim_Quote(iStrimmerU); + } + else if (sTryRead_CP(theStrimU, '\'')) + { + return new ZYadStrimR_ZooLibStrim_Apos(iStrimmerU); + } + else + { + ZAny theVal; + if (spFromStrim_Value(theStrimU, theVal)) + return new ZYadAtomR_Any(theVal); + } + + return null; + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadParseException_ZooLibStrim + +ZYadParseException_ZooLibStrim::ZYadParseException_ZooLibStrim(const string& iWhat) +: ZYadParseException_Std(iWhat) + {} + +ZYadParseException_ZooLibStrim::ZYadParseException_ZooLibStrim(const char* iWhat) +: ZYadParseException_Std(iWhat) + {} + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadStreamR_ZooLibStrim + +ZYadStreamR_ZooLibStrim::ZYadStreamR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU, bool iReadDelimiter) +: fStrimmerU(iStrimmerU), + fReadDelimiter(iReadDelimiter), + fStreamR(fStrimmerU->GetStrimU()) + {} + +void ZYadStreamR_ZooLibStrim::Finish() + { + using namespace ZUtil_Strim; + + fStreamR.SkipAll(); + + if (fReadDelimiter) + { + const ZStrimU& theStrimU = fStrimmerU->GetStrimU(); + sSkip_WSAndCPlusPlusComments(theStrimU); + if (!sTryRead_CP(theStrimU, ')')) + spThrowParseException("Expected ')' to close a raw"); + } + } + +const ZStreamR& ZYadStreamR_ZooLibStrim::GetStreamR() + { return fStreamR; } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadStrimR_ZooLibStrim_Apos + +ZYadStrimR_ZooLibStrim_Apos::ZYadStrimR_ZooLibStrim_Apos(ZRef<ZStrimmerU> iStrimmerU) +: fStrimmerU(iStrimmerU), + fStrimR(fStrimmerU->GetStrimU(), '\'') + {} + +void ZYadStrimR_ZooLibStrim_Apos::Finish() + { + using namespace ZUtil_Strim; + fStrimR.SkipAll(); + if (!sTryRead_CP(fStrimmerU->GetStrimU(), '\'')) + throw ParseException("Missing string delimiter"); + } + +const ZStrimR& ZYadStrimR_ZooLibStrim_Apos::GetStrimR() + { return fStrimR; } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadStrimR_ZooLibStrim_Quote + +ZYadStrimR_ZooLibStrim_Quote::ZYadStrimR_ZooLibStrim_Quote(ZRef<ZStrimmerU> iStrimmerU) +: fStrimmerU(iStrimmerU), + fStrimR_Boundary("\"\"\"", fStrimmerU->GetStrimR()), + fQuotesSeen(1) + {} + +void ZYadStrimR_ZooLibStrim_Quote::Finish() + { this->SkipAll(); } + +const ZStrimR& ZYadStrimR_ZooLibStrim_Quote::GetStrimR() + { return *this; } + +void ZYadStrimR_ZooLibStrim_Quote::Imp_ReadUTF32(UTF32* oDest, size_t iCount, size_t* oCount) + { + using namespace ZUtil_Strim; + + const ZStrimU& theStrimU = fStrimmerU->GetStrimU(); + + UTF32* localDest = oDest; + UTF32* localDestEnd = oDest + iCount; + bool exhausted = false; + while (localDestEnd > localDest && !exhausted) + { + switch (fQuotesSeen) + { + case 0: + { + sSkip_WSAndCPlusPlusComments(theStrimU); + + if (sTryRead_CP(theStrimU, '"')) + fQuotesSeen = 1; + else + exhausted = true; + break; + } + case 1: + { + if (sTryRead_CP(theStrimU, '"')) + { + fQuotesSeen = 2; + } + else + { + size_t countRead; + ZStrimR_Escaped(theStrimU, '"') + .Read(localDest, localDestEnd - localDest, &countRead); + localDest += countRead; + + if (sTryRead_CP(theStrimU, '"')) + fQuotesSeen = 0; + else if (countRead == 0) + spThrowParseException("Expected \" to close a string"); + } + break; + } + case 2: + { + if (sTryRead_CP(theStrimU, '"')) + { + fQuotesSeen = 3; + UTF32 theCP = theStrimU.ReadCP(); + if (not ZUnicode::sIsEOL(theCP)) + theStrimU.Unread(theCP); + } + else + { + // We have two quotes in a row, followed by something + // else, so we had an empty string segment. + fQuotesSeen = 0; + } + break; + } + case 3: + { + // We've got three quotes in a row, and any trailing EOL + // has been stripped. + size_t countRead; + fStrimR_Boundary.Read(localDest, localDestEnd - localDest, &countRead); + localDest += countRead; + if (countRead == 0) + { + if (!fStrimR_Boundary.HitBoundary()) + spThrowParseException("Expected \"\"\" to close a string"); + fStrimR_Boundary.Reset(); + fQuotesSeen = 0; + } + break; + } + } + } + + if (oCount) + *oCount = localDest - oDest; + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadSeqR_ZooLibStrim + +ZYadSeqR_ZooLibStrim::ZYadSeqR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU, bool iReadDelimiter) +: fStrimmerU(iStrimmerU), + fReadDelimiter(iReadDelimiter) + {} + +void ZYadSeqR_ZooLibStrim::Imp_ReadInc(bool iIsFirst, ZRef<ZYadR>& oYadR) + { + using namespace ZUtil_Strim; + + const ZStrimU& theStrimU = fStrimmerU->GetStrimU(); + + sSkip_WSAndCPlusPlusComments(theStrimU); + + bool gotSeparator = true; + if (not iIsFirst) + { + if (!sTryRead_CP(theStrimU, ',') && !sTryRead_CP(theStrimU, ';')) + gotSeparator = false; + else + sSkip_WSAndCPlusPlusComments(theStrimU); + } + + if (fReadDelimiter) + { + if (sTryRead_CP(theStrimU, ']')) + return; + } + + if (!gotSeparator) + spThrowParseException("Expected ';' or ',' between values"); + + if (!(oYadR = spMakeYadR_ZooLibStrim(fStrimmerU))) + { + if (!fReadDelimiter) + return; + spThrowParseException("Expected a value"); + } + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadMapR_ZooLibStrim + +ZYadMapR_ZooLibStrim::ZYadMapR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU, bool iReadDelimiter) +: fStrimmerU(iStrimmerU), + fReadDelimiter(iReadDelimiter) + {} + +void ZYadMapR_ZooLibStrim::Imp_ReadInc(bool iIsFirst, std::string& oName, ZRef<ZYadR>& oYadR) + { + using namespace ZUtil_Strim; + + const ZStrimU& theStrimU = fStrimmerU->GetStrimU(); + + sSkip_WSAndCPlusPlusComments(theStrimU); + + if (not iIsFirst) + { + if (!sTryRead_CP(theStrimU, ',') && !sTryRead_CP(theStrimU, ';')) + spThrowParseException("Expected ';' or ',' after property"); + sSkip_WSAndCPlusPlusComments(theStrimU); + } + + if (fReadDelimiter) + { + if (sTryRead_CP(theStrimU, '}')) + return; + } + + if (!spTryRead_PropertyName(theStrimU, oName)) + { + if (!fReadDelimiter) + return; + spThrowParseException("Expected property name"); + } + + sSkip_WSAndCPlusPlusComments(theStrimU); + + if (!sTryRead_CP(theStrimU, '=')) + spThrowParseException("Expected '=' after property name"); + + if (!(oYadR = spMakeYadR_ZooLibStrim(fStrimmerU))) + spThrowParseException("Expected value after '='"); + } + +// ================================================================================================= +#pragma mark - +#pragma mark * Static writing functions + +static void spWriteIndent(const ZStrimW& iStrimW, + size_t iCount, const ZYadOptions& iOptions) + { + while (iCount--) + iStrimW.Write(iOptions.fIndentString); + } + +static void spWriteLFIndent(const ZStrimW& iStrimW, + size_t iCount, const ZYadOptions& iOptions) + { + iStrimW.Write(iOptions.fEOLString); + spWriteIndent(iStrimW, iCount, iOptions); + } + +static void spWriteString + (const ZStrimW& s, const ZYadOptions& iOptions, const string& iString) + { + if (iOptions.fBreakStrings + && iOptions.DoIndentation() + && string::npos != iString.find_first_of("\n\r")) + { + // We put a newline after the opening """, which will be + // ignored by sFromStrim, so the first line of iString + // will be in column zero. + s << "\"\"\"\n"; + ZStrimU_String strim_String(iString); + ZStrimR_Boundary strim_Boundary("\"\"\"", strim_String); + for (;;) + { + s.CopyAllFrom(strim_Boundary); + if (!strim_Boundary.HitBoundary()) + { + // We've returned without having hit the boundary, so we're done. + break; + } + strim_Boundary.Reset(); + + // Close the triple quotes. + s << "\"\"\""; + // A space to separate the triple-quote from the single quote + s << " "; + // An open quote + s << "\""; + // Three escaped quotes. + s << "\\\"\\\"\\\""; + // A close quote. + s << "\""; + // Another space, for symmetry + s << " "; + // And re-open triple quotes again. + s << "\"\"\""; + // With a newline, so the text will again + // start in column zero. + s << "\n"; + } + s << "\"\"\""; + } + else + { + string delimiter = "\""; + bool quoteQuotes = true; + if (string::npos != iString.find('"') && string::npos == iString.find('\'')) + { + delimiter = "'"; + quoteQuotes = false; + } + + s.Write(delimiter); + + ZStrimW_Escaped::Options theOptions; + theOptions.fQuoteQuotes = quoteQuotes; + theOptions.fEscapeHighUnicode = false; + + ZStrimW_Escaped(theOptions, s).Write(iString); + + s.Write(delimiter); + } + } + +static void spToStrim_Stream(const ZStrimW& s, const ZStreamRPos& iStreamRPos, + size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) + { + uint64 theSize = iStreamRPos.GetSize(); + if (theSize == 0) + { + // we've got an empty Raw + s.Write("()"); + } + else + { + if (iOptions.DoIndentation() && theSize > iOptions.fRawChunkSize) + { + if (iMayNeedInitialLF) + spWriteLFIndent(s, iLevel, iOptions); + + uint64 countRemaining = theSize; + if (iOptions.fRawSizeCap) + countRemaining = min(countRemaining, iOptions.fRawSizeCap.Get()); + + s.Writef("( // %lld bytes", theSize); + + if (countRemaining < theSize) + s.Writef(" (truncated at %lld bytes)", iOptions.fRawSizeCap.Get()); + + spWriteLFIndent(s, iLevel, iOptions); + if (iOptions.fRawAsASCII) + { + for (;;) + { + uint64 lastPos = iStreamRPos.GetPosition(); + const size_t countToCopy = + min(iOptions.fRawChunkSize, ZStream::sClampedSize(countRemaining)); + uint64 countCopied; + ZStreamW_HexStrim(iOptions.fRawByteSeparator, string(), 0, s) + .CopyFrom(iStreamRPos, countToCopy, &countCopied, nullptr); + countRemaining -= countCopied; + if (countCopied == 0) + break; + + iStreamRPos.SetPosition(lastPos); + if (size_t extraSpaces = iOptions.fRawChunkSize - countCopied) + { + // We didn't write a complete line of bytes, so pad it out. + while (extraSpaces--) + { + // Two spaces for the two nibbles + s.Write(" "); + // And then the separator sequence + s.Write(iOptions.fRawByteSeparator); + } + } + + s.Write(" // "); + while (countCopied--) + { + char theChar = iStreamRPos.ReadInt8(); + if (theChar < 0x20 || theChar > 0x7E) + s.WriteCP('.'); + else + s.WriteCP(theChar); + } + spWriteLFIndent(s, iLevel, iOptions); + } + } + else + { + string eol = iOptions.fEOLString; + for (size_t x = 0; x < iLevel; ++x) + eol += iOptions.fIndentString; + + ZStreamW_HexStrim(iOptions.fRawByteSeparator, + eol, iOptions.fRawChunkSize, s).CopyAllFrom(iStreamRPos); + + spWriteLFIndent(s, iLevel, iOptions); + } + + s.Write(")"); + } + else + { + s.Write("("); + + ZStreamW_HexStrim(iOptions.fRawByteSeparator, string(), 0, s) + .CopyAllFrom(iStreamRPos); + + if (iOptions.fRawAsASCII) + { + iStreamRPos.SetPosition(0); + s.Write(" /* "); + while (theSize--) + { + char theChar = iStreamRPos.ReadInt8(); + if (theChar < 0x20 || theChar > 0x7E) + s.WriteCP('.'); + else + s.WriteCP(theChar); + } + s.Write(" */"); + } + s.Write(")"); + } + } + } + +static void spToStrim_Stream(const ZStrimW& s, const ZStreamR& iStreamR, + size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) + { + if (const ZStreamRPos* theStreamRPos = dynamic_cast<const ZStreamRPos*>(&iStreamR)) + { + spToStrim_Stream(s, *theStreamRPos, iLevel, iOptions, iMayNeedInitialLF); + } + else + { + s.Write("("); + + ZStreamW_HexStrim(iOptions.fRawByteSeparator, string(), 0, s) + .CopyAllFrom(iStreamR); + + s.Write(")"); + } + } + +static void spToStrim_Strim(const ZStrimW& s, const ZStrimR& iStrimR, + size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) + { + if (const ZStrimU_String8* theStrimU = dynamic_cast<const ZStrimU_String8*>(&iStrimR)) + { + spWriteString(s, iOptions, theStrimU->GetString8()); + } + else + { + s.Write("\""); + + ZStrimW_Escaped::Options theOptions; + theOptions.fQuoteQuotes = true; + theOptions.fEscapeHighUnicode = false; + + ZStrimW_Escaped(theOptions, s) + .CopyAllFrom(iStrimR); + + s.Write("\""); + } + } + +static void spToStrim_SimpleValue(const ZStrimW& s, const ZAny& iVal, + size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) + { + if (false) + {} + else if (iVal.Type() == typeid(void)) + { + s.Write("Null"); + } + else if (const ZType* theValue = iVal.PGet<ZType>()) + { + s << "Type(" << ZTypeAsString(*theValue) << ")"; + } + else if (const uint64* theValue = iVal.PGet<uint64>()) + { + s.Writef("ID(0x%0llX)", *theValue); + } + else if (const char* theValue = iVal.PGet<char>()) + { + s.Writef("int8(%d)", *theValue); + } + else if (const unsigned char* theValue = iVal.PGet<unsigned char>()) + { + s.Writef("int8(%d)", *theValue); + } + else if (const signed char* theValue = iVal.PGet<signed char>()) + { + s.Writef("int8(%d)", *theValue); + } + else if (const short* theValue = iVal.PGet<short>()) + { + s.Writef("int16(%d)", *theValue); + } + else if (const unsigned short* theValue = iVal.PGet<unsigned short>()) + { + s.Writef("int16(%d)", *theValue); + } + else if (const int* theValue = iVal.PGet<int>()) + { + if (ZIntIs32Bit) + s.Writef("int32(%d)", *theValue); + else + s.Writef("int64(%lld)", int64(*theValue)); + } + else if (const unsigned int* theValue = iVal.PGet<unsigned int>()) + { + if (ZIntIs32Bit) + s.Writef("int32(%d)", *theValue); + else + s.Writef("int64(%lld)", int64(*theValue)); + } + else if (const long* theValue = iVal.PGet<long>()) + { + if (ZLongIs32Bit) + s.Writef("int32(%ld)", *theValue); + else + s.Writef("int64(%lld)", int64(*theValue)); + } + else if (const unsigned long* theValue = iVal.PGet<unsigned long>()) + { + if (ZLongIs32Bit) + s.Writef("int32(%ld)", long(*theValue)); + else + s.Writef("int64(%lld)", int64(*theValue)); + } + else if (const int64* theValue = iVal.PGet<int64>()) + { + s.Writef("int64(%lld)", *theValue); + } + else if (const bool* theValue = iVal.PGet<bool>()) + { + if (*theValue) + s << "true"; + else + s << "false"; + } + else if (const float* theValue = iVal.PGet<float>()) + { + s << "float("; + ZUtil_Strim::sWriteExact(s, *theValue); + s << ")"; + } + else if (const double* theValue = iVal.PGet<double>()) + { + s << "double("; + ZUtil_Strim::sWriteExact(s, *theValue); + s << ")"; + } + else if (const ZTime* theValue = iVal.PGet<ZTime>()) + { + if (*theValue) + { + s.Write("time("); + s << ZUtil_Time::sAsString_ISO8601(*theValue, true); + s.Write(")"); + } + else + { + // We're now allowing empty parens to represent invalid times. + s.Write("time()"); + } + } + else if (const VoidStar_t* theValue = iVal.PGet<VoidStar_t>()) + { + s.Writef("pointer(%p)", *theValue); + } + else if (const ZRectPOD* theValue = iVal.PGet<ZRectPOD>()) + { + s.Writef("Rect(%d, %d, %d, %d)", + theValue->left, + theValue->top, + theValue->right, + theValue->bottom); + } + else if (const ZPointPOD* theValue = iVal.PGet<ZPointPOD>()) + { + s.Writef("Point(%d, %d)", + theValue->h, + theValue->v); + } + else if (const ZRef<ZCounted>* theValue = + iVal.PGet<ZRef<ZCounted> >()) + { + s.Writef("RefCounted(%p)", theValue->Get()); + } + else + { + s << "null /*Unhandled: " << iVal.Type().name() << "*/"; + } + } + +static void spToStrim_Yad(const ZStrimW& s, ZRef<ZYadR> iYadR, + size_t iInitialIndent, const ZYadOptions& iOptions, bool iMayNeedInitialLF); + +static void spToStrim_Seq(const ZStrimW& s, ZRef<ZYadSeqR> iYadSeqR, + size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) + { + bool needsIndentation = false; + if (iOptions.DoIndentation()) + { + // We're supposed to be indenting if we're complex, ie if any element is: + // 1. A non-empty vector. + // 2. A non-empty tuple. + // or if iOptions.fBreakStrings is true, any element is a string with embedded + // line breaks or more than iOptions.fStringLineLength characters. + needsIndentation = !iYadSeqR->IsSimple(iOptions); + } + + if (needsIndentation) + { + // We need to indent. + if (iMayNeedInitialLF) + { + // We were invoked by a tuple which has already issued the property + // name and equals sign, so we need to start a fresh line. + spWriteLFIndent(s, iLevel, iOptions); + } + + s.Write("["); + for (bool isFirst = true; /*no test*/ ; isFirst = false) + { + if (ZRef<ZYadR,false> cur = iYadSeqR->ReadInc()) + { + break; + } + else + { + if (not isFirst) + s.Write(", "); + spWriteLFIndent(s, iLevel, iOptions); + spToStrim_Yad(s, cur, iLevel, iOptions, false); + } + } + spWriteLFIndent(s, iLevel, iOptions); + s.Write("]"); + } + else + { + // We're not indenting, so we can just dump everything out on + // one line, with just some spaces to keep things legible. + s.Write("["); + for (bool isFirst = true; /*no test*/ ; isFirst = false) + { + if (ZRef<ZYadR,false> cur = iYadSeqR->ReadInc()) + { + break; + } + else + { + if (not isFirst) + s.Write(", "); + spToStrim_Yad(s, cur, iLevel, iOptions, false); + } + } + s.Write("]"); + } + } + +static void spToStrim_Map(const ZStrimW& s, ZRef<ZYadMapR> iYadMapR, + size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) + { + bool needsIndentation = false; + if (iOptions.DoIndentation()) + { + needsIndentation = ! iYadMapR->IsSimple(iOptions); + } + + if (needsIndentation) + { + if (iMayNeedInitialLF) + { + // We're going to be indenting, but need to start + // a fresh line to have our { and contents line up. + spWriteLFIndent(s, iLevel, iOptions); + } + + s.Write("{"); + for (;;) + { + string curName; + if (ZRef<ZYadR,false> cur = iYadMapR->ReadInc(curName)) + { + break; + } + else + { + spWriteLFIndent(s, iLevel, iOptions); + ZYad_ZooLibStrim::sWrite_PropName(curName, s); + s << " = "; + spToStrim_Yad(s, cur, iLevel + 1, iOptions, true); + s.Write(";"); + } + } + spWriteLFIndent(s, iLevel, iOptions); + s.Write("}"); + } + else + { + s.Write("{"); + for (;;) + { + string curName; + if (ZRef<ZYadR,false> cur = iYadMapR->ReadInc(curName)) + { + break; + } + else + { + s.Write(" "); + ZYad_ZooLibStrim::sWrite_PropName(curName, s); + s << " = "; + spToStrim_Yad(s, cur, iLevel + 1, iOptions, true); + s.Write(";"); + } + } + s.Write(" }"); + } + } + +static void spToStrim_Yad(const ZStrimW& s, ZRef<ZYadR> iYadR, + size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) + { + if (not iYadR) + { + return; + } + else if (ZRef<ZYadMapR> theYadMapR = iYadR.DynamicCast<ZYadMapR>()) + { + spToStrim_Map(s, theYadMapR, iLevel, iOptions, iMayNeedInitialLF); + } + else if (ZRef<ZYadSeqR> theYadSeqR = iYadR.DynamicCast<ZYadSeqR>()) + { + spToStrim_Seq(s, theYadSeqR, iLevel, iOptions, iMayNeedInitialLF); + } + else if (ZRef<ZYadStreamR> theYadStreamR = iYadR.DynamicCast<ZYadStreamR>()) + { + spToStrim_Stream(s, theYadStreamR->GetStreamR(), iLevel, iOptions, iMayNeedInitialLF); + } + else if (ZRef<ZYadStrimR> theYadStrimR = iYadR.DynamicCast<ZYadStrimR>()) + { + spToStrim_Strim(s, theYadStrimR->GetStrimR(), iLevel, iOptions, iMayNeedInitialLF); + } + else if (ZRef<ZYadAtomR> theYadAtomR = iYadR.DynamicCast<ZYadAtomR>()) + { + spToStrim_SimpleValue(s, theYadAtomR->AsAny(), + iLevel, iOptions, iMayNeedInitialLF); + } + else + { + s << "null /*!! Unhandled yad !!*/"; + } + } + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYad_ZooLibStrim + +bool ZYad_ZooLibStrim::sRead_Identifier + (const ZStrimU& iStrimU, string* oStringLC, string* oStringExact) + { + if (oStringExact) + oStringExact->reserve(32); + + if (oStringLC) + oStringLC->reserve(32); + + bool gotAny = false; + for (;;) + { + UTF32 theCP; + if (not iStrimU.ReadCP(theCP)) + break; + if (not ZUnicode::sIsAlphaDigit(theCP) && theCP != '_') + { + iStrimU.Unread(theCP); + break; + } + + gotAny = true; + + if (oStringLC) + *oStringLC += ZUnicode::sToLower(theCP); + if (oStringExact) + *oStringExact += theCP; + } + return gotAny; + } + +ZRef<ZYadR> ZYad_ZooLibStrim::sYadR(ZRef<ZStrimmerU> iStrimmerU) + { return spMakeYadR_ZooLibStrim(iStrimmerU); } + +void ZYad_ZooLibStrim::sToStrim(ZRef<ZYadR> iYadR, const ZStrimW& s) + { spToStrim_Yad(s, iYadR, 0, ZYadOptions(), false); } + +void ZYad_ZooLibStrim::sToStrim(size_t iInitialIndent, const ZYadOptions& iOptions, + ZRef<ZYadR> iYadR, const ZStrimW& s) + { spToStrim_Yad(s, iYadR, iInitialIndent, iOptions, false); } + +static bool spContainsProblemChars(const string& iString) + { + if (iString.empty()) + { + // An empty string can't be distinguished from no string at all, so + // we treat it as if it has problem chars, so it will be wrapped in quotes. + return true; + } + + for (string::const_iterator i = iString.begin(), end = iString.end();;) + { + UTF32 theCP; + if (not ZUnicode::sReadInc(i, end, theCP)) + break; + if (not ZUnicode::sIsAlphaDigit(theCP) && '_' != theCP) + return true; + } + + return false; + } + +void ZYad_ZooLibStrim::sWrite_PropName(const string& iPropName, const ZStrimW& iStrimW) + { + if (spContainsProblemChars(iPropName)) + { + iStrimW << "\""; + ZStrimW_Escaped(iStrimW) << iPropName; + iStrimW << "\""; + } + else + { + iStrimW << iPropName; + } + } + +} // namespace ZooLib Added: trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStrim.h =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStrim.h (rev 0) +++ trunk/zoolib/source/cxx/old/zoolib/ZYad_ZooLibStrim.h 2011-07-25 00:40:00 UTC (rev 2426) @@ -0,0 +1,168 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2008 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZYad_ZooLibStrim__ +#define __ZYad_ZooLibStrim__ 1 +#include "zconfig.h" + +#include "zoolib/ZStreamR_HexStrim.h" +#include "zoolib/ZStrim.h" +#include "zoolib/ZStrim_Escaped.h" +#include "zoolib/ZStrimR_Boundary.h" +#include "zoolib/ZYad_Std.h" + +namespace ZooLib { + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadParseException_ZooLibStrim + +class ZYadParseException_ZooLibStrim : public ZYadParseException_Std + { +public: + ZYadParseException_ZooLibStrim(const std::string& iWhat); + ZYadParseException_ZooLibStrim(const char* iWhat); + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadStreamR_ZooLibStrim + +class ZYadStreamR_ZooLibStrim +: public ZYadStreamR + { +public: + ZYadStreamR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU, bool iReadDelimiter); + +// From ZYadR + virtual void Finish(); + +// From ZStreamerR via ZYadStreamR + const ZStreamR& GetStreamR(); + +private: + ZRef<ZStrimmerU> fStrimmerU; + bool fReadDelimiter; + ZStreamR_HexStrim fStreamR; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadStrimR_ZooLibStrim_Apos + +class ZYadStrimR_ZooLibStrim_Apos +: public ZYadStrimR + { +public: + ZYadStrimR_ZooLibStrim_Apos(ZRef<ZStrimmerU> iStrimmerU); + +// From ZYadR + virtual void Finish(); + +// From ZStrimmerR via ZYadStrimR + const ZStrimR& GetStrimR(); + +private: + ZRef<ZStrimmerU> fStrimmerU; + ZStrimR_Escaped fStrimR; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadStrimR_ZooLibStrim_Quote + +class ZYadStrimR_ZooLibStrim_Quote +: public ZYadStrimR, + private ZStrimR + { +public: + ZYadStrimR_ZooLibStrim_Quote(ZRef<ZStrimmerU> iStrimmerU); + +// From ZYadR + virtual void Finish(); + +// From ZStrimmerR via ZYadStrimR + const ZStrimR& GetStrimR(); + +// From ZStrimR + virtual void Imp_ReadUTF32(UTF32* oDest, size_t iCount, size_t* oCount); + +private: + ZRef<ZStrimmerU> fStrimmerU; + ZStrimR_Boundary fStrimR_Boundary; + size_t fQuotesSeen; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadSeqR_ZooLibStrim + +class ZYadSeqR_ZooLibStrim : public ZYadSeqR_Std + { +public: + ZYadSeqR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU, bool iReadDelimiter); + +// From ZYadSeqR_Std + virtual void Imp_ReadInc(bool iIsFirst, ZRef<ZYadR>& oYadR); + +private: + ZRef<ZStrimmerU> fStrimmerU; + bool fReadDelimiter; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYadMapR_ZooLibStrim + +class ZYadMapR_ZooLibStrim : public ZYadMapR_Std + { +public: + ZYadMapR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU, bool iReadDelimiter); + +// From ZYadMapR_Std + virtual void Imp_ReadInc(bool iIsFirst, std::string& oName, ZRef<ZYadR>& oYadR); + +private: + ZRef<ZStrimmerU> fStrimmerU; + bool fReadDelimiter; + }; + +// ================================================================================================= +#pragma mark - +#pragma mark * ZYad_ZooLibStrim + +namespace ZYad_ZooLibStrim { + +bool sRead_Identifier + (const ZStrimU& iStrimU, std::string* oStringLC, std::string* oStringExact); + +ZRef<ZYadR> sYadR(ZRef<ZStrimmerU> iStrimmerU); + +void sToStrim(ZRef<ZYadR> iYadR, const ZStrimW& s); + +void sToStrim(size_t iInitialIndent, const ZYadOptions& iOptions, + ZRef<ZYadR> iYadR, const ZStrimW& s); + +void sWrite_PropName(const std::string& iPropName, const ZStrimW& s); + +} // namespace ZYad_ZooLibStrim +} // namespace ZooLib + +#endif // __ZYad_ZooLibStrim__ Deleted: trunk/zoolib/source/cxx/zoolib/ZYad_ZooLibStrim.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_ZooLibStrim.cpp 2011-07-24 04:00:34 UTC (rev 2425) +++ trunk/zoolib/source/cxx/zoolib/ZYad_ZooLibStrim.cpp 2011-07-25 00:40:00 UTC (rev 2426) @@ -1,1182 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2008 Andrew Green -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZGeomPOD.h" -#include "zoolib/ZStreamW_HexStrim.h" -#include "zoolib/ZStrimR_Boundary.h" -#include "zoolib/ZStrim_Escaped.h" -#include "zoolib/ZUnicode.h" -#include "zoolib/ZUtil_Strim.h" -#include "zoolib/ZUtil_Strim_Operators.h" -#include "zoolib/ZUtil_Time.h" -#include "zoolib/ZVal_ZooLib.h" // For ZType enum -#include "zoolib/ZYad_ZooLibStrim.h" - -#include <vector> - -namespace ZooLib { - -using std::min; -using std::string; -using std::vector; - -// ================================================================================================= -#pragma mark - -#pragma mark * Static parsing functions - -static void spThrowParseException(const string& iMessage) - { - throw ZYadParseException_ZooLibStrim(iMessage); - } - -static bool spTryRead_PropertyName(const ZStrimU& iStrimU, string& oName) - { - using namespace ZUtil_Strim; - - if (!sTryRead_EscapedString(iStrimU, '"', oName)) - { - if (!sTryRead_EscapedString(iStrimU, '\'', oName)) - { - if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, nullptr, &oName)) - return false; - } - } - - return true; - } - -static int64 spMustRead_GenericInteger(const ZStrimU& iStrimU) - { - using namespace ZUtil_Strim; - int64 theInteger; - if (!sTryRead_SignedGenericInteger(iStrimU, theInteger)) - spThrowParseException("Expected an integer"); - return theInteger; - } - -static void spMustRead_WSCommaWS(const ZStrimU& iStrimU) - { - using namespace ZUtil_Strim; - sSkip_WSAndCPlusPlusComments(iStrimU); - - if (!sTryRead_CP(iStrimU, ',')) - spThrowParseException("Expected a ','"); - - sSkip_WSAndCPlusPlusComments(iStrimU); - } - -static bool spFromStrim_Value(const ZStrimU& iStrimU, ZAny& oVal) - { - using namespace ZUtil_Strim; - - sSkip_WSAndCPlusPlusComments(iStrimU); - - if (false) - {} -#if 0//## - else if (sTryRead_CP(iStrimU, '@')) - { - // It's a property name. - string propertyName; - if (!sTryRead_EscapedString(iStrimU, '"', propertyName)) - { - if (!sTryRead_EscapedString(iStrimU, '\'', propertyName)) - { - if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, nullptr, &propertyName)) - spThrowParseException("Expected a property name after '#'"); - } - } - oVal.SetName(propertyName); - } -#endif - else - { - string theTypeLC, theType; - if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, &theTypeLC, &theType)) - { - // We couldn't find any of the special characters, nor could - // we read a type designator, so we fail to read a value, - // which is not a parse error at this stage -- it might be for our caller. - return false; - } - - if (theTypeLC == "null") - { - oVal = ZAny(); - } - else if (theTypeLC == "false") - { - oVal = false; - } - else if (theTypeLC == "true") - { - oVal = true; - } - else - { - sSkip_WSAndCPlusPlusComments(iStrimU); - if (!sTryRead_CP(iStrimU, '(')) - spThrowParseException("Expected '(' following a type designator"); - - sSkip_WSAndCPlusPlusComments(iStrimU); - - if (theTypeLC == "type") - { - string typeValueLC, typeValue; - if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, &typeValueLC, &typeValue)) - spThrowParseException("Expected a type name"); - - if (typeValueLC == "null") oVal = eZType_Null; - else if (typeValueLC == "string") oVal = eZType_String; -// AG 2007-08-06. cstring has never been used. Not even sure what it's point was. -// else if (typeValueLC == "cstring") oVal = eZType_CString; - else if (typeValueLC == "int8") oVal = eZType_Int8; - else if (typeValueLC == "int16") oVal = eZType_Int16; - else if (typeValueLC == "int32") oVal = eZType_Int32; - else if (typeValueLC == "int64") oVal = eZType_Int64; - else if (typeValueLC == "float") oVal = eZType_Float; - else if (typeValueLC == "double") oVal = eZType_Double; - else if (typeValueLC == "time") oVal = eZType_Time; - else if (typeValueLC == "bool") oVal = eZType_Bool; - else if (typeValueLC == "pointer") oVal = eZType_Pointer; - else if (typeValueLC == "raw") oVal = eZType_Raw; - else if (typeValueLC == "tuple") oVal = eZType_Tuple; - else if (typeValueLC == "refcounted") oVal = eZType_RefCounted; - else if (typeValueLC == "rect") oVal = eZType_Rect; - else if (typeValueLC == "point") oVal = eZType_Point; - else if (typeValueLC == "region") oVal = eZType_Region; - else if (typeValueLC == "id") oVal = eZType_ID; - else if (typeValueLC == "vector") oVal = eZType_Vector; - else if (typeValueLC == "type") oVal = eZType_Type; - else if (typeValueLC == "time") oVal = eZType_Time; -//## else if (typeValueLC == "name") oVal = eZType_Name; - else - spThrowParseException("Unknown type name '" + typeValue + "'"); - } - else if (theTypeLC == "id") - { - oVal = uint64(spMustRead_GenericInteger(iStrimU)); - } - else if (theTypeLC == "int8") - { - oVal = int8(spMustRead_GenericInteger(iStrimU)); - } - else if (theTypeLC == "int16") - { - oVal = int16(spMustRead_GenericInteger(iStrimU)); - } - else if (theTypeLC == "int32") - { - oVal = int32(spMustRead_GenericInteger(iStrimU)); - } - else if (theTypeLC == "int64") - { - oVal = int64(spMustRead_GenericInteger(iStrimU)); - } - else if (theTypeLC == "bool") - { - string theBool; - if (not ZYad_ZooLibStrim::sRead_Identifier(iStrimU, &theBool, nullptr)) - spThrowParseException("Expected 'false' or 'true'"); - - if (theBool == "true") - oVal = true; - else if (theBool == "false") - oVal = false; - else - spThrowParseException("Expected 'false' or 'true'"); - } - else if (theTypeLC == "float") - { - double theDouble; - if (!sTryRead_SignedDouble(iStrimU, theDouble)) - spThrowParseException("Expected a floating point number"); - oVal = float(theDouble); - } - else if (theTypeLC == "double") - { - double theDouble; - if (!sTryRead_SignedDouble(iStrimU, theDouble)) - spThrowParseException("Expected a floating point number"); - oVal = theDouble; - } - else if (theTypeLC == "time") - { - if (sTryRead_CP(iStrimU, ')')) - { - // It's a time with no content, hence an invalid time. - oVal = ZTime(); - - // We'll take an early exit so the normal code that - // looks for a closing parenthesis doesn't choke. - return true; - } - - // Read up till the closing paren, if any. - const string8 theContent = sRead_Until(iStrimU, ')'); - if (const ZTime theTime = ZUtil_Time::sFromString_ISO8601(theContent)) - { - oVal = theTime; - return true; - } - - double theDouble; - if (sTryRead_SignedDouble(ZStrimU_String(theContent), theDouble)) - { - oVal = ZTime(theDouble); - return true; - } - - spThrowParseException("Expected a floating point time"); - } - else if (theTypeLC == "rect") - { - ZRectPOD theRect; - - theRect.left = spMustRead_GenericInteger(iStrimU); - - spMustRead_WSCommaWS(iStrimU); - - theRect.top = spMustRead_GenericInteger(iStrimU); - - spMustRead_WSCommaWS(iStrimU); - - theRect.right = spMustRead_GenericInteger(iStrimU); - - spMustRead_WSCommaWS(iStrimU); - - theRect.bottom = spMustRead_GenericInteger(iStrimU); - - oVal = theRect; - } - else if (theTypeLC == "point") - { - ZPointPOD thePoint; - - thePoint.h = spMustRead_GenericInteger(iStrimU); - - spMustRead_WSCommaWS(iStrimU); - - thePoint.v = spMustRead_GenericInteger(iStrimU); - - oVal = thePoint; - } - else - { - spThrowParseException("Unknown type designator '" + theType + "'"); - } - - sSkip_WSAndCPlusPlusComments(iStrimU); - - if (!sTryRead_CP(iStrimU, ')')) - spThrowParseException("Expected ')' to close a value"); - } - } - return true; - } - -static ZRef<ZYadR> spMakeYadR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU) - { - using namespace ZUtil_Strim; - - const ZStrimU& theStrimU = iStrimmerU->GetStrimU(); - - sSkip_WSAndCPlusPlusComments(theStrimU); - - if (sTryRead_CP(theStrimU, '[')) - { - return new ZYadSeqR_ZooLibStrim(iStrimmerU, true); - } - else if (sTryRead_CP(theStrimU, '{')) - { - return new ZYadMapR_ZooLibStrim(iStrimmerU, true); - } - else if (sTryRead_CP(theStrimU, '(')) - { - return new ZYadStreamR_ZooLibStrim(iStrimmerU, true); - } - else if (sTryRead_CP(theStrimU, '"')) - { - return new ZYadStrimR_ZooLibStrim_Quote(iStrimmerU); - } - else if (sTryRead_CP(theStrimU, '\'')) - { - return new ZYadStrimR_ZooLibStrim_Apos(iStrimmerU); - } - else - { - ZAny theVal; - if (spFromStrim_Value(theStrimU, theVal)) - return new ZYadAtomR_Any(theVal); - } - - return null; - } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZYadParseException_ZooLibStrim - -ZYadParseException_ZooLibStrim::ZYadParseException_ZooLibStrim(const string& iWhat) -: ZYadParseException_Std(iWhat) - {} - -ZYadParseException_ZooLibStrim::ZYadParseException_ZooLibStrim(const char* iWhat) -: ZYadParseException_Std(iWhat) - {} - -// ================================================================================================= -#pragma mark - -#pragma mark * ZYadStreamR_ZooLibStrim - -ZYadStreamR_ZooLibStrim::ZYadStreamR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU, bool iReadDelimiter) -: fStrimmerU(iStrimmerU), - fReadDelimiter(iReadDelimiter), - fStreamR(fStrimmerU->GetStrimU()) - {} - -void ZYadStreamR_ZooLibStrim::Finish() - { - using namespace ZUtil_Strim; - - fStreamR.SkipAll(); - - if (fReadDelimiter) - { - const ZStrimU& theStrimU = fStrimmerU->GetStrimU(); - sSkip_WSAndCPlusPlusComments(theStrimU); - if (!sTryRead_CP(theStrimU, ')')) - spThrowParseException("Expected ')' to close a raw"); - } - } - -const ZStreamR& ZYadStreamR_ZooLibStrim::GetStreamR() - { return fStreamR; } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZYadStrimR_ZooLibStrim_Apos - -ZYadStrimR_ZooLibStrim_Apos::ZYadStrimR_ZooLibStrim_Apos(ZRef<ZStrimmerU> iStrimmerU) -: fStrimmerU(iStrimmerU), - fStrimR(fStrimmerU->GetStrimU(), '\'') - {} - -void ZYadStrimR_ZooLibStrim_Apos::Finish() - { - using namespace ZUtil_Strim; - fStrimR.SkipAll(); - if (!sTryRead_CP(fStrimmerU->GetStrimU(), '\'')) - throw ParseException("Missing string delimiter"); - } - -const ZStrimR& ZYadStrimR_ZooLibStrim_Apos::GetStrimR() - { return fStrimR; } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZYadStrimR_ZooLibStrim_Quote - -ZYadStrimR_ZooLibStrim_Quote::ZYadStrimR_ZooLibStrim_Quote(ZRef<ZStrimmerU> iStrimmerU) -: fStrimmerU(iStrimmerU), - fStrimR_Boundary("\"\"\"", fStrimmerU->GetStrimR()), - fQuotesSeen(1) - {} - -void ZYadStrimR_ZooLibStrim_Quote::Finish() - { this->SkipAll(); } - -const ZStrimR& ZYadStrimR_ZooLibStrim_Quote::GetStrimR() - { return *this; } - -void ZYadStrimR_ZooLibStrim_Quote::Imp_ReadUTF32(UTF32* oDest, size_t iCount, size_t* oCount) - { - using namespace ZUtil_Strim; - - const ZStrimU& theStrimU = fStrimmerU->GetStrimU(); - - UTF32* localDest = oDest; - UTF32* localDestEnd = oDest + iCount; - bool exhausted = false; - while (localDestEnd > localDest && !exhausted) - { - switch (fQuotesSeen) - { - case 0: - { - sSkip_WSAndCPlusPlusComments(theStrimU); - - if (sTryRead_CP(theStrimU, '"')) - fQuotesSeen = 1; - else - exhausted = true; - break; - } - case 1: - { - if (sTryRead_CP(theStrimU, '"')) - { - fQuotesSeen = 2; - } - else - { - size_t countRead; - ZStrimR_Escaped(theStrimU, '"') - .Read(localDest, localDestEnd - localDest, &countRead); - localDest += countRead; - - if (sTryRead_CP(theStrimU, '"')) - fQuotesSeen = 0; - else if (countRead == 0) - spThrowParseException("Expected \" to close a string"); - } - break; - } - case 2: - { - if (sTryRead_CP(theStrimU, '"')) - { - fQuotesSeen = 3; - UTF32 theCP = theStrimU.ReadCP(); - if (not ZUnicode::sIsEOL(theCP)) - theStrimU.Unread(theCP); - } - else - { - // We have two quotes in a row, followed by something - // else, so we had an empty string segment. - fQuotesSeen = 0; - } - break; - } - case 3: - { - // We've got three quotes in a row, and any trailing EOL - // has been stripped. - size_t countRead; - fStrimR_Boundary.Read(localDest, localDestEnd - localDest, &countRead); - localDest += countRead; - if (countRead == 0) - { - if (!fStrimR_Boundary.HitBoundary()) - spThrowParseException("Expected \"\"\" to close a string"); - fStrimR_Boundary.Reset(); - fQuotesSeen = 0; - } - break; - } - } - } - - if (oCount) - *oCount = localDest - oDest; - } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZYadSeqR_ZooLibStrim - -ZYadSeqR_ZooLibStrim::ZYadSeqR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU, bool iReadDelimiter) -: fStrimmerU(iStrimmerU), - fReadDelimiter(iReadDelimiter) - {} - -void ZYadSeqR_ZooLibStrim::Imp_ReadInc(bool iIsFirst, ZRef<ZYadR>& oYadR) - { - using namespace ZUtil_Strim; - - const ZStrimU& theStrimU = fStrimmerU->GetStrimU(); - - sSkip_WSAndCPlusPlusComments(theStrimU); - - bool gotSeparator = true; - if (not iIsFirst) - { - if (!sTryRead_CP(theStrimU, ',') && !sTryRead_CP(theStrimU, ';')) - gotSeparator = false; - else - sSkip_WSAndCPlusPlusComments(theStrimU); - } - - if (fReadDelimiter) - { - if (sTryRead_CP(theStrimU, ']')) - return; - } - - if (!gotSeparator) - spThrowParseException("Expected ';' or ',' between values"); - - if (!(oYadR = spMakeYadR_ZooLibStrim(fStrimmerU))) - { - if (!fReadDelimiter) - return; - spThrowParseException("Expected a value"); - } - } - -// ================================================================================================= -#pragma mark - -#pragma mark * ZYadMapR_ZooLibStrim - -ZYadMapR_ZooLibStrim::ZYadMapR_ZooLibStrim(ZRef<ZStrimmerU> iStrimmerU, bool iReadDelimiter) -: fStrimmerU(iStrimmerU), - fReadDelimiter(iReadDelimiter) - {} - -void ZYadMapR_ZooLibStrim::Imp_ReadInc(bool iIsFirst, std::string& oName, ZRef<ZYadR>& oYadR) - { - using namespace ZUtil_Strim; - - const ZStrimU& theStrimU = fStrimmerU->GetStrimU(); - - sSkip_WSAndCPlusPlusComments(theStrimU); - - if (not iIsFirst) - { - if (!sTryRead_CP(theStrimU, ',') && !sTryRead_CP(theStrimU, ';')) - spThrowParseException("Expected ';' or ',' after property"); - sSkip_WSAndCPlusPlusComments(theStrimU); - } - - if (fReadDelimiter) - { - if (sTryRead_CP(theStrimU, '}')) - return; - } - - if (!spTryRead_PropertyName(theStrimU, oName)) - { - if (!fReadDelimiter) - return; - spThrowParseException("Expected property name"); - } - - sSkip_WSAndCPlusPlusComments(theStrimU); - - if (!sTryRead_CP(theStrimU, '=')) - spThrowParseException("Expected '=' after property name"); - - if (!(oYadR = spMakeYadR_ZooLibStrim(fStrimmerU))) - spThrowParseException("Expected value after '='"); - } - -// ================================================================================================= -#pragma mark - -#pragma mark * Static writing functions - -static void spWriteIndent(const ZStrimW& iStrimW, - size_t iCount, const ZYadOptions& iOptions) - { - while (iCount--) - iStrimW.Write(iOptions.fIndentString); - } - -static void spWriteLFIndent(const ZStrimW& iStrimW, - size_t iCount, const ZYadOptions& iOptions) - { - iStrimW.Write(iOptions.fEOLString); - spWriteIndent(iStrimW, iCount, iOptions); - } - -static void spWriteString - (const ZStrimW& s, const ZYadOptions& iOptions, const string& iString) - { - if (iOptions.fBreakStrings - && iOptions.DoIndentation() - && string::npos != iString.find_first_of("\n\r")) - { - // We put a newline after the opening """, which will be - // ignored by sFromStrim, so the first line of iString - // will be in column zero. - s << "\"\"\"\n"; - ZStrimU_String strim_String(iString); - ZStrimR_Boundary strim_Boundary("\"\"\"", strim_String); - for (;;) - { - s.CopyAllFrom(strim_Boundary); - if (!strim_Boundary.HitBoundary()) - { - // We've returned without having hit the boundary, so we're done. - break; - } - strim_Boundary.Reset(); - - // Close the triple quotes. - s << "\"\"\""; - // A space to separate the triple-quote from the single quote - s << " "; - // An open quote - s << "\""; - // Three escaped quotes. - s << "\\\"\\\"\\\""; - // A close quote. - s << "\""; - // Another space, for symmetry - s << " "; - // And re-open triple quotes again. - s << "\"\"\""; - // With a newline, so the text will again - // start in column zero. - s << "\n"; - } - s << "\"\"\""; - } - else - { - string delimiter = "\""; - bool quoteQuotes = true; - if (string::npos != iString.find('"') && string::npos == iString.find('\'')) - { - delimiter = "'"; - quoteQuotes = false; - } - - s.Write(delimiter); - - ZStrimW_Escaped::Options theOptions; - theOptions.fQuoteQuotes = quoteQuotes; - theOptions.fEscapeHighUnicode = false; - - ZStrimW_Escaped(theOptions, s).Write(iString); - - s.Write(delimiter); - } - } - -static void spToStrim_Stream(const ZStrimW& s, const ZStreamRPos& iStreamRPos, - size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) - { - uint64 theSize = iStreamRPos.GetSize(); - if (theSize == 0) - { - // we've got an empty Raw - s.Write("()"); - } - else - { - if (iOptions.DoIndentation() && theSize > iOptions.fRawChunkSize) - { - if (iMayNeedInitialLF) - spWriteLFIndent(s, iLevel, iOptions); - - uint64 countRemaining = theSize; - if (iOptions.fRawSizeCap) - countRemaining = min(countRemaining, iOptions.fRawSizeCap.Get()); - - s.Writef("( // %lld bytes", theSize); - - if (countRemaining < theSize) - s.Writef(" (truncated at %lld bytes)", iOptions.fRawSizeCap.Get()); - - spWriteLFIndent(s, iLevel, iOptions); - if (iOptions.fRawAsASCII) - { - for (;;) - { - uint64 lastPos = iStreamRPos.GetPosition(); - const size_t countToCopy = - min(iOptions.fRawChunkSize, ZStream::sClampedSize(countRemaining)); - uint64 countCopied; - ZStreamW_HexStrim(iOptions.fRawByteSeparator, string(), 0, s) - .CopyFrom(iStreamRPos, countToCopy, &countCopied, nullptr); - countRemaining -= countCopied; - if (countCopied == 0) - break; - - iStreamRPos.SetPosition(lastPos); - if (size_t extraSpaces = iOptions.fRawChunkSize - countCopied) - { - // We didn't write a complete line of bytes, so pad it out. - while (extraSpaces--) - { - // Two spaces for the two nibbles - s.Write(" "); - // And then the separator sequence - s.Write(iOptions.fRawByteSeparator); - } - } - - s.Write(" // "); - while (countCopied--) - { - char theChar = iStreamRPos.ReadInt8(); - if (theChar < 0x20 || theChar > 0x7E) - s.WriteCP('.'); - else - s.WriteCP(theChar); - } - spWriteLFIndent(s, iLevel, iOptions); - } - } - else - { - string eol = iOptions.fEOLString; - for (size_t x = 0; x < iLevel; ++x) - eol += iOptions.fIndentString; - - ZStreamW_HexStrim(iOptions.fRawByteSeparator, - eol, iOptions.fRawChunkSize, s).CopyAllFrom(iStreamRPos); - - spWriteLFIndent(s, iLevel, iOptions); - } - - s.Write(")"); - } - else - { - s.Write("("); - - ZStreamW_HexStrim(iOptions.fRawByteSeparator, string(), 0, s) - .CopyAllFrom(iStreamRPos); - - if (iOptions.fRawAsASCII) - { - iStreamRPos.SetPosition(0); - s.Write(" /* "); - while (theSize--) - { - char theChar = iStreamRPos.ReadInt8(); - if (theChar < 0x20 || theChar > 0x7E) - s.WriteCP('.'); - else - s.WriteCP(theChar); - } - s.Write(" */"); - } - s.Write(")"); - } - } - } - -static void spToStrim_Stream(const ZStrimW& s, const ZStreamR& iStreamR, - size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) - { - if (const ZStreamRPos* theStreamRPos = dynamic_cast<const ZStreamRPos*>(&iStreamR)) - { - spToStrim_Stream(s, *theStreamRPos, iLevel, iOptions, iMayNeedInitialLF); - } - else - { - s.Write("("); - - ZStreamW_HexStrim(iOptions.fRawByteSeparator, string(), 0, s) - .CopyAllFrom(iStreamR); - - s.Write(")"); - } - } - -static void spToStrim_Strim(const ZStrimW& s, const ZStrimR& iStrimR, - size_t iLevel, const ZYadOptions& iOptions, bool iMayNeedInitialLF) - { - if (const ZStrimU_String8* theStrimU = dynamic_cast<const ZStrimU_String8*>(&iStrimR)) - { - spWriteString(s, iOptions, theStrimU->GetString8()); - } - else - { - s.Write("\""); - - ZStrimW_Escaped::Options theOptions; - theOptions.fQuoteQuotes = true; - t... [truncated message content] |
From: <ag...@us...> - 2012-01-23 18:18:22
|
Revision: 2681 http://zoolib.svn.sourceforge.net/zoolib/?rev=2681&view=rev Author: agreen Date: 2012-01-23 18:18:12 +0000 (Mon, 23 Jan 2012) Log Message: ----------- Method name change GetData-->GetPtr. It had become confusing to me that the type has Data in its name, and yet an element of that type was accessed using that same name. Not overly in love with Ptr, but it is accurate and distinct from the type name now. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerryServer.cpp trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerry_Client.cpp trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerry_Streamer.cpp trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_DatonSet.cpp trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime_Val.cpp trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime_Val.h trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Host_Std.cpp trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp trunk/zoolib/source/cxx/zoolib/ZData_Any.cpp trunk/zoolib/source/cxx/zoolib/ZData_Any.h trunk/zoolib/source/cxx/zoolib/ZData_CF.cpp trunk/zoolib/source/cxx/zoolib/ZData_CF.h trunk/zoolib/source/cxx/zoolib/ZData_NS.h trunk/zoolib/source/cxx/zoolib/ZData_NS.mm trunk/zoolib/source/cxx/zoolib/ZNatter.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_CF.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_NS.mm trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.cpp Modified: trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerryServer.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerryServer.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerryServer.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -379,7 +379,7 @@ ZBlackBerry::Data theMB = theQ.Get(); w.WriteBool(true); w.WriteCount(theMB.GetSize()); - w.Write(theMB.GetData(), theMB.GetSize()); + w.Write(theMB.GetPtr(), theMB.GetSize()); return; } } Modified: trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerry_Client.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerry_Client.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerry_Client.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -235,7 +235,7 @@ if (r.ReadBool()) { Data theMB(r.ReadCount()); - r.Read(theMB.GetDataMutable(), theMB.GetSize()); + r.Read(theMB.GetPtrMutable(), theMB.GetSize()); return theMB; } } Modified: trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerry_Streamer.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerry_Streamer.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/more/zoolib/blackberry/ZBlackBerry_Streamer.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -755,7 +755,7 @@ { Data theMB_PIN = this->GetAttribute(8, 4); if (theMB_PIN.GetSize() >= 15) - return ZByteSwap_ReadLittle32(static_cast<const char*>(theMB_PIN.GetData()) + 11); + return ZByteSwap_ReadLittle32(static_cast<const char*>(theMB_PIN.GetPtr()) + 11); return 0; } @@ -1062,7 +1062,7 @@ // We've already read one byte (containing the command); Data theMB(iPayloadSize - 1); - iStreamR.Read(theMB.GetDataMutable(), theMB.GetSize()); + iStreamR.Read(theMB.GetPtrMutable(), theMB.GetSize()); ZGuardRMtxR locker(fMutex); ZAssert(fGetAttribute); Modified: trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_DatonSet.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_DatonSet.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/more/zoolib/dataspace/ZDataspace_Source_DatonSet.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -69,7 +69,7 @@ static const ZStrimW& operator<<(const ZStrimW& w, const Daton& iDaton) { const ZData_Any& theData = iDaton.GetData(); - w.Write(static_cast<const UTF8*>(theData.GetData()), theData.GetSize()); + w.Write(static_cast<const UTF8*>(theData.GetPtr()), theData.GetSize()); return w; } Modified: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime_Val.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime_Val.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime_Val.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -120,7 +120,7 @@ { return sAsVal(ZStreamRPos_Memory(iSource, iSize)); } ZQ<ZVal_Any> sAsVal(const ZData_Any& iData) - { return sAsVal(iData.GetData(), iData.GetSize()); } + { return sAsVal(iData.GetPtr(), iData.GetSize()); } } // namespace QuickTime } // namespace FileFormat Modified: trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime_Val.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime_Val.h 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/more/zoolib/fileformat/ZFileFormat_QuickTime_Val.h 2012-01-23 18:18:12 UTC (rev 2681) @@ -41,7 +41,6 @@ ZQ<ZVal_Any> sAsVal(const ZData_Any& iData); ZQ<ZVal_Any> sAsVal(const ZStreamR& iStreamR); - } // namespace QuickTime } // namespace FileFormat } // namespace ZooLib Modified: trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Host_Std.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Host_Std.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_Host_Std.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -650,7 +650,7 @@ fNPStream.lastmodified = 0; fNPStream.notifyData = iNotifyData; fNPStream.headers = nullptr; -// fNPStream.headers = static_cast<const char*>(fHeaders.GetData()); +// fNPStream.headers = static_cast<const char*>(fHeaders.GetPtr()); } Host_Std::Sender::~Sender() Modified: trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -151,9 +151,9 @@ { \ Data theVal(theLength); \ if (0 == theLength \ - || noErr == SUITE->GetData(iSource, iKey, theVal.GetDataMutable())) \ + || noErr == SUITE->GetData(iSource, iKey, theVal.GetPtrMutable())) \ { \ - SUITE->PutData(DEST, theVal.GetSize(), theVal.GetDataMutable()); \ + SUITE->PutData(DEST, theVal.GetSize(), theVal.GetPtrMutable()); \ } \ } \ break; \ @@ -250,7 +250,7 @@ if (noErr == SUITE->GetDataLength(P0, P1, &theLength)) \ { \ Data result(theLength); \ - if (0 == theLength || noErr == SUITE->GetData(P0, P1, result.GetDataMutable())) \ + if (0 == theLength || noErr == SUITE->GetData(P0, P1, result.GetPtrMutable())) \ return result; \ } \ break; \ @@ -287,7 +287,7 @@ else if (const FileRef* theVal = iVal.PGet<FileRef>()) \ { SUITE->PutAlias(PARAM, theVal->Get()); } \ else if (const Data* theVal = iVal.PGet<Data>()) \ - { SUITE->PutData(PARAM, theVal->GetSize(), const_cast<void*>(theVal->GetData())); } + { SUITE->PutData(PARAM, theVal->GetSize(), const_cast<void*>(theVal->GetPtr())); } // ================================================================================================= // MARK: - ZPhotoshop suites, for local use Modified: trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -1246,7 +1246,7 @@ const ZData_ZooLib* theMemoryBlock = sFetch_T<ZData_ZooLib>(fType.fBytes); iStreamW.WriteCount(theMemoryBlock->GetSize()); if (theMemoryBlock->GetSize()) - iStreamW.Write(theMemoryBlock->GetData(), theMemoryBlock->GetSize()); + iStreamW.Write(theMemoryBlock->GetPtr(), theMemoryBlock->GetSize()); break; } case eZType_Vector: @@ -1712,7 +1712,7 @@ { try { - iStreamR.Read(theRaw->GetDataMutable(), size); + iStreamR.Read(theRaw->GetPtrMutable(), size); } catch (...) { Modified: trunk/zoolib/source/cxx/zoolib/ZData_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZData_Any.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZData_Any.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -140,10 +140,10 @@ } } -const void* ZData_Any::GetData() const +const void* ZData_Any::GetPtr() const { return ZUtil_STL::sFirstOrNil(fRep->fVector); } -void* ZData_Any::GetDataMutable() +void* ZData_Any::GetPtrMutable() { this->pTouch(); return ZUtil_STL::sFirstOrNil(fRep->fVector); Modified: trunk/zoolib/source/cxx/zoolib/ZData_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZData_Any.h 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZData_Any.h 2012-01-23 18:18:12 UTC (rev 2681) @@ -53,8 +53,8 @@ size_t GetSize() const; void SetSize(size_t iSize); - const void* GetData() const; - void* GetDataMutable(); + const void* GetPtr() const; + void* GetPtrMutable(); void CopyFrom(size_t iOffset, const void* iSource, size_t iCount); void CopyFrom(const void* iSource, size_t iCount); Modified: trunk/zoolib/source/cxx/zoolib/ZData_CF.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZData_CF.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZData_CF.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -127,14 +127,14 @@ ::CFDataSetLength(this->pTouch(), iSize); } -const void* ZData_CF::GetData() const +const void* ZData_CF::GetPtr() const { if (CFDataRef theData = this->pData()) return ::CFDataGetBytePtr(theData); return nullptr; } -void* ZData_CF::GetDataMutable() +void* ZData_CF::GetPtrMutable() { return ::CFDataGetMutableBytePtr(this->pTouch()); } void ZData_CF::CopyFrom(size_t iOffset, const void* iSource, size_t iCount) Modified: trunk/zoolib/source/cxx/zoolib/ZData_CF.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZData_CF.h 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZData_CF.h 2012-01-23 18:18:12 UTC (rev 2681) @@ -66,8 +66,8 @@ size_t GetSize() const; void SetSize(size_t iSize); - const void* GetData() const; - void* GetDataMutable(); + const void* GetPtr() const; + void* GetPtrMutable(); void CopyFrom(size_t iOffset, const void* iSource, size_t iCount); void CopyFrom(const void* iSource, size_t iCount); Modified: trunk/zoolib/source/cxx/zoolib/ZData_NS.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZData_NS.h 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZData_NS.h 2012-01-23 18:18:12 UTC (rev 2681) @@ -68,8 +68,8 @@ size_t GetSize() const; void SetSize(size_t iSize); - const void* GetData() const; - void* GetDataMutable(); + const void* GetPtr() const; + void* GetPtrMutable(); void CopyFrom(size_t iOffset, const void* iSource, size_t iCount); void CopyFrom(const void* iSource, size_t iCount); Modified: trunk/zoolib/source/cxx/zoolib/ZData_NS.mm =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZData_NS.mm 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZData_NS.mm 2012-01-23 18:18:12 UTC (rev 2681) @@ -123,14 +123,14 @@ [this->pTouch() setLength:iSize]; } -const void* ZData_NS::GetData() const +const void* ZData_NS::GetPtr() const { if (NSData* theData = this->pData()) return [theData bytes]; return nullptr; } -void* ZData_NS::GetDataMutable() +void* ZData_NS::GetPtrMutable() { return [this->pTouch() mutableBytes]; } void ZData_NS::CopyFrom(size_t iOffset, const void* iSource, size_t iCount) Modified: trunk/zoolib/source/cxx/zoolib/ZNatter.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZNatter.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZNatter.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -160,7 +160,7 @@ w.WriteUInt8(2); w.WriteInt64(iExchange->fID ^ 1); w.WriteCount(iData.GetSize()); - w.Write(iData.GetData(), iData.GetSize()); + w.Write(iData.GetPtr(), iData.GetSize()); w.Flush(); } catch (...) Modified: trunk/zoolib/source/cxx/zoolib/ZUtil_CF.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_CF.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_CF.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -329,7 +329,7 @@ else if (const ZData_Any* theValue = iVal.PGet<ZData_Any>()) { if (size_t theSize = theValue->GetSize()) - return sData(theValue->GetData(), theSize); + return sData(theValue->GetPtr(), theSize); else return sData(); } Modified: trunk/zoolib/source/cxx/zoolib/ZUtil_NS.mm =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_NS.mm 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_NS.mm 2012-01-23 18:18:12 UTC (rev 2681) @@ -170,7 +170,7 @@ else if (const ZData_Any* theValue = iVal.PGet<ZData_Any>()) { if (size_t theSize = theValue->GetSize()) - return sData(theValue->GetData(), theSize); + return sData(theValue->GetPtr(), theSize); else return sData(); } Modified: trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.cpp 2012-01-19 22:37:47 UTC (rev 2680) +++ trunk/zoolib/source/cxx/zoolib/ZYad_AppleEvent.cpp 2012-01-23 18:18:12 UTC (rev 2681) @@ -38,7 +38,7 @@ const size_t theSize = ::AEGetDescDataSize(&iAEDesc); ZData_Any theData(theSize); - ::AEGetDescData(&iAEDesc, theData.GetDataMutable(), theSize); + ::AEGetDescData(&iAEDesc, theData.GetPtrMutable(), theSize); theMap.Set("Value", theData); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2012-02-01 18:51:43
|
Revision: 2708 http://zoolib.svn.sourceforge.net/zoolib/?rev=2708&view=rev Author: agreen Date: 2012-02-01 18:51:31 +0000 (Wed, 01 Feb 2012) Log Message: ----------- Get rid of last 'bool QGet' methods. Clean up ZValAccessors.h Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.cpp trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_VariantPriv.h trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.h trunk/zoolib/source/cxx/zoolib/ZValAccessors.h trunk/zoolib/source/cxx/zoolib/ZValAccessors_Std.h trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp trunk/zoolib/source/cxx/zoolib/ZVal_Any.h trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h trunk/zoolib/source/cxx/zoolib/ZVal_CF.cpp trunk/zoolib/source/cxx/zoolib/ZVal_CF.h trunk/zoolib/source/cxx/zoolib/ZVal_NS.h trunk/zoolib/source/cxx/zoolib/ZVal_NS.mm trunk/zoolib/source/cxx/zoolib/ZVal_Yad.cpp trunk/zoolib/source/cxx/zoolib/ZVal_Yad.h trunk/zoolib/source/cxx/zoolib/ZWinCOM.cpp trunk/zoolib/source/cxx/zoolib/ZWinCOM.h trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Val.cpp trunk/zoolib/source/cxx/zoolib/ZYad_NS.mm Modified: trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.cpp 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/more/zoolib/javascriptcore/ZJavaScriptCore.cpp 2012-02-01 18:51:31 UTC (rev 2708) @@ -546,10 +546,10 @@ return null; } -ZMACRO_ZValAccessors_Def_GetP(,Value, Bool, bool) -ZMACRO_ZValAccessors_Def_GetP(,Value, Double, double) -ZMACRO_ZValAccessors_Def_GetP(,Value, String, String) -ZMACRO_ZValAccessors_Def_GetP(,Value, ObjectRef, ObjectRef) +ZMACRO_ZValAccessors_Def_Get(Value, Bool, bool) +ZMACRO_ZValAccessors_Def_Get(Value, Double, double) +ZMACRO_ZValAccessors_Def_Get(Value, String, String) +ZMACRO_ZValAccessors_Def_Get(Value, ObjectRef, ObjectRef) // ================================================================================================= // MARK: - ZJavaScriptCore::ObjectRef Modified: trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_VariantPriv.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_VariantPriv.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/more/zoolib/netscape/ZNetscape_VariantPriv.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -365,11 +365,11 @@ // ================================================================================================= // MARK: - NPVariant_T<T> typename accessors -ZMACRO_ZValAccessors_Def_GetP(template <class T>, NPVariant_T<T>, Bool, bool) -ZMACRO_ZValAccessors_Def_GetP(template <class T>, NPVariant_T<T>, Int32, int32) -ZMACRO_ZValAccessors_Def_GetP(template <class T>, NPVariant_T<T>, Double, double) -ZMACRO_ZValAccessors_Def_GetP(template <class T>, NPVariant_T<T>, String, std::string) -ZMACRO_ZValAccessors_Def_GetP(template <class T>, NPVariant_T<T>, Object, ZRef<T>) +ZMACRO_ZValAccessors_Def_GetX(template <class T>, NPVariant_T<T>, Bool, bool) +ZMACRO_ZValAccessors_Def_GetX(template <class T>, NPVariant_T<T>, Int32, int32) +ZMACRO_ZValAccessors_Def_GetX(template <class T>, NPVariant_T<T>, Double, double) +ZMACRO_ZValAccessors_Def_GetX(template <class T>, NPVariant_T<T>, String, std::string) +ZMACRO_ZValAccessors_Def_GetX(template <class T>, NPVariant_T<T>, Object, ZRef<T>) } // namespace ZNetscape } // namespace ZooLib Modified: trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.cpp 2012-02-01 18:51:31 UTC (rev 2708) @@ -1078,18 +1078,18 @@ // ================================================================================================= // MARK: - Val typename accessors -ZMACRO_ZValAccessors_Def_Entry(Val, Int32, int32) -ZMACRO_ZValAccessors_Def_Entry(Val, Double, double) -ZMACRO_ZValAccessors_Def_Entry(Val, Bool, bool) -ZMACRO_ZValAccessors_Def_Entry(Val, String, string8) -ZMACRO_ZValAccessors_Def_Entry(Val, Data, Data) -ZMACRO_ZValAccessors_Def_Entry(Val, ClassID, ClassID) -ZMACRO_ZValAccessors_Def_Entry(Val, UnitFloat, UnitFloat) -ZMACRO_ZValAccessors_Def_Entry(Val, Enumerated, Enumerated) -ZMACRO_ZValAccessors_Def_Entry(Val, FileRef, FileRef) -ZMACRO_ZValAccessors_Def_Entry(Val, Seq, Seq) -ZMACRO_ZValAccessors_Def_Entry(Val, Map, Map) -ZMACRO_ZValAccessors_Def_Entry(Val, Spec, Spec) +ZMACRO_ZValAccessors_Def_GetSet(Val, Int32, int32) +ZMACRO_ZValAccessors_Def_GetSet(Val, Double, double) +ZMACRO_ZValAccessors_Def_GetSet(Val, Bool, bool) +ZMACRO_ZValAccessors_Def_GetSet(Val, String, string8) +ZMACRO_ZValAccessors_Def_GetSet(Val, Data, Data) +ZMACRO_ZValAccessors_Def_GetSet(Val, ClassID, ClassID) +ZMACRO_ZValAccessors_Def_GetSet(Val, UnitFloat, UnitFloat) +ZMACRO_ZValAccessors_Def_GetSet(Val, Enumerated, Enumerated) +ZMACRO_ZValAccessors_Def_GetSet(Val, FileRef, FileRef) +ZMACRO_ZValAccessors_Def_GetSet(Val, Seq, Seq) +ZMACRO_ZValAccessors_Def_GetSet(Val, Map, Map) +ZMACRO_ZValAccessors_Def_GetSet(Val, Spec, Spec) // ================================================================================================= // MARK: - Seq Modified: trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/more/zoolib/photoshop/ZPhotoshop_Val.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -243,18 +243,18 @@ // Typename accessors /// \cond DoxygenIgnore - ZMACRO_ZValAccessors_Decl_Entry(Val, Int32, int32) - ZMACRO_ZValAccessors_Decl_Entry(Val, Double, double) - ZMACRO_ZValAccessors_Decl_Entry(Val, Bool, bool) - ZMACRO_ZValAccessors_Decl_Entry(Val, String, string8) - ZMACRO_ZValAccessors_Decl_Entry(Val, Data, Data) - ZMACRO_ZValAccessors_Decl_Entry(Val, ClassID, ClassID) - ZMACRO_ZValAccessors_Decl_Entry(Val, UnitFloat, UnitFloat) - ZMACRO_ZValAccessors_Decl_Entry(Val, Enumerated, Enumerated) - ZMACRO_ZValAccessors_Decl_Entry(Val, FileRef, FileRef) - ZMACRO_ZValAccessors_Decl_Entry(Val, Seq, Seq) - ZMACRO_ZValAccessors_Decl_Entry(Val, Map, Map) - ZMACRO_ZValAccessors_Decl_Entry(Val, Spec, Spec) + ZMACRO_ZValAccessors_Decl_GetSet(Val, Int32, int32) + ZMACRO_ZValAccessors_Decl_GetSet(Val, Double, double) + ZMACRO_ZValAccessors_Decl_GetSet(Val, Bool, bool) + ZMACRO_ZValAccessors_Decl_GetSet(Val, String, string8) + ZMACRO_ZValAccessors_Decl_GetSet(Val, Data, Data) + ZMACRO_ZValAccessors_Decl_GetSet(Val, ClassID, ClassID) + ZMACRO_ZValAccessors_Decl_GetSet(Val, UnitFloat, UnitFloat) + ZMACRO_ZValAccessors_Decl_GetSet(Val, Enumerated, Enumerated) + ZMACRO_ZValAccessors_Decl_GetSet(Val, FileRef, FileRef) + ZMACRO_ZValAccessors_Decl_GetSet(Val, Seq, Seq) + ZMACRO_ZValAccessors_Decl_GetSet(Val, Map, Map) + ZMACRO_ZValAccessors_Decl_GetSet(Val, Spec, Spec) /// \endcond DoxygenIgnore }; Modified: trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.cpp 2012-02-01 18:51:31 UTC (rev 2708) @@ -1265,20 +1265,20 @@ // MARK: - ZVal_ZooLib typename accessors ZMACRO_ZValAccessors_Def_Std(ZVal_ZooLib) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, ID, uint64) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Type, ZType) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Time, ZTime) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Rect, ZRectPOD) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Point, ZPointPOD) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, RefCounted, ZRef<ZCounted>) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Pointer, VoidStar_t) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Data, ZData_ZooLib) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Seq, ZSeq_ZooLib) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Map, ZMap_ZooLib) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, ID, uint64) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Type, ZType) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Time, ZTime) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Rect, ZRectPOD) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Point, ZPointPOD) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, RefCounted, ZRef<ZCounted>) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Pointer, VoidStar_t) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Data, ZData_ZooLib) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Seq, ZSeq_ZooLib) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Map, ZMap_ZooLib) // Backwards compatibility -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Raw, ZData_ZooLib) -ZMACRO_ZValAccessors_Def_Entry(ZVal_ZooLib, Tuple, ZMap_ZooLib) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Raw, ZData_ZooLib) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_ZooLib, Tuple, ZMap_ZooLib) // ================================================================================================= // MARK: - ZVal_ZooLib internal implementation Modified: trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.h =================================================================== --- trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/old/zoolib/ZVal_ZooLib.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -195,20 +195,20 @@ // Typename accessors /// \cond DoxygenIgnore ZMACRO_ZValAccessors_Decl_Std(ZVal_ZooLib) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, ID, uint64) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Type, ZType) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Time, ZTime) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Rect, ZRectPOD) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Point, ZPointPOD) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, RefCounted, ZRef<ZCounted>) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Pointer, VoidStar_t) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Data, ZData_ZooLib) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Seq, ZSeq_ZooLib) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Map, ZMap_ZooLib) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, ID, uint64) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Type, ZType) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Time, ZTime) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Rect, ZRectPOD) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Point, ZPointPOD) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, RefCounted, ZRef<ZCounted>) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Pointer, VoidStar_t) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Data, ZData_ZooLib) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Seq, ZSeq_ZooLib) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Map, ZMap_ZooLib) // Backwards compatibility - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Raw, ZData_ZooLib) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_ZooLib, Tuple, ZMap_ZooLib) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Raw, ZData_ZooLib) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_ZooLib, Tuple, ZMap_ZooLib) /// \endcond DoxygenIgnore private: Modified: trunk/zoolib/source/cxx/zoolib/ZValAccessors.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZValAccessors.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZValAccessors.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -25,36 +25,47 @@ // ================================================================================================= // MARK: - ZMACRO_ZValAccessors +// Declaration, Get + #define ZMACRO_ZValAccessors_Decl_Get(T, TYPENAME, TYPE) \ ZQ<TYPE> QGet##TYPENAME() const; \ - bool QGet##TYPENAME(TYPE& oVal) const; \ TYPE DGet##TYPENAME(const TYPE& iDefault) const; \ TYPE Get##TYPENAME() const; \ -#define ZMACRO_ZValAccessors_Decl_Entry(T, TYPENAME, TYPE) \ +// Declaration, GetSet + +#define ZMACRO_ZValAccessors_Decl_GetSet(T, TYPENAME, TYPE) \ ZMACRO_ZValAccessors_Decl_Get(T, TYPENAME, TYPE) \ void Set##TYPENAME(const TYPE& iVal); \ -#define ZMACRO_ZValAccessors_Def_GetP(P, T, TYPENAME, TYPE) \ - P ZQ<TYPE> T::QGet##TYPENAME() const \ + +// Definition, Get, with leading extra qualification + +#define ZMACRO_ZValAccessors_Def_GetX(X, T, TYPENAME, TYPE) \ + X ZQ<TYPE> T::QGet##TYPENAME() const \ { return this->QGet<TYPE>(); } \ - P bool T::QGet##TYPENAME(TYPE& oVal) const \ - { \ - if (ZQ<TYPE> theQ = this->QGet<TYPE>()) \ - { oVal = theQ.Get(); return true; } \ - return false; \ - } \ - P TYPE T::DGet##TYPENAME(const TYPE& iDefault) const \ + X TYPE T::DGet##TYPENAME(const TYPE& iDefault) const \ { return this->DGet<TYPE>(iDefault); } \ - P TYPE T::Get##TYPENAME() const \ + X TYPE T::Get##TYPENAME() const \ { return this->Get<TYPE>(); } \ -#define ZMACRO_ZValAccessors_Def_EntryP(P, T, TYPENAME, TYPE) \ - ZMACRO_ZValAccessors_Def_GetP(P, T, TYPENAME, TYPE) \ - P void T::Set##TYPENAME(const TYPE& iVal) \ + +// Definition, GetSet, with leading extra qualification + +#define ZMACRO_ZValAccessors_Def_GetSetX(X, T, TYPENAME, TYPE) \ + ZMACRO_ZValAccessors_Def_GetX(X, T, TYPENAME, TYPE) \ + X void T::Set##TYPENAME(const TYPE& iVal) \ { return this->Set<TYPE>(iVal); } \ -#define ZMACRO_ZValAccessors_Def_Entry(T, TYPENAME, TYPE) \ - ZMACRO_ZValAccessors_Def_EntryP(,T,TYPENAME, TYPE) +// Definition, Get + +#define ZMACRO_ZValAccessors_Def_Get(T, TYPENAME, TYPE) \ + ZMACRO_ZValAccessors_Def_GetX(,T,TYPENAME, TYPE) + +// Definition, GetSet + +#define ZMACRO_ZValAccessors_Def_GetSet(T, TYPENAME, TYPE) \ + ZMACRO_ZValAccessors_Def_GetSetX(,T,TYPENAME, TYPE) + #endif // __ZValAccessors_h__ Modified: trunk/zoolib/source/cxx/zoolib/ZValAccessors_Std.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZValAccessors_Std.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZValAccessors_Std.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -31,23 +31,23 @@ // MARK: - ZMACRO_ZValAccessors_Std #define ZMACRO_ZValAccessors_Decl_Std(T) \ - ZMACRO_ZValAccessors_Decl_Entry(T, Int8, int8) \ - ZMACRO_ZValAccessors_Decl_Entry(T, Int16, int16) \ - ZMACRO_ZValAccessors_Decl_Entry(T, Int32, int32) \ - ZMACRO_ZValAccessors_Decl_Entry(T, Int64, int64) \ - ZMACRO_ZValAccessors_Decl_Entry(T, Bool, bool) \ - ZMACRO_ZValAccessors_Decl_Entry(T, Float, float) \ - ZMACRO_ZValAccessors_Decl_Entry(T, Double, double) \ - ZMACRO_ZValAccessors_Decl_Entry(T, String, std::string) \ + ZMACRO_ZValAccessors_Decl_GetSet(T, Int8, int8) \ + ZMACRO_ZValAccessors_Decl_GetSet(T, Int16, int16) \ + ZMACRO_ZValAccessors_Decl_GetSet(T, Int32, int32) \ + ZMACRO_ZValAccessors_Decl_GetSet(T, Int64, int64) \ + ZMACRO_ZValAccessors_Decl_GetSet(T, Bool, bool) \ + ZMACRO_ZValAccessors_Decl_GetSet(T, Float, float) \ + ZMACRO_ZValAccessors_Decl_GetSet(T, Double, double) \ + ZMACRO_ZValAccessors_Decl_GetSet(T, String, std::string) \ #define ZMACRO_ZValAccessors_Def_Std(T) \ - ZMACRO_ZValAccessors_Def_Entry(T, Int8, int8) \ - ZMACRO_ZValAccessors_Def_Entry(T, Int16, int16) \ - ZMACRO_ZValAccessors_Def_Entry(T, Int32, int32) \ - ZMACRO_ZValAccessors_Def_Entry(T, Int64, int64) \ - ZMACRO_ZValAccessors_Def_Entry(T, Bool, bool) \ - ZMACRO_ZValAccessors_Def_Entry(T, Float, float) \ - ZMACRO_ZValAccessors_Def_Entry(T, Double, double) \ - ZMACRO_ZValAccessors_Def_Entry(T, String, std::string) \ + ZMACRO_ZValAccessors_Def_GetSet(T, Int8, int8) \ + ZMACRO_ZValAccessors_Def_GetSet(T, Int16, int16) \ + ZMACRO_ZValAccessors_Def_GetSet(T, Int32, int32) \ + ZMACRO_ZValAccessors_Def_GetSet(T, Int64, int64) \ + ZMACRO_ZValAccessors_Def_GetSet(T, Bool, bool) \ + ZMACRO_ZValAccessors_Def_GetSet(T, Float, float) \ + ZMACRO_ZValAccessors_Def_GetSet(T, Double, double) \ + ZMACRO_ZValAccessors_Def_GetSet(T, String, std::string) \ #endif // __ZValAccessors_Std_h__ Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp 2012-02-01 18:51:31 UTC (rev 2708) @@ -114,9 +114,9 @@ ZVal_Any ZVal_Any::Get(size_t iIndex) const { return this->GetSeq().Get(iIndex); } -ZMACRO_ZValAccessors_Def_Entry(ZVal_Any, Data, ZData_Any) -ZMACRO_ZValAccessors_Def_Entry(ZVal_Any, Seq, ZSeq_Any) -ZMACRO_ZValAccessors_Def_Entry(ZVal_Any, Map, ZMap_Any) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_Any, Data, ZData_Any) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_Any, Seq, ZSeq_Any) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_Any, Map, ZMap_Any) // ================================================================================================= // MARK: - ZSeq_Any::Rep Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -215,9 +215,9 @@ // Typename accessors /// \cond DoxygenIgnore - ZMACRO_ZValAccessors_Decl_Entry(ZVal_Any, Data, ZData_Any) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_Any, Seq, ZSeq_Any) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_Any, Map, ZMap_Any) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_Any, Data, ZData_Any) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_Any, Seq, ZSeq_Any) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_Any, Map, ZMap_Any) /// \endcond DoxygenIgnore // If these are free functions then our template constructor will Modified: trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.cpp 2012-02-01 18:51:31 UTC (rev 2708) @@ -458,19 +458,19 @@ // ================================================================================================= // MARK: - ZVal_AppleEvent typename accessors -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, Int16, int16) -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, Int32, int32) -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, Int64, int64) -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, Bool, bool) -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, Float, float) -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, Double, double) -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, String, std::string) -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, Seq, ZSeq_AppleEvent) -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, Map, ZMap_AppleEvent) -ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, FSRef, FSRef) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, Int16, int16) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, Int32, int32) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, Int64, int64) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, Bool, bool) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, Float, float) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, Double, double) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, String, std::string) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, Seq, ZSeq_AppleEvent) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, Map, ZMap_AppleEvent) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, FSRef, FSRef) #if ZCONFIG_SPI_Enabled(Carbon) - ZMACRO_ZValAccessors_Def_Entry(ZVal_AppleEvent, FSSpec, FSSpec) + ZMACRO_ZValAccessors_Def_GetSet(ZVal_AppleEvent, FSSpec, FSSpec) #endif // ================================================================================================= Modified: trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_AppleEvent.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -119,19 +119,19 @@ // Typename accessors /// \cond DoxygenIgnore - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, Int16, int16) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, Int32, int32) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, Int64, int64) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, Bool, bool) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, Float, float) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, Double, double) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, String, std::string) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, Seq, ZSeq_AppleEvent) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, Map, ZMap_AppleEvent) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, FSRef, FSRef) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, Int16, int16) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, Int32, int32) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, Int64, int64) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, Bool, bool) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, Float, float) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, Double, double) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, String, std::string) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, Seq, ZSeq_AppleEvent) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, Map, ZMap_AppleEvent) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, FSRef, FSRef) #if ZCONFIG_SPI_Enabled(Carbon) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_AppleEvent, FSSpec, FSSpec) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_AppleEvent, FSSpec, FSSpec) #endif /// \endcond DoxygenIgnore }; Modified: trunk/zoolib/source/cxx/zoolib/ZVal_CF.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_CF.cpp 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_CF.cpp 2012-02-01 18:51:31 UTC (rev 2708) @@ -471,10 +471,10 @@ // MARK: - ZVal_CF typename accessors ZMACRO_ZValAccessors_Def_Std(ZVal_CF) -ZMACRO_ZValAccessors_Def_Entry(ZVal_CF, CFString, ZRef<CFStringRef>) -ZMACRO_ZValAccessors_Def_Entry(ZVal_CF, Data, ZData_CF) -ZMACRO_ZValAccessors_Def_Entry(ZVal_CF, Seq, ZSeq_CF) -ZMACRO_ZValAccessors_Def_Entry(ZVal_CF, Map, ZMap_CF) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_CF, CFString, ZRef<CFStringRef>) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_CF, Data, ZData_CF) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_CF, Seq, ZSeq_CF) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_CF, Map, ZMap_CF) // ================================================================================================= // MARK: - ZSeq_CF Modified: trunk/zoolib/source/cxx/zoolib/ZVal_CF.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_CF.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_CF.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -136,10 +136,10 @@ // Typename accessors /// \cond DoxygenIgnore ZMACRO_ZValAccessors_Decl_Std(ZVal_CF) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_CF, CFString, ZRef<CFStringRef>) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_CF, Data, ZData_CF) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_CF, Seq, ZSeq_CF) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_CF, Map, ZMap_CF) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_CF, CFString, ZRef<CFStringRef>) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_CF, Data, ZData_CF) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_CF, Seq, ZSeq_CF) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_CF, Map, ZMap_CF) /// \endcond DoxygenIgnore }; Modified: trunk/zoolib/source/cxx/zoolib/ZVal_NS.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_NS.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_NS.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -149,10 +149,10 @@ typedef NSString* NSStringPtr; ZMACRO_ZValAccessors_Decl_Std(ZVal_NS) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_NS, NSString, NSStringPtr) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_NS, Data, ZData_NS) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_NS, Seq, ZSeq_NS) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_NS, Map, ZMap_NS) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_NS, NSString, NSStringPtr) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_NS, Data, ZData_NS) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_NS, Seq, ZSeq_NS) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_NS, Map, ZMap_NS) /// \endcond DoxygenIgnore }; Modified: trunk/zoolib/source/cxx/zoolib/ZVal_NS.mm =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_NS.mm 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_NS.mm 2012-02-01 18:51:31 UTC (rev 2708) @@ -384,10 +384,10 @@ // MARK: - ZVal_NS typename accessors ZMACRO_ZValAccessors_Def_Std(ZVal_NS) -ZMACRO_ZValAccessors_Def_Entry(ZVal_NS, NSString, ZVal_NS::NSStringPtr) -ZMACRO_ZValAccessors_Def_Entry(ZVal_NS, Data, ZData_NS) -ZMACRO_ZValAccessors_Def_Entry(ZVal_NS, Seq, ZSeq_NS) -ZMACRO_ZValAccessors_Def_Entry(ZVal_NS, Map, ZMap_NS) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_NS, NSString, ZVal_NS::NSStringPtr) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_NS, Data, ZData_NS) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_NS, Seq, ZSeq_NS) +ZMACRO_ZValAccessors_Def_GetSet(ZVal_NS, Map, ZMap_NS) // ================================================================================================= // MARK: - ZSeq_NS Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Yad.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Yad.cpp 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Yad.cpp 2012-02-01 18:51:31 UTC (rev 2708) @@ -132,8 +132,8 @@ return ZAny(); } -ZMACRO_ZValAccessors_Def_GetP(,ZVal_Yad, Seq, ZSeq_Yad) -ZMACRO_ZValAccessors_Def_GetP(,ZVal_Yad, Map, ZMap_Yad) +ZMACRO_ZValAccessors_Def_Get(ZVal_Yad, Seq, ZSeq_Yad) +ZMACRO_ZValAccessors_Def_Get(ZVal_Yad, Map, ZMap_Yad) // ================================================================================================= // MARK: - ZSeq_Yad Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Yad.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Yad.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Yad.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -105,8 +105,8 @@ // Typename accessors /// \cond DoxygenIgnore - ZMACRO_ZValAccessors_Decl_Entry(ZVal_Yad, Seq, ZSeq_Yad) - ZMACRO_ZValAccessors_Decl_Entry(ZVal_Yad, Map, ZMap_Yad) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_Yad, Seq, ZSeq_Yad) + ZMACRO_ZValAccessors_Decl_GetSet(ZVal_Yad, Map, ZMap_Yad) /// \endcond DoxygenIgnore // Our protocol Modified: trunk/zoolib/source/cxx/zoolib/ZWinCOM.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWinCOM.cpp 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZWinCOM.cpp 2012-02-01 18:51:31 UTC (rev 2708) @@ -433,22 +433,22 @@ } /// \cond DoxygenIgnore -ZMACRO_ZValAccessors_Def_Entry(Variant, Int8, int8) -ZMACRO_ZValAccessors_Def_Entry(Variant, UInt, uint8) -ZMACRO_ZValAccessors_Def_Entry(Variant, Int16, int16) -ZMACRO_ZValAccessors_Def_Entry(Variant, UInt16, uint16) -ZMACRO_ZValAccessors_Def_Entry(Variant, Int32, int32) -ZMACRO_ZValAccessors_Def_Entry(Variant, UInt32, uint32) -ZMACRO_ZValAccessors_Def_Entry(Variant, Int64, int64) -ZMACRO_ZValAccessors_Def_Entry(Variant, UInt64, uint64) -ZMACRO_ZValAccessors_Def_Entry(Variant, Bool, bool) -ZMACRO_ZValAccessors_Def_Entry(Variant, Float, float) -ZMACRO_ZValAccessors_Def_Entry(Variant, Double, double) -ZMACRO_ZValAccessors_Def_Entry(Variant, String, string8) -ZMACRO_ZValAccessors_Def_Entry(Variant, String8, string8) -ZMACRO_ZValAccessors_Def_Entry(Variant, String16, string16) -ZMACRO_ZValAccessors_Def_Entry(Variant, Unknown, ZRef<IUnknown>) -ZMACRO_ZValAccessors_Def_Entry(Variant, Dispatch, ZRef<IDispatch>) +ZMACRO_ZValAccessors_Def_GetSet(Variant, Int8, int8) +ZMACRO_ZValAccessors_Def_GetSet(Variant, UInt, uint8) +ZMACRO_ZValAccessors_Def_GetSet(Variant, Int16, int16) +ZMACRO_ZValAccessors_Def_GetSet(Variant, UInt16, uint16) +ZMACRO_ZValAccessors_Def_GetSet(Variant, Int32, int32) +ZMACRO_ZValAccessors_Def_GetSet(Variant, UInt32, uint32) +ZMACRO_ZValAccessors_Def_GetSet(Variant, Int64, int64) +ZMACRO_ZValAccessors_Def_GetSet(Variant, UInt64, uint64) +ZMACRO_ZValAccessors_Def_GetSet(Variant, Bool, bool) +ZMACRO_ZValAccessors_Def_GetSet(Variant, Float, float) +ZMACRO_ZValAccessors_Def_GetSet(Variant, Double, double) +ZMACRO_ZValAccessors_Def_GetSet(Variant, String, string8) +ZMACRO_ZValAccessors_Def_GetSet(Variant, String8, string8) +ZMACRO_ZValAccessors_Def_GetSet(Variant, String16, string16) +ZMACRO_ZValAccessors_Def_GetSet(Variant, Unknown, ZRef<IUnknown>) +ZMACRO_ZValAccessors_Def_GetSet(Variant, Dispatch, ZRef<IDispatch>) /// \endcond DoxygenIgnore // ================================================================================================= Modified: trunk/zoolib/source/cxx/zoolib/ZWinCOM.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWinCOM.h 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZWinCOM.h 2012-02-01 18:51:31 UTC (rev 2708) @@ -306,22 +306,22 @@ // Typename accessors /// \cond DoxygenIgnore - ZMACRO_ZValAccessors_Decl_Entry(Variant, Int8, int8) - ZMACRO_ZValAccessors_Decl_Entry(Variant, UInt, uint8) - ZMACRO_ZValAccessors_Decl_Entry(Variant, Int16, int16) - ZMACRO_ZValAccessors_Decl_Entry(Variant, UInt16, uint16) - ZMACRO_ZValAccessors_Decl_Entry(Variant, Int32, int32) - ZMACRO_ZValAccessors_Decl_Entry(Variant, UInt32, uint32) - ZMACRO_ZValAccessors_Decl_Entry(Variant, Int64, int64) - ZMACRO_ZValAccessors_Decl_Entry(Variant, UInt64, uint64) - ZMACRO_ZValAccessors_Decl_Entry(Variant, Bool, bool) - ZMACRO_ZValAccessors_Decl_Entry(Variant, Float, float) - ZMACRO_ZValAccessors_Decl_Entry(Variant, Double, double) - ZMACRO_ZValAccessors_Decl_Entry(Variant, String, string8) - ZMACRO_ZValAccessors_Decl_Entry(Variant, String8, string8) - ZMACRO_ZValAccessors_Decl_Entry(Variant, String16, string16) - ZMACRO_ZValAccessors_Decl_Entry(Variant, Unknown, ZRef<IUnknown>) - ZMACRO_ZValAccessors_Decl_Entry(Variant, Dispatch, ZRef<IDispatch>) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, Int8, int8) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, UInt, uint8) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, Int16, int16) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, UInt16, uint16) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, Int32, int32) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, UInt32, uint32) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, Int64, int64) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, UInt64, uint64) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, Bool, bool) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, Float, float) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, Double, double) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, String, string8) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, String8, string8) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, String16, string16) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, Unknown, ZRef<IUnknown>) + ZMACRO_ZValAccessors_Decl_GetSet(Variant, Dispatch, ZRef<IDispatch>) /// \endcond DoxygenIgnore }; Modified: trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Val.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Val.cpp 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZWinRegistry_Val.cpp 2012-02-01 18:51:31 UTC (rev 2708) @@ -263,14 +263,14 @@ return Val(); } -ZMACRO_ZValAccessors_Def_GetP(,Val, String16, string16) -ZMACRO_ZValAccessors_Def_GetP(,Val, StringList, vector<string16>) -ZMACRO_ZValAccessors_Def_GetP(,Val, String_Env, String_Env) -ZMACRO_ZValAccessors_Def_GetP(,Val, String_Link, String_Link) -ZMACRO_ZValAccessors_Def_GetP(,Val, Int32, int32) -ZMACRO_ZValAccessors_Def_GetP(,Val, Int64, int64) -ZMACRO_ZValAccessors_Def_GetP(,Val, Data, Data) -ZMACRO_ZValAccessors_Def_GetP(,Val, KeyRef, KeyRef) +ZMACRO_ZValAccessors_Def_Get(Val, String16, string16) +ZMACRO_ZValAccessors_Def_Get(Val, StringList, vector<string16>) +ZMACRO_ZValAccessors_Def_Get(Val, String_Env, String_Env) +ZMACRO_ZValAccessors_Def_Get(Val, String_Link, String_Link) +ZMACRO_ZValAccessors_Def_Get(Val, Int32, int32) +ZMACRO_ZValAccessors_Def_Get(Val, Int64, int64) +ZMACRO_ZValAccessors_Def_Get(Val, Data, Data) +ZMACRO_ZValAccessors_Def_Get(Val, KeyRef, KeyRef) // ================================================================================================= // MARK: - ZWinRegistry::KeyRef Modified: trunk/zoolib/source/cxx/zoolib/ZYad_NS.mm =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZYad_NS.mm 2012-02-01 18:21:01 UTC (rev 2707) +++ trunk/zoolib/source/cxx/zoolib/ZYad_NS.mm 2012-02-01 18:51:31 UTC (rev 2708) @@ -129,21 +129,17 @@ { const ZVal_NS theVal = iVal; - ZMap_NS asMap; - if (theVal.QGetMap(asMap)) - return new ZYadMapRPos_NS(asMap); + if (ZQ<ZMap_NS> theQ = theVal.QGetMap()) + return new ZYadMapRPos_NS(*theQ); - ZSeq_NS asSeq; - if (theVal.QGetSeq(asSeq)) - return new ZYadSeqRPos_NS(asSeq); + if (ZQ<ZSeq_NS> theQ = theVal.QGetSeq()) + return new ZYadSeqRPos_NS(*theQ); - ZData_NS asData; - if (theVal.QGetData(asData)) - return new ZYadStreamRPos_NS(asData); + if (ZQ<ZData_NS> theQ = theVal.QGetData()) + return new ZYadStreamRPos_NS(*theQ); - NSString* asNSString; - if (theVal.QGetNSString(asNSString)) - return new ZYadStrimR_NS(asNSString); + if (ZQ<NSString*> theQ = theVal.QGetNSString()) + return new ZYadStrimR_NS(*theQ); return new ZYadAtomR_NS(iVal); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2009-07-19 17:40:59
|
Revision: 856 http://zoolib.svn.sourceforge.net/zoolib/?rev=856&view=rev Author: agreen Date: 2009-07-19 17:40:57 +0000 (Sun, 19 Jul 2009) Log Message: ----------- Move to cxx_old. Added Paths: ----------- trunk/zoolib/source/cxx_old/zoolib/ZDCPixmap_Asset_BMP.cpp trunk/zoolib/source/cxx_old/zoolib/ZDCPixmap_Asset_BMP.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.cpp trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.h Deleted: trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.cpp 2009-07-19 17:34:21 UTC (rev 855) +++ trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.cpp 2009-07-19 17:40:57 UTC (rev 856) @@ -1,417 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2002 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZDCPixmap_Asset_BMP.h" -#include "zoolib/ZAsset.h" -#include "zoolib/ZDCPixmap.h" - -using std::runtime_error; -using std::vector; - -NAMESPACE_ZOOLIB_BEGIN - -// From wingdi.h -#ifndef BI_RGB -# define BI_RGB 0L -# define BI_RLE8 1L -# define BI_RLE4 2L -# define BI_BITFIELDS 3L -#endif - -// ================================================================================================= -#pragma mark - -#pragma mark * PixmapRaster_Asset - -namespace ZANONYMOUS { - -class PixmapRaster_Asset : public ZDCPixmapRaster - { -public: - PixmapRaster_Asset(const ZAsset& iAsset, - const void* iBaseAddress, const ZDCPixmapNS::RasterDesc& iRasterDesc); - virtual ~PixmapRaster_Asset(); - -private: - ZAsset fAsset; - }; - -PixmapRaster_Asset::PixmapRaster_Asset(const ZAsset& iAsset, - const void* iBaseAddress, const ZDCPixmapNS::RasterDesc& iRasterDesc) -: ZDCPixmapRaster(iRasterDesc), - fAsset(iAsset) - { - fBaseAddress = const_cast<void*>(iBaseAddress); - } - -PixmapRaster_Asset::~PixmapRaster_Asset() - { - fBaseAddress = nullptr; - } - -} // anonymous namespace - -// ================================================================================================= -#pragma mark - -#pragma mark * ZDCPixmap_Asset_BMP::sGetPixmap - -static void sReadRLE8(const ZStreamR& iStream, - ZCoord iWidth, ZCoord iHeight, size_t iRowBytes, bool iFlip, uint8* iBuffer); - -static void sReadRLE4(const ZStreamR& iStream, - ZCoord iWidth, ZCoord iHeight, size_t iRowBytes, bool iFlip, uint8* iBuffer); - -ZDCPixmap ZDCPixmap_Asset_BMP::sGetPixmap(const ZAsset& iAsset) - { - if (!iAsset) - return ZDCPixmap(); - - // Get the data loaded before we call OpenRPos -- if the asset is file-based - // then it will create a memory based streamer if the data is already loaded. - - const void* theData; - size_t theSize; - iAsset.GetData(&theData, & theSize); - - ZRef<ZStreamerRPos> theStreamer = iAsset.OpenRPos(); - if (!theStreamer) - return ZDCPixmap(); - - const ZStreamRPos& theStream = theStreamer->GetStreamRPos(); - - // Parse the header - uint16 bfType = theStream.ReadUInt16LE(); - if (bfType != 0x4D42) - throw runtime_error("ZDCPixmap_Asset_BMP::sGetPixmap, invalid BMP file"); - - // Ignore bfSize, bfReserved1 and bfReserved2. - theStream.Skip(8); - - size_t bfOffBits = theStream.ReadUInt32LE() - 54; - - uint32 biSize = theStream.ReadUInt32LE(); - if (biSize != 0x28) - throw runtime_error("ZDCPixmap_Asset_BMP::sGetPixmap, invalid BMP file"); - - int32 biWidth = theStream.ReadUInt32LE(); - int32 biHeight = theStream.ReadUInt32LE(); - - uint16 biPlanes = theStream.ReadUInt16LE(); - // We only handle single planes - ZAssertStop(0, biPlanes == 1); - - uint16 biBitCount = theStream.ReadUInt16LE(); - uint32 biCompression = theStream.ReadUInt32LE(); - - // Ignore biSizeImage, biXPelsPerMeter and biYPelsPerMeter. - theStream.Skip(12); - - uint32 biClrUsed = theStream.ReadUInt32LE(); - /*uint32 biClrImportant =*/ theStream.ReadUInt32LE(); - - bool sourceFlipped = true; - if (biHeight < 0) - { - sourceFlipped = false; - biHeight = -biHeight; - } - - if (biClrUsed == 0) - { - if (biBitCount <= 8) - biClrUsed = 1 << biBitCount; - } - - // Read in the color table, if any - vector<ZRGBColorPOD> localColorVector; - if (biClrUsed > 0) - { - localColorVector.resize(biClrUsed); - - const uint8* theColors = static_cast<const uint8*>(theData) + theStream.GetPosition(); - theStream.Skip(biClrUsed * 4); - - for (size_t x = 0; x < biClrUsed; ++x) - { - ZRGBColorPOD& theColor = localColorVector[x]; - theColor.blue = (*theColors++) * 0x101; - theColor.green = (*theColors++) * 0x101; - theColor.red = (*theColors++) * 0x101; - ++theColors; // Ignore rgbReserved - theColor.alpha = 0xFFFFU; - } - } - - // If we're coming from a BMP file bfOffBits (the munged version) will be non zero, - // and might tell us that the pixels are actually at some different offset than - // immediately after the color table - if (bfOffBits) - theStream.Skip(bfOffBits - (biClrUsed * 4)); - - if (biCompression == BI_RGB) - { - // Uncompressed pixel data can be used as is -- we just have to set up an - // appropriate RasterDesc and PixelDesc, and pass a PixmapRaster_Asset to - // ZDCPixmap's constructor. When the raster is no longer in use by the pixmap - // (or anyone else) the ZAsset's destructor will be called and the underlying - // asset rep will be one step closer to being released. - - ZDCPixmapNS::RasterDesc theRasterDesc; - theRasterDesc.fPixvalDesc.fDepth = biBitCount; - theRasterDesc.fPixvalDesc.fBigEndian = true; - theRasterDesc.fRowBytes = ((biWidth * biBitCount + 31) / 32) * 4; - theRasterDesc.fRowCount = biHeight; - theRasterDesc.fFlipped = sourceFlipped; - - ZDCPixmapNS::PixelDesc thePixelDesc; - switch (biBitCount) - { - case 1: - case 4: - case 8: - { - thePixelDesc - = ZDCPixmapNS::PixelDesc(&localColorVector[0], localColorVector.size()); - break; - } - case 16: - { - thePixelDesc = ZDCPixmapNS::PixelDesc(0x7C00, 0x03E0, 0x001F, 0); - theRasterDesc.fPixvalDesc.fBigEndian = false; - break; - } - case 24: - { - thePixelDesc - = ZDCPixmapNS::PixelDesc(0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000); - break; - } - case 32: - { - thePixelDesc - = ZDCPixmapNS::PixelDesc(0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000); - break; - } - } - - ZRef<ZDCPixmapRaster> theRaster = new PixmapRaster_Asset(iAsset, - static_cast<const char*>(theData) + theStream.GetPosition(), theRasterDesc); - - return ZDCPixmap(new ZDCPixmapRep(theRaster, ZRect(biWidth, biHeight), thePixelDesc)); - } - else - { - // We've got RLE data and so can't use the pixel data as is -- it has - // to be expanded into a real raster. - ZAssertStop(2, biBitCount == 1 || biBitCount == 4 || biBitCount == 8); - - ZDCPixmapNS::RasterDesc sourceRasterDesc; - sourceRasterDesc.fPixvalDesc.fDepth = biBitCount; - sourceRasterDesc.fPixvalDesc.fBigEndian = true; - sourceRasterDesc.fRowBytes = ((biWidth * biBitCount + 31) / 32) * 4; - sourceRasterDesc.fRowCount = biHeight; - sourceRasterDesc.fFlipped = false; - - ZDCPixmapNS::PixelDesc sourcePixelDesc(&localColorVector[0], localColorVector.size()); - - ZDCPixmap thePixmap(sourceRasterDesc, ZPoint(biWidth, biHeight), sourcePixelDesc); - - if (biCompression == BI_RLE8) - { - thePixmap.GetRaster()->Fill(0); - bool destFlipped = (thePixmap.GetRasterDesc().fFlipped); - sReadRLE8(theStream, biWidth, biHeight, - sourceRasterDesc.fRowBytes, sourceFlipped != destFlipped, - reinterpret_cast<uint8*>(thePixmap.GetRaster()->GetBaseAddress())); - } - else - { - ZAssertStop(2, biCompression == BI_RLE4); - thePixmap.GetRaster()->Fill(0); - bool destFlipped = (thePixmap.GetRasterDesc().fFlipped); - sReadRLE4(theStream, biWidth, biHeight, - sourceRasterDesc.fRowBytes, destFlipped, - reinterpret_cast<uint8*>(thePixmap.GetRaster()->GetBaseAddress())); - } - return thePixmap; - } - } - -static void sReadRLE8(const ZStreamR& iStream, - ZCoord iWidth, ZCoord iHeight, size_t iRowBytes, bool iFlip, uint8* iBuffer) - { - ZCoord currentRow = 0; - ZCoord currentCol = 0; - bool done = false; - while (!done) - { - uint8 count = iStream.ReadUInt8(); - uint8 command = iStream.ReadUInt8(); - if (count == 0) - { - switch (command) - { - case 0: // Move to start of next row - { - currentRow += 1; - currentCol = 0; - break; - } - case 1: // All done - { - done = true; - break; - } - case 2: // Offset by some relative amount - { - currentCol += iStream.ReadUInt8(); - currentRow += iStream.ReadUInt8(); - break; - } - default: // Absolute data follows -- the length is the value of 'command' - { - uint8* destAddress = iBuffer - + iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow) - + currentCol; - - iStream.Read(destAddress, command); - currentCol += command; - // An odd number of bytes is followed by a pad byte. - if ((command & 1) != 0) - iStream.Skip(1); - break; - } - } - } - else - { - // Store a run of bytes. The count is in 'count', the value is in 'command'. - uint8* destAddress = iBuffer - + iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow) + currentCol; - - for (int x = 0; x < count; ++x) - *destAddress++ = command; - currentCol += count; - } - } - } - -static void sReadRLE4(const ZStreamR& iStream, - ZCoord iWidth, ZCoord iHeight, size_t iRowBytes, bool iFlip, uint8* iBuffer) - { - ZCoord currentRow = 0; - ZCoord currentCol = 0; - bool done = false; - while (!done) - { - uint8 count = iStream.ReadUInt8(); - uint8 command = iStream.ReadUInt8(); - if (count == 0) - { - switch (command) - { - case 0: // Move to start of next row - { - currentRow += 1; - currentCol = 0; - break; - } - case 1: // All done - { - done = true; - break; - } - case 2: // Offset by some relative amount - { - currentCol += iStream.ReadUInt8(); - currentRow += iStream.ReadUInt8(); - break; - } - default: // Absolute data follows -- the length is the value of 'command' - { - uint8* rowStart = iBuffer - + iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow); - - uint8 hi, lo; - for (int i = 0; i < command; ++i) - { - if ((i & 1) == 0) - { - uint8 data = iStream.ReadUInt8(); - hi = data >> 4; - lo = data & 0x0f; - } - if ((currentCol & 1) == 0) - { - if ((i & 1) == 0) - rowStart[currentCol / 2] = hi << 4; - else - rowStart[currentCol / 2] = lo << 4; - } - else - { - if ((i & 1) == 0) - rowStart[currentCol / 2] |= hi; - else - rowStart[currentCol / 2] |= lo; - } - ++currentCol; - } - switch (command & 0x03) - { - case 1: case 2: - iStream.Skip(1); - break; - } - break; - } - } - } - else - { - // Store a run of nibbles. The count is in 'count', - // the values are packed into 'command'. - uint8* rowStart = iBuffer - + iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow); - - uint8 hi = command >> 4; - uint8 lo = command & 0x0F; - for (int i = 0; i < count; ++i) - { - if ((currentCol & 1) == 0) - { - if ((i & 1) == 0) - rowStart[currentCol / 2] = hi << 4; - else - rowStart[currentCol / 2] = lo << 4; - } - else - { - if ((i & 1) == 0) - rowStart[currentCol / 2] |= hi; - else - rowStart[currentCol / 2] |= lo; - } - ++currentCol; - } - } - } - } - -NAMESPACE_ZOOLIB_END Deleted: trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.h 2009-07-19 17:34:21 UTC (rev 855) +++ trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.h 2009-07-19 17:40:57 UTC (rev 856) @@ -1,38 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2002 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZDCPixmap_Asset_BMP__ -#define __ZDCPixmap_Asset_BMP__ 1 -#include "zconfig.h" - -NAMESPACE_ZOOLIB_BEGIN - -class ZAsset; -class ZDCPixmap; - -namespace ZDCPixmap_Asset_BMP { - -ZDCPixmap sGetPixmap(const ZAsset& iAsset); - -} // namespace ZDCPixmap_Asset_BMP - -NAMESPACE_ZOOLIB_END - -#endif // __ZDCPixmap_Asset_BMP__ Copied: trunk/zoolib/source/cxx_old/zoolib/ZDCPixmap_Asset_BMP.cpp (from rev 588, trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.cpp) =================================================================== --- trunk/zoolib/source/cxx_old/zoolib/ZDCPixmap_Asset_BMP.cpp (rev 0) +++ trunk/zoolib/source/cxx_old/zoolib/ZDCPixmap_Asset_BMP.cpp 2009-07-19 17:40:57 UTC (rev 856) @@ -0,0 +1,417 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2002 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZDCPixmap_Asset_BMP.h" +#include "zoolib/ZAsset.h" +#include "zoolib/ZDCPixmap.h" + +using std::runtime_error; +using std::vector; + +NAMESPACE_ZOOLIB_BEGIN + +// From wingdi.h +#ifndef BI_RGB +# define BI_RGB 0L +# define BI_RLE8 1L +# define BI_RLE4 2L +# define BI_BITFIELDS 3L +#endif + +// ================================================================================================= +#pragma mark - +#pragma mark * PixmapRaster_Asset + +namespace ZANONYMOUS { + +class PixmapRaster_Asset : public ZDCPixmapRaster + { +public: + PixmapRaster_Asset(const ZAsset& iAsset, + const void* iBaseAddress, const ZDCPixmapNS::RasterDesc& iRasterDesc); + virtual ~PixmapRaster_Asset(); + +private: + ZAsset fAsset; + }; + +PixmapRaster_Asset::PixmapRaster_Asset(const ZAsset& iAsset, + const void* iBaseAddress, const ZDCPixmapNS::RasterDesc& iRasterDesc) +: ZDCPixmapRaster(iRasterDesc), + fAsset(iAsset) + { + fBaseAddress = const_cast<void*>(iBaseAddress); + } + +PixmapRaster_Asset::~PixmapRaster_Asset() + { + fBaseAddress = nullptr; + } + +} // anonymous namespace + +// ================================================================================================= +#pragma mark - +#pragma mark * ZDCPixmap_Asset_BMP::sGetPixmap + +static void sReadRLE8(const ZStreamR& iStream, + ZCoord iWidth, ZCoord iHeight, size_t iRowBytes, bool iFlip, uint8* iBuffer); + +static void sReadRLE4(const ZStreamR& iStream, + ZCoord iWidth, ZCoord iHeight, size_t iRowBytes, bool iFlip, uint8* iBuffer); + +ZDCPixmap ZDCPixmap_Asset_BMP::sGetPixmap(const ZAsset& iAsset) + { + if (!iAsset) + return ZDCPixmap(); + + // Get the data loaded before we call OpenRPos -- if the asset is file-based + // then it will create a memory based streamer if the data is already loaded. + + const void* theData; + size_t theSize; + iAsset.GetData(&theData, & theSize); + + ZRef<ZStreamerRPos> theStreamer = iAsset.OpenRPos(); + if (!theStreamer) + return ZDCPixmap(); + + const ZStreamRPos& theStream = theStreamer->GetStreamRPos(); + + // Parse the header + uint16 bfType = theStream.ReadUInt16LE(); + if (bfType != 0x4D42) + throw runtime_error("ZDCPixmap_Asset_BMP::sGetPixmap, invalid BMP file"); + + // Ignore bfSize, bfReserved1 and bfReserved2. + theStream.Skip(8); + + size_t bfOffBits = theStream.ReadUInt32LE() - 54; + + uint32 biSize = theStream.ReadUInt32LE(); + if (biSize != 0x28) + throw runtime_error("ZDCPixmap_Asset_BMP::sGetPixmap, invalid BMP file"); + + int32 biWidth = theStream.ReadUInt32LE(); + int32 biHeight = theStream.ReadUInt32LE(); + + uint16 biPlanes = theStream.ReadUInt16LE(); + // We only handle single planes + ZAssertStop(0, biPlanes == 1); + + uint16 biBitCount = theStream.ReadUInt16LE(); + uint32 biCompression = theStream.ReadUInt32LE(); + + // Ignore biSizeImage, biXPelsPerMeter and biYPelsPerMeter. + theStream.Skip(12); + + uint32 biClrUsed = theStream.ReadUInt32LE(); + /*uint32 biClrImportant =*/ theStream.ReadUInt32LE(); + + bool sourceFlipped = true; + if (biHeight < 0) + { + sourceFlipped = false; + biHeight = -biHeight; + } + + if (biClrUsed == 0) + { + if (biBitCount <= 8) + biClrUsed = 1 << biBitCount; + } + + // Read in the color table, if any + vector<ZRGBColorPOD> localColorVector; + if (biClrUsed > 0) + { + localColorVector.resize(biClrUsed); + + const uint8* theColors = static_cast<const uint8*>(theData) + theStream.GetPosition(); + theStream.Skip(biClrUsed * 4); + + for (size_t x = 0; x < biClrUsed; ++x) + { + ZRGBColorPOD& theColor = localColorVector[x]; + theColor.blue = (*theColors++) * 0x101; + theColor.green = (*theColors++) * 0x101; + theColor.red = (*theColors++) * 0x101; + ++theColors; // Ignore rgbReserved + theColor.alpha = 0xFFFFU; + } + } + + // If we're coming from a BMP file bfOffBits (the munged version) will be non zero, + // and might tell us that the pixels are actually at some different offset than + // immediately after the color table + if (bfOffBits) + theStream.Skip(bfOffBits - (biClrUsed * 4)); + + if (biCompression == BI_RGB) + { + // Uncompressed pixel data can be used as is -- we just have to set up an + // appropriate RasterDesc and PixelDesc, and pass a PixmapRaster_Asset to + // ZDCPixmap's constructor. When the raster is no longer in use by the pixmap + // (or anyone else) the ZAsset's destructor will be called and the underlying + // asset rep will be one step closer to being released. + + ZDCPixmapNS::RasterDesc theRasterDesc; + theRasterDesc.fPixvalDesc.fDepth = biBitCount; + theRasterDesc.fPixvalDesc.fBigEndian = true; + theRasterDesc.fRowBytes = ((biWidth * biBitCount + 31) / 32) * 4; + theRasterDesc.fRowCount = biHeight; + theRasterDesc.fFlipped = sourceFlipped; + + ZDCPixmapNS::PixelDesc thePixelDesc; + switch (biBitCount) + { + case 1: + case 4: + case 8: + { + thePixelDesc + = ZDCPixmapNS::PixelDesc(&localColorVector[0], localColorVector.size()); + break; + } + case 16: + { + thePixelDesc = ZDCPixmapNS::PixelDesc(0x7C00, 0x03E0, 0x001F, 0); + theRasterDesc.fPixvalDesc.fBigEndian = false; + break; + } + case 24: + { + thePixelDesc + = ZDCPixmapNS::PixelDesc(0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000); + break; + } + case 32: + { + thePixelDesc + = ZDCPixmapNS::PixelDesc(0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000); + break; + } + } + + ZRef<ZDCPixmapRaster> theRaster = new PixmapRaster_Asset(iAsset, + static_cast<const char*>(theData) + theStream.GetPosition(), theRasterDesc); + + return ZDCPixmap(new ZDCPixmapRep(theRaster, ZRect(biWidth, biHeight), thePixelDesc)); + } + else + { + // We've got RLE data and so can't use the pixel data as is -- it has + // to be expanded into a real raster. + ZAssertStop(2, biBitCount == 1 || biBitCount == 4 || biBitCount == 8); + + ZDCPixmapNS::RasterDesc sourceRasterDesc; + sourceRasterDesc.fPixvalDesc.fDepth = biBitCount; + sourceRasterDesc.fPixvalDesc.fBigEndian = true; + sourceRasterDesc.fRowBytes = ((biWidth * biBitCount + 31) / 32) * 4; + sourceRasterDesc.fRowCount = biHeight; + sourceRasterDesc.fFlipped = false; + + ZDCPixmapNS::PixelDesc sourcePixelDesc(&localColorVector[0], localColorVector.size()); + + ZDCPixmap thePixmap(sourceRasterDesc, ZPoint(biWidth, biHeight), sourcePixelDesc); + + if (biCompression == BI_RLE8) + { + thePixmap.GetRaster()->Fill(0); + bool destFlipped = (thePixmap.GetRasterDesc().fFlipped); + sReadRLE8(theStream, biWidth, biHeight, + sourceRasterDesc.fRowBytes, sourceFlipped != destFlipped, + reinterpret_cast<uint8*>(thePixmap.GetRaster()->GetBaseAddress())); + } + else + { + ZAssertStop(2, biCompression == BI_RLE4); + thePixmap.GetRaster()->Fill(0); + bool destFlipped = (thePixmap.GetRasterDesc().fFlipped); + sReadRLE4(theStream, biWidth, biHeight, + sourceRasterDesc.fRowBytes, destFlipped, + reinterpret_cast<uint8*>(thePixmap.GetRaster()->GetBaseAddress())); + } + return thePixmap; + } + } + +static void sReadRLE8(const ZStreamR& iStream, + ZCoord iWidth, ZCoord iHeight, size_t iRowBytes, bool iFlip, uint8* iBuffer) + { + ZCoord currentRow = 0; + ZCoord currentCol = 0; + bool done = false; + while (!done) + { + uint8 count = iStream.ReadUInt8(); + uint8 command = iStream.ReadUInt8(); + if (count == 0) + { + switch (command) + { + case 0: // Move to start of next row + { + currentRow += 1; + currentCol = 0; + break; + } + case 1: // All done + { + done = true; + break; + } + case 2: // Offset by some relative amount + { + currentCol += iStream.ReadUInt8(); + currentRow += iStream.ReadUInt8(); + break; + } + default: // Absolute data follows -- the length is the value of 'command' + { + uint8* destAddress = iBuffer + + iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow) + + currentCol; + + iStream.Read(destAddress, command); + currentCol += command; + // An odd number of bytes is followed by a pad byte. + if ((command & 1) != 0) + iStream.Skip(1); + break; + } + } + } + else + { + // Store a run of bytes. The count is in 'count', the value is in 'command'. + uint8* destAddress = iBuffer + + iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow) + currentCol; + + for (int x = 0; x < count; ++x) + *destAddress++ = command; + currentCol += count; + } + } + } + +static void sReadRLE4(const ZStreamR& iStream, + ZCoord iWidth, ZCoord iHeight, size_t iRowBytes, bool iFlip, uint8* iBuffer) + { + ZCoord currentRow = 0; + ZCoord currentCol = 0; + bool done = false; + while (!done) + { + uint8 count = iStream.ReadUInt8(); + uint8 command = iStream.ReadUInt8(); + if (count == 0) + { + switch (command) + { + case 0: // Move to start of next row + { + currentRow += 1; + currentCol = 0; + break; + } + case 1: // All done + { + done = true; + break; + } + case 2: // Offset by some relative amount + { + currentCol += iStream.ReadUInt8(); + currentRow += iStream.ReadUInt8(); + break; + } + default: // Absolute data follows -- the length is the value of 'command' + { + uint8* rowStart = iBuffer + + iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow); + + uint8 hi, lo; + for (int i = 0; i < command; ++i) + { + if ((i & 1) == 0) + { + uint8 data = iStream.ReadUInt8(); + hi = data >> 4; + lo = data & 0x0f; + } + if ((currentCol & 1) == 0) + { + if ((i & 1) == 0) + rowStart[currentCol / 2] = hi << 4; + else + rowStart[currentCol / 2] = lo << 4; + } + else + { + if ((i & 1) == 0) + rowStart[currentCol / 2] |= hi; + else + rowStart[currentCol / 2] |= lo; + } + ++currentCol; + } + switch (command & 0x03) + { + case 1: case 2: + iStream.Skip(1); + break; + } + break; + } + } + } + else + { + // Store a run of nibbles. The count is in 'count', + // the values are packed into 'command'. + uint8* rowStart = iBuffer + + iRowBytes * (iFlip ? iHeight - currentRow - 1 : currentRow); + + uint8 hi = command >> 4; + uint8 lo = command & 0x0F; + for (int i = 0; i < count; ++i) + { + if ((currentCol & 1) == 0) + { + if ((i & 1) == 0) + rowStart[currentCol / 2] = hi << 4; + else + rowStart[currentCol / 2] = lo << 4; + } + else + { + if ((i & 1) == 0) + rowStart[currentCol / 2] |= hi; + else + rowStart[currentCol / 2] |= lo; + } + ++currentCol; + } + } + } + } + +NAMESPACE_ZOOLIB_END Copied: trunk/zoolib/source/cxx_old/zoolib/ZDCPixmap_Asset_BMP.h (from rev 547, trunk/zoolib/source/cxx/zoolib/ZDCPixmap_Asset_BMP.h) =================================================================== --- trunk/zoolib/source/cxx_old/zoolib/ZDCPixmap_Asset_BMP.h (rev 0) +++ trunk/zoolib/source/cxx_old/zoolib/ZDCPixmap_Asset_BMP.h 2009-07-19 17:40:57 UTC (rev 856) @@ -0,0 +1,38 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2002 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZDCPixmap_Asset_BMP__ +#define __ZDCPixmap_Asset_BMP__ 1 +#include "zconfig.h" + +NAMESPACE_ZOOLIB_BEGIN + +class ZAsset; +class ZDCPixmap; + +namespace ZDCPixmap_Asset_BMP { + +ZDCPixmap sGetPixmap(const ZAsset& iAsset); + +} // namespace ZDCPixmap_Asset_BMP + +NAMESPACE_ZOOLIB_END + +#endif // __ZDCPixmap_Asset_BMP__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2009-07-19 17:42:56
|
Revision: 857 http://zoolib.svn.sourceforge.net/zoolib/?rev=857&view=rev Author: agreen Date: 2009-07-19 17:42:52 +0000 (Sun, 19 Jul 2009) Log Message: ----------- Move to cxx_old. Added Paths: ----------- trunk/zoolib/source/cxx_old/zoolib/ZTS_Umbrella.cpp trunk/zoolib/source/cxx_old/zoolib/ZTS_Umbrella.h Removed Paths: ------------- trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.cpp trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.h Deleted: trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.cpp 2009-07-19 17:40:57 UTC (rev 856) +++ trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.cpp 2009-07-19 17:42:52 UTC (rev 857) @@ -1,266 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2005 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#include "zoolib/ZTS_Umbrella.h" - -#include "zoolib/ZDebug.h" - -NAMESPACE_ZOOLIB_BEGIN - -using std::map; -using std::pair; -using std::set; -using std::vector; - -#define kDebug_TS_Umbrella 0 - -// ================================================================================================= -#pragma mark - -#pragma mark * ZTS_Umbrella - -ZTS_Umbrella::ZTS_Umbrella(const vector<ZRef<ZTS> >& iTSes) - { - for (vector<ZRef<ZTS> >::const_iterator i = iTSes.begin(), theEnd = iTSes.end(); - i != theEnd; ++i) - { - Child theChild; - theChild.fTS = *i; - fChildren.push_back(theChild); - fReadComposite.Add((*i)->GetReadLock()); - } - } - -ZTS_Umbrella::~ZTS_Umbrella() - {} - -void ZTS_Umbrella::AllocateIDs(size_t iCount, uint64& oBaseID, size_t& oCount) - { fChildren.front().fTS->AllocateIDs(iCount, oBaseID, oCount); } - -void ZTS_Umbrella::SetTuples(size_t iCount, const uint64* iIDs, const ZTuple* iTuples) - { - while (--iCount) - { - uint64 theGlobalID = *iIDs++; - GlobalToLocal_t::iterator i = fGlobalToLocal.find(theGlobalID); - if (i != fGlobalToLocal.end()) - { - size_t theChildIndex = (*i).second.first; - uint64 theLocalID = (*i).second.second; - ZTuple temp = *iTuples; - this->pTranslate_GlobalToLocal(theChildIndex, temp); - fChildren[theChildIndex].fTS->SetTuples(1, &theLocalID, &temp); - } - else - { - // It's in the prime TS, and thus its ID and contents are not translated. - fChildren.front().fTS->SetTuples(1, &theGlobalID, iTuples); - } - ++iTuples; - } - // Any changes - fChildren.front().fTS->SetTuples(iCount, iIDs, iTuples); - } - -void ZTS_Umbrella::GetTuples(size_t iCount, const uint64* iIDs, ZTuple* oTuples) - { - // A real implementation would walk iIDs and determine which TS owns each ID, - // then push the fetch off to a pre-running thread that synchronously - // calls the appropriate TS, and possibly lock only those TSes. Alternatively - // we would make the TS API asynchronous. - while (--iCount) - { - uint64 theGlobalID = *iIDs++; - GlobalToLocal_t::iterator i = fGlobalToLocal.find(theGlobalID); - if (i != fGlobalToLocal.end()) - { - size_t theChildIndex = (*i).second.first; - uint64 theLocalID = (*i).second.second; - fChildren[theChildIndex].fTS->GetTuples(1, &theLocalID, oTuples); - this->pTranslate_LocalToGlobal(theChildIndex, *oTuples); - } - else - { - // It's in the prime TS, and thus its ID and contents are not translated. - fChildren.front().fTS->GetTuples(1, &theGlobalID, oTuples); - } - ++oTuples; - } - } - -void ZTS_Umbrella::Search(const ZTBSpec& iSpec, const set<uint64>& iSkipIDs, set<uint64>& ioIDs) - { - vector<Child>::iterator i = fChildren.begin(); - (*i).fTS->Search(iSpec, iSkipIDs, ioIDs); - - vector<set<uint64> > skipIDs(fChildren.size()); - - for (set<uint64>::const_iterator i = iSkipIDs.begin(), theEnd = iSkipIDs.end(); - i != theEnd; ++i) - { - GlobalToLocal_t::iterator j = fGlobalToLocal.find(*i); - if (j != fGlobalToLocal.end()) - { - size_t theChildIndex = (*j).second.first; - ZAssertStop(kDebug_TS_Umbrella, theChildIndex < fChildren.size()); - skipIDs[theChildIndex].insert((*j).second.second); - } - } - - for (size_t theChildIndex = 1; theChildIndex < fChildren.size(); ++theChildIndex) - { - set<uint64> results; - fChildren[theChildIndex].fTS->Search(iSpec, skipIDs[theChildIndex], results); - - for (set<uint64>::iterator i = results.begin(), theEnd = results.end(); - i != theEnd; ++i) - { - uint64 globalID = this->pLocalToGlobal(theChildIndex, *i); - ioIDs.insert(globalID); - } - } - } - -ZMutexBase& ZTS_Umbrella::GetReadLock() - { return fReadComposite; } - -ZMutexBase& ZTS_Umbrella::GetWriteLock() - { return fChildren.front().fTS->GetWriteLock(); } - -uint64 ZTS_Umbrella::pAllocateID() - { return this->pAllocateID(fChildren.front().fTS); } - -uint64 ZTS_Umbrella::pAllocateID(ZRef<ZTS> iTS) - { - for (;;) - { - uint64 theID; - size_t countIssued; - iTS->AllocateIDs(1, theID, countIssued); - if (countIssued) - return theID; - } - } - -void ZTS_Umbrella::pTranslate_GlobalToLocal(size_t iChildIndex, ZValMap_ZooLib& ioTuple) - { - for (ZTuple::const_iterator i = ioTuple.begin(), theEnd = ioTuple.end(); - i != theEnd; ++i) - { - switch (ioTuple.RGet(i).TypeOf()) - { - case eZType_ID: - { - uint64 localID = this->pGlobalToLocal(iChildIndex, ioTuple.Get(i).GetID()); - ioTuple.Set(i, localID); - break; - } - case eZType_Tuple: - { - this->pTranslate_GlobalToLocal(iChildIndex, ioTuple.Mutable(i).MutableMap()); - break; - } - case eZType_Vector: - { - vector<ZTValue>& theVector = ioTuple.Mutable(i).MutableList().MutableVector(); - for (vector<ZTValue>::iterator j = theVector.begin(); j != theVector.end(); ++j) - { - if (eZType_ID == (*j).TypeOf()) - { - uint64 localID = this->pGlobalToLocal(iChildIndex, ioTuple.Get(i).GetID()); - (*j).SetID(localID); - } - } - } - } - } - } - -void ZTS_Umbrella::pTranslate_LocalToGlobal(size_t iChildIndex, ZValMap_ZooLib& ioTuple) - { - for (ZTuple::const_iterator i = ioTuple.begin(), theEnd = ioTuple.end(); - i != theEnd; ++i) - { - switch (ioTuple.RGet(i).TypeOf()) - { - case eZType_ID: - { - uint64 globalID = this->pLocalToGlobal(iChildIndex, ioTuple.Get(i).GetID()); - ioTuple.Set(i, globalID); - break; - } - case eZType_Tuple: - { - this->pTranslate_LocalToGlobal(iChildIndex, ioTuple.Mutable(i).MutableMap()); - break; - } - case eZType_Vector: - { - vector<ZTValue>& theVector = ioTuple.Mutable(i).MutableList().MutableVector(); - for (vector<ZTValue>::iterator j = theVector.begin(); j != theVector.end(); ++j) - { - if (eZType_ID == (*j).TypeOf()) - { - uint64 globalID = this->pLocalToGlobal(iChildIndex, ioTuple.Get(i).GetID()); - (*j).SetID(globalID); - } - } - } - } - } - } - -uint64 ZTS_Umbrella::pGlobalToLocal(size_t iChildIndex, uint64 iGlobalID) - { - Child& theChild = fChildren[iChildIndex]; - GlobalToLocal_t::iterator i = fGlobalToLocal.find(iGlobalID); - if (i != fGlobalToLocal.end()) - { - ZAssertStop(kDebug_TS_Umbrella, (*i).second.first == iChildIndex); - return (*i).second.second; - } - else - { - uint64 localID = this->pAllocateID(theChild.fTS); - theChild.fLocalToGlobal.insert(LocalToGlobal_t::value_type(localID, iGlobalID)); - fGlobalToLocal.insert(GlobalToLocal_t::value_type(iGlobalID, pair<size_t, uint64>(iChildIndex, localID))); - return localID; - } - } - -uint64 ZTS_Umbrella::pLocalToGlobal(size_t iChildIndex, uint64 iLocalID) - { - Child& theChild = fChildren[iChildIndex]; - LocalToGlobal_t::iterator i = theChild.fLocalToGlobal.find(iLocalID); - if (i != theChild.fLocalToGlobal.end()) - { - return (*i).second; - } - else - { - // No mapping found, create one. - uint64 globalID = this->pAllocateID(); - theChild.fLocalToGlobal.insert(LocalToGlobal_t::value_type(iLocalID, globalID)); - fGlobalToLocal.insert(GlobalToLocal_t::value_type(globalID, pair<size_t, uint64>(iChildIndex, iLocalID))); - return globalID; - } - } - -NAMESPACE_ZOOLIB_END - Deleted: trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.h 2009-07-19 17:40:57 UTC (rev 856) +++ trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.h 2009-07-19 17:42:52 UTC (rev 857) @@ -1,76 +0,0 @@ -/* ------------------------------------------------------------------------------------------------- -Copyright (c) 2005 Andrew Green and Learning in Motion, Inc. -http://www.zoolib.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------------------- */ - -#ifndef __ZTS_Umbrella__ -#define __ZTS_Umbrella__ -#include "zconfig.h" - -#include "zoolib/ZTS.h" - -#include "zoolib/ZMutexComposite.h" - -#include <map> - -NAMESPACE_ZOOLIB_BEGIN - -// ================================================================================================= -#pragma mark - -#pragma mark * ZTS_Umbrella - -class ZTS_Umbrella : public ZTS - { -public: - ZTS_Umbrella(const std::vector<ZRef<ZTS> >& iTSes); - virtual ~ZTS_Umbrella(); - - virtual void AllocateIDs(size_t iCount, uint64& oBaseID, size_t& oCount); - virtual void SetTuples(size_t iCount, const uint64* iIDs, const ZTuple* iTuples); - virtual void GetTuples(size_t iCount, const uint64* iIDs, ZTuple* oTuples); - virtual void Search(const ZTBSpec& iSpec, const std::set<uint64>& iSkipIDs, std::set<uint64>& ioIDs); - virtual ZMutexBase& GetReadLock(); - virtual ZMutexBase& GetWriteLock(); - -private: - typedef std::map<uint64, std::pair<size_t, uint64> > GlobalToLocal_t; - typedef std::map<uint64, uint64> LocalToGlobal_t; - class Child - { - public: - ZRef<ZTS> fTS; - LocalToGlobal_t fLocalToGlobal; - }; - - uint64 pAllocateID(); - uint64 pAllocateID(ZRef<ZTS> iTS); - - void pTranslate_GlobalToLocal(size_t iChildIndex, ZValMap_ZooLib& ioTuple); - void pTranslate_LocalToGlobal(size_t iChildIndex, ZValMap_ZooLib& ioTuple); - - uint64 pGlobalToLocal(size_t iChildIndex, uint64 iGlobalID); - uint64 pLocalToGlobal(size_t iChildIndex, uint64 iLocalID); - - std::vector<Child> fChildren; - GlobalToLocal_t fGlobalToLocal; - ZMutexComposite fReadComposite; - }; - -NAMESPACE_ZOOLIB_END - -#endif // __ZTS_Umbrella__ Copied: trunk/zoolib/source/cxx_old/zoolib/ZTS_Umbrella.cpp (from rev 790, trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.cpp) =================================================================== --- trunk/zoolib/source/cxx_old/zoolib/ZTS_Umbrella.cpp (rev 0) +++ trunk/zoolib/source/cxx_old/zoolib/ZTS_Umbrella.cpp 2009-07-19 17:42:52 UTC (rev 857) @@ -0,0 +1,266 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2005 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZTS_Umbrella.h" + +#include "zoolib/ZDebug.h" + +NAMESPACE_ZOOLIB_BEGIN + +using std::map; +using std::pair; +using std::set; +using std::vector; + +#define kDebug_TS_Umbrella 0 + +// ================================================================================================= +#pragma mark - +#pragma mark * ZTS_Umbrella + +ZTS_Umbrella::ZTS_Umbrella(const vector<ZRef<ZTS> >& iTSes) + { + for (vector<ZRef<ZTS> >::const_iterator i = iTSes.begin(), theEnd = iTSes.end(); + i != theEnd; ++i) + { + Child theChild; + theChild.fTS = *i; + fChildren.push_back(theChild); + fReadComposite.Add((*i)->GetReadLock()); + } + } + +ZTS_Umbrella::~ZTS_Umbrella() + {} + +void ZTS_Umbrella::AllocateIDs(size_t iCount, uint64& oBaseID, size_t& oCount) + { fChildren.front().fTS->AllocateIDs(iCount, oBaseID, oCount); } + +void ZTS_Umbrella::SetTuples(size_t iCount, const uint64* iIDs, const ZTuple* iTuples) + { + while (--iCount) + { + uint64 theGlobalID = *iIDs++; + GlobalToLocal_t::iterator i = fGlobalToLocal.find(theGlobalID); + if (i != fGlobalToLocal.end()) + { + size_t theChildIndex = (*i).second.first; + uint64 theLocalID = (*i).second.second; + ZTuple temp = *iTuples; + this->pTranslate_GlobalToLocal(theChildIndex, temp); + fChildren[theChildIndex].fTS->SetTuples(1, &theLocalID, &temp); + } + else + { + // It's in the prime TS, and thus its ID and contents are not translated. + fChildren.front().fTS->SetTuples(1, &theGlobalID, iTuples); + } + ++iTuples; + } + // Any changes + fChildren.front().fTS->SetTuples(iCount, iIDs, iTuples); + } + +void ZTS_Umbrella::GetTuples(size_t iCount, const uint64* iIDs, ZTuple* oTuples) + { + // A real implementation would walk iIDs and determine which TS owns each ID, + // then push the fetch off to a pre-running thread that synchronously + // calls the appropriate TS, and possibly lock only those TSes. Alternatively + // we would make the TS API asynchronous. + while (--iCount) + { + uint64 theGlobalID = *iIDs++; + GlobalToLocal_t::iterator i = fGlobalToLocal.find(theGlobalID); + if (i != fGlobalToLocal.end()) + { + size_t theChildIndex = (*i).second.first; + uint64 theLocalID = (*i).second.second; + fChildren[theChildIndex].fTS->GetTuples(1, &theLocalID, oTuples); + this->pTranslate_LocalToGlobal(theChildIndex, *oTuples); + } + else + { + // It's in the prime TS, and thus its ID and contents are not translated. + fChildren.front().fTS->GetTuples(1, &theGlobalID, oTuples); + } + ++oTuples; + } + } + +void ZTS_Umbrella::Search(const ZTBSpec& iSpec, const set<uint64>& iSkipIDs, set<uint64>& ioIDs) + { + vector<Child>::iterator i = fChildren.begin(); + (*i).fTS->Search(iSpec, iSkipIDs, ioIDs); + + vector<set<uint64> > skipIDs(fChildren.size()); + + for (set<uint64>::const_iterator i = iSkipIDs.begin(), theEnd = iSkipIDs.end(); + i != theEnd; ++i) + { + GlobalToLocal_t::iterator j = fGlobalToLocal.find(*i); + if (j != fGlobalToLocal.end()) + { + size_t theChildIndex = (*j).second.first; + ZAssertStop(kDebug_TS_Umbrella, theChildIndex < fChildren.size()); + skipIDs[theChildIndex].insert((*j).second.second); + } + } + + for (size_t theChildIndex = 1; theChildIndex < fChildren.size(); ++theChildIndex) + { + set<uint64> results; + fChildren[theChildIndex].fTS->Search(iSpec, skipIDs[theChildIndex], results); + + for (set<uint64>::iterator i = results.begin(), theEnd = results.end(); + i != theEnd; ++i) + { + uint64 globalID = this->pLocalToGlobal(theChildIndex, *i); + ioIDs.insert(globalID); + } + } + } + +ZMutexBase& ZTS_Umbrella::GetReadLock() + { return fReadComposite; } + +ZMutexBase& ZTS_Umbrella::GetWriteLock() + { return fChildren.front().fTS->GetWriteLock(); } + +uint64 ZTS_Umbrella::pAllocateID() + { return this->pAllocateID(fChildren.front().fTS); } + +uint64 ZTS_Umbrella::pAllocateID(ZRef<ZTS> iTS) + { + for (;;) + { + uint64 theID; + size_t countIssued; + iTS->AllocateIDs(1, theID, countIssued); + if (countIssued) + return theID; + } + } + +void ZTS_Umbrella::pTranslate_GlobalToLocal(size_t iChildIndex, ZValMap_ZooLib& ioTuple) + { + for (ZTuple::const_iterator i = ioTuple.begin(), theEnd = ioTuple.end(); + i != theEnd; ++i) + { + switch (ioTuple.RGet(i).TypeOf()) + { + case eZType_ID: + { + uint64 localID = this->pGlobalToLocal(iChildIndex, ioTuple.Get(i).GetID()); + ioTuple.Set(i, localID); + break; + } + case eZType_Tuple: + { + this->pTranslate_GlobalToLocal(iChildIndex, ioTuple.Mutable(i).MutableMap()); + break; + } + case eZType_Vector: + { + vector<ZTValue>& theVector = ioTuple.Mutable(i).MutableList().MutableVector(); + for (vector<ZTValue>::iterator j = theVector.begin(); j != theVector.end(); ++j) + { + if (eZType_ID == (*j).TypeOf()) + { + uint64 localID = this->pGlobalToLocal(iChildIndex, ioTuple.Get(i).GetID()); + (*j).SetID(localID); + } + } + } + } + } + } + +void ZTS_Umbrella::pTranslate_LocalToGlobal(size_t iChildIndex, ZValMap_ZooLib& ioTuple) + { + for (ZTuple::const_iterator i = ioTuple.begin(), theEnd = ioTuple.end(); + i != theEnd; ++i) + { + switch (ioTuple.RGet(i).TypeOf()) + { + case eZType_ID: + { + uint64 globalID = this->pLocalToGlobal(iChildIndex, ioTuple.Get(i).GetID()); + ioTuple.Set(i, globalID); + break; + } + case eZType_Tuple: + { + this->pTranslate_LocalToGlobal(iChildIndex, ioTuple.Mutable(i).MutableMap()); + break; + } + case eZType_Vector: + { + vector<ZTValue>& theVector = ioTuple.Mutable(i).MutableList().MutableVector(); + for (vector<ZTValue>::iterator j = theVector.begin(); j != theVector.end(); ++j) + { + if (eZType_ID == (*j).TypeOf()) + { + uint64 globalID = this->pLocalToGlobal(iChildIndex, ioTuple.Get(i).GetID()); + (*j).SetID(globalID); + } + } + } + } + } + } + +uint64 ZTS_Umbrella::pGlobalToLocal(size_t iChildIndex, uint64 iGlobalID) + { + Child& theChild = fChildren[iChildIndex]; + GlobalToLocal_t::iterator i = fGlobalToLocal.find(iGlobalID); + if (i != fGlobalToLocal.end()) + { + ZAssertStop(kDebug_TS_Umbrella, (*i).second.first == iChildIndex); + return (*i).second.second; + } + else + { + uint64 localID = this->pAllocateID(theChild.fTS); + theChild.fLocalToGlobal.insert(LocalToGlobal_t::value_type(localID, iGlobalID)); + fGlobalToLocal.insert(GlobalToLocal_t::value_type(iGlobalID, pair<size_t, uint64>(iChildIndex, localID))); + return localID; + } + } + +uint64 ZTS_Umbrella::pLocalToGlobal(size_t iChildIndex, uint64 iLocalID) + { + Child& theChild = fChildren[iChildIndex]; + LocalToGlobal_t::iterator i = theChild.fLocalToGlobal.find(iLocalID); + if (i != theChild.fLocalToGlobal.end()) + { + return (*i).second; + } + else + { + // No mapping found, create one. + uint64 globalID = this->pAllocateID(); + theChild.fLocalToGlobal.insert(LocalToGlobal_t::value_type(iLocalID, globalID)); + fGlobalToLocal.insert(GlobalToLocal_t::value_type(globalID, pair<size_t, uint64>(iChildIndex, iLocalID))); + return globalID; + } + } + +NAMESPACE_ZOOLIB_END + Copied: trunk/zoolib/source/cxx_old/zoolib/ZTS_Umbrella.h (from rev 790, trunk/zoolib/source/cxx/zoolib/ZTS_Umbrella.h) =================================================================== --- trunk/zoolib/source/cxx_old/zoolib/ZTS_Umbrella.h (rev 0) +++ trunk/zoolib/source/cxx_old/zoolib/ZTS_Umbrella.h 2009-07-19 17:42:52 UTC (rev 857) @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2005 Andrew Green and Learning in Motion, Inc. +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZTS_Umbrella__ +#define __ZTS_Umbrella__ +#include "zconfig.h" + +#include "zoolib/ZTS.h" + +#include "zoolib/ZMutexComposite.h" + +#include <map> + +NAMESPACE_ZOOLIB_BEGIN + +// ================================================================================================= +#pragma mark - +#pragma mark * ZTS_Umbrella + +class ZTS_Umbrella : public ZTS + { +public: + ZTS_Umbrella(const std::vector<ZRef<ZTS> >& iTSes); + virtual ~ZTS_Umbrella(); + + virtual void AllocateIDs(size_t iCount, uint64& oBaseID, size_t& oCount); + virtual void SetTuples(size_t iCount, const uint64* iIDs, const ZTuple* iTuples); + virtual void GetTuples(size_t iCount, const uint64* iIDs, ZTuple* oTuples); + virtual void Search(const ZTBSpec& iSpec, const std::set<uint64>& iSkipIDs, std::set<uint64>& ioIDs); + virtual ZMutexBase& GetReadLock(); + virtual ZMutexBase& GetWriteLock(); + +private: + typedef std::map<uint64, std::pair<size_t, uint64> > GlobalToLocal_t; + typedef std::map<uint64, uint64> LocalToGlobal_t; + class Child + { + public: + ZRef<ZTS> fTS; + LocalToGlobal_t fLocalToGlobal; + }; + + uint64 pAllocateID(); + uint64 pAllocateID(ZRef<ZTS> iTS); + + void pTranslate_GlobalToLocal(size_t iChildIndex, ZValMap_ZooLib& ioTuple); + void pTranslate_LocalToGlobal(size_t iChildIndex, ZValMap_ZooLib& ioTuple); + + uint64 pGlobalToLocal(size_t iChildIndex, uint64 iGlobalID); + uint64 pLocalToGlobal(size_t iChildIndex, uint64 iLocalID); + + std::vector<Child> fChildren; + GlobalToLocal_t fGlobalToLocal; + ZMutexComposite fReadComposite; + }; + +NAMESPACE_ZOOLIB_END + +#endif // __ZTS_Umbrella__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |