Return-Path: Delivered-To: apmail-xml-xalan-cvs-archive@www.apache.org Received: (qmail 95826 invoked from network); 12 Aug 2004 21:37:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 12 Aug 2004 21:37:13 -0000 Received: (qmail 83610 invoked by uid 500); 12 Aug 2004 21:37:13 -0000 Delivered-To: apmail-xml-xalan-cvs-archive@xml.apache.org Received: (qmail 83573 invoked by uid 500); 12 Aug 2004 21:37:12 -0000 Mailing-List: contact xalan-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: Delivered-To: mailing list xalan-cvs@xml.apache.org Received: (qmail 83551 invoked by uid 99); 12 Aug 2004 21:37:12 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=ALL_TRUSTED,CASHCASHCASH,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Thu, 12 Aug 2004 14:37:11 -0700 Received: (qmail 95796 invoked by uid 1034); 12 Aug 2004 21:37:11 -0000 Date: 12 Aug 2004 21:37:11 -0000 Message-ID: <20040812213711.95795.qmail@minotaur.apache.org> From: dbertoni@apache.org To: xml-xalan-cvs@apache.org Subject: cvs commit: xml-xalan/c/src/xalanc/PlatformSupport XalanDOMStringReusableAllocator.cpp XalanDOMStringReusableAllocator.hpp X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N dbertoni 2004/08/12 14:37:11 Added: c/src/xalanc/PlatformSupport XalanDOMStringReusableAllocator.cpp XalanDOMStringReusableAllocator.hpp Log: Initial revision. Revision Changes Path 1.1 xml-xalan/c/src/xalanc/PlatformSupport/XalanDOMStringReusableAllocator.cpp Index: XalanDOMStringReusableAllocator.cpp =================================================================== /* * Copyright 1999-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Class header file. #include "XalanDOMStringReusableAllocator.hpp" XALAN_CPP_NAMESPACE_BEGIN XalanDOMStringReusableAllocator::XalanDOMStringReusableAllocator(size_type theBlockCount) : m_allocator(theBlockCount) { } XalanDOMStringReusableAllocator::~XalanDOMStringReusableAllocator() { } XalanDOMStringReusableAllocator::data_type& XalanDOMStringReusableAllocator::create() { data_type* const theBlock = m_allocator.allocateBlock(); assert(theBlock != 0); data_type* const theResult = new(theBlock) data_type; m_allocator.commitAllocation(theBlock); return *theResult; } XalanDOMStringReusableAllocator::data_type& XalanDOMStringReusableAllocator::create( const char* theString, data_type_size_type theCount) { data_type* const theBlock = m_allocator.allocateBlock(); assert(theBlock != 0); data_type* const theResult = new(theBlock) data_type(theString, theCount); m_allocator.commitAllocation(theBlock); return *theResult; } XalanDOMStringReusableAllocator::data_type& XalanDOMStringReusableAllocator::create( const data_type& theSource, data_type_size_type theStartPosition, data_type_size_type theCount) { data_type* const theBlock = m_allocator.allocateBlock(); assert(theBlock != 0); data_type* const theResult = new(theBlock) data_type(theSource, theStartPosition, theCount); m_allocator.commitAllocation(theBlock); return *theResult; } XalanDOMStringReusableAllocator::data_type& XalanDOMStringReusableAllocator::create( const XalanDOMChar* theString, data_type_size_type theCount) { data_type* const theBlock = m_allocator.allocateBlock(); assert(theBlock != 0); data_type* const theResult = new(theBlock) data_type(theString, theCount); m_allocator.commitAllocation(theBlock); return *theResult; } XalanDOMStringReusableAllocator::data_type& XalanDOMStringReusableAllocator::create( data_type_size_type theCount, XalanDOMChar theChar) { data_type* const theBlock = m_allocator.allocateBlock(); assert(theBlock != 0); data_type* const theResult = new(theBlock) data_type(theCount, theChar); m_allocator.commitAllocation(theBlock); return *theResult; } XALAN_CPP_NAMESPACE_END 1.1 xml-xalan/c/src/xalanc/PlatformSupport/XalanDOMStringReusableAllocator.hpp Index: XalanDOMStringReusableAllocator.hpp =================================================================== /* * Copyright 1999-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if !defined(XALANDOMSTRINGREUSABLEALLOCATOR_INCLUDE_GUARD_12455133) #define XALANDOMSTRINGREUSABLEALLOCATOR_INCLUDE_GUARD_12455133 // Base include file. Must be first. #include #include #include XALAN_CPP_NAMESPACE_BEGIN class XALAN_PLATFORMSUPPORT_EXPORT XalanDOMStringReusableAllocator { public: typedef XalanDOMString data_type; typedef data_type::size_type data_type_size_type; #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS) typedef ReusableArenaBlock ArenaBlockType; typedef ReusableArenaBlock ArenaAllocatorType; #else typedef ReusableArenaAllocator ArenaAllocatorType; #endif typedef ArenaAllocatorType::size_type size_type; enum { eDefaultBlockSize = 32 }; /** * Construct an instance that will allocate in blocks of the specified size. * * @param theBlockSize The block size. */ XalanDOMStringReusableAllocator(size_type theBlockCount); ~XalanDOMStringReusableAllocator(); /** * Create a XalanDOMString object. * * @return reference to the new instance */ data_type& create(); /** * Create a XalanDOMString object. * * @param theString A pointer to a character string * @param theCount The number of characters in the string, or npos if the string is null-terminated. * * @return reference to the new instance */ data_type& create( const char* theString, #if defined(_MSC_VER) && (_MSC_VER <= 1300) // $$$ ToDo: Some strange bug in MSVC++ complains when using data_type::npos here. data_type_size_type theCount = data_type_size_type(-1)); #else data_type_size_type theCount = data_type_size_type(data_type::npos)); #endif /** * Copy constructor * * @param theSource The source string for the copy * @param theStartPosition The position to start in the source string. * @param theCount The number of characters to copy from the source string. * * @return reference to the new instance */ data_type& create( const data_type& theSource, data_type_size_type theStartPosition = 0, data_type_size_type theCount = data_type_size_type(data_type::npos)); /** * Create a XalanDOMString object. * * @param theString A pointer to a wide character string * @param theCount The number of characters in the string, or npos if the string is null-terminated. * * @return reference to the new instance */ data_type& create( const XalanDOMChar* theString, data_type_size_type theCount = data_type_size_type(data_type::npos)); /** * Create a XalanDOMString object. * * @param theCount the size of the string * @param theChar the character used to initialize the string * * @return reference to the new instance */ data_type& create( data_type_size_type theCount, XalanDOMChar theChar); /* * Destroy a XalanDOMString object. * */ bool destroy(XalanDOMString& theDOMString) { return m_allocator.destroyObject(&theDOMString); } /** * Determine if an object is owned by the allocator... */ bool ownsObject(const data_type* theObject) { return m_allocator.ownsObject(theObject); } /** * Delete all instance objects from allocator. */ void reset() { m_allocator.reset(); } /** * Get the number of ArenaBlocks currently allocated. * * @return The number of blocks. */ size_type getBlockCount() const { return m_allocator.getBlockCount(); } /** * Get size of an ArenaBlock, that is, the number * of objects in each block. * * @return The size of the block */ size_type getBlockSize() const { return m_allocator.getBlockSize(); } private: // Not implemented... XalanDOMStringReusableAllocator(const XalanDOMStringReusableAllocator&); XalanDOMStringReusableAllocator& operator=(const XalanDOMStringReusableAllocator&); // Data members... ArenaAllocatorType m_allocator; }; XALAN_CPP_NAMESPACE_END #endif // XALANDOMSTRINGREUSABLEALLOCATOR_INCLUDE_GUARD_12455133 --------------------------------------------------------------------- To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: xalan-cvs-help@xml.apache.org