GME  13
BinFileOutputStream.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  * 
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  * 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: BinFileOutputStream.cpp 553915 2007-07-06 14:57:08Z amassari $
00020  */
00021 
00022 
00023 // ---------------------------------------------------------------------------
00024 //  Includes
00025 // ---------------------------------------------------------------------------
00026 #include <xercesc/internal/BinFileOutputStream.hpp>
00027 #include <xercesc/util/Janitor.hpp>
00028 #include <xercesc/util/PlatformUtils.hpp>
00029 #include <xercesc/util/XMLExceptMsgs.hpp>
00030 #include <xercesc/util/XMLString.hpp>
00031 
00032 XERCES_CPP_NAMESPACE_BEGIN
00033 
00034 // ---------------------------------------------------------------------------
00035 //  BinFileOutputStream: Constructors and Destructor
00036 // ---------------------------------------------------------------------------
00037 BinFileOutputStream::~BinFileOutputStream()
00038 {
00039     if (getIsOpen())
00040         XMLPlatformUtils::closeFile(fSource, fMemoryManager);
00041 }
00042 
00043 BinFileOutputStream::BinFileOutputStream(const XMLCh*   const fileName
00044                                          , MemoryManager* const manager)
00045 
00046 :fSource(XMLPlatformUtils::openFileToWrite(fileName, manager))
00047 ,fMemoryManager(manager)
00048 {
00049 }
00050 
00051 BinFileOutputStream::BinFileOutputStream(const char*    const fileName
00052                                        , MemoryManager* const manager)
00053 :fSource(XMLPlatformUtils::openFileToWrite(fileName, manager))
00054 ,fMemoryManager(manager)
00055 {
00056 }
00057 
00058 // ---------------------------------------------------------------------------
00059 //  BinFileOutputStream: Getter methods
00060 // ---------------------------------------------------------------------------
00061 XMLFilePos BinFileOutputStream::getSize() const
00062 {
00063     return XMLPlatformUtils::fileSize(fSource, fMemoryManager);
00064 }
00065 
00066 
00067 // ---------------------------------------------------------------------------
00068 //  BinFileOutputStream: Stream management methods
00069 // ---------------------------------------------------------------------------
00070 void BinFileOutputStream::reset()
00071 {
00072     XMLPlatformUtils::resetFile(fSource, fMemoryManager);
00073 }
00074 
00075 
00076 // ---------------------------------------------------------------------------
00077 //  BinFileOutputStream: Implementation of the input stream interface
00078 // ---------------------------------------------------------------------------
00079 XMLFilePos BinFileOutputStream::curPos() const
00080 {
00081     return XMLPlatformUtils::curFilePos(fSource, fMemoryManager);
00082 }
00083 
00084 
00085 void BinFileOutputStream::writeBytes( const XMLByte* const  toGo
00086                                     , const XMLSize_t       maxToWrite)
00087 {
00088     //
00089     //  Write up to the maximum bytes requested. 
00090     //  
00091 
00092     XMLPlatformUtils::writeBufferToFile(fSource, maxToWrite, toGo, fMemoryManager);
00093 }
00094 
00095 XERCES_CPP_NAMESPACE_END