cdrfile.h

Go to the documentation of this file.
00001 // OSB library ************************************************ -*- C++ -*-
00006 /*
00007   AUTHOR(S): Stephan Broennimann (vb)
00008 
00009   RCS information
00010    $Name: OSB_060808 $
00011    $Revision: 1.27 $
00012 
00013   License
00014    OSB rating and billing library for communication networks
00015    Copyright (C) 2004, 2005, 2006  OSB systems
00016 
00017    This file may be distributed and/or modify under the terms of the
00018    GNU General Public License (GPL) as published by the Free Software
00019    Foundation which is provided in the file LICENSE.GPL included in the
00020    packaging of this file.
00021 
00022    The file is distributed in the hope that it will be useful, but WITHOUT
00023    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00024    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00025    for more details.
00026 
00027    Holders of a OSB Commercial License may use this file under the terms
00028    and conditions of this commercial license.
00029  */
00030 #ifndef _CDRFILE_H_
00031 #define _CDRFILE_H_
00032 
00033 // ************************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <cstdio>
00037 #include <string>
00038 
00039 // + libraries
00040 
00041 // + local headers
00042 #include "asn1fwd.h"
00043 
00044 // + class declarations
00045 namespace OSB_LIB {
00046     class Cdr;
00047     class Asn1Reader;
00048     class Asn1Writer;
00049 }
00050 
00051 // ************************************************************************
00052 // namespace extensions
00053 namespace OSB_LIB {
00054 
00055 // ************************************************************************
00056 // class definitions
00062     class FileBase {
00063     public:
00065         FileBase();
00067         virtual ~FileBase();
00068 
00069     private:
00071         FileBase(const FileBase&);
00073         FileBase& operator=(const FileBase&);
00074 
00075     public:                             // information
00077         bool isOpen() const;
00079         const std::string& name() const;
00081         const std::string& dir() const;
00087         const std::string path() const;
00094         bool eof();
00101         bool error();
00102 
00109         FILE* file();
00110 
00111     public:                             // manipulation
00118         virtual int close();
00119 
00129         int remove();
00130 
00142         int rename(const std::string& newName);
00143 
00144     protected:
00155         int open(
00156             const std::string& dir,
00157             const std::string& name,
00158             const char*        mode
00159         );
00160 
00161     protected:
00163         FILE* file_;
00165         std::string name_;
00167         std::string dir_;
00168     };                                  // class FileBase
00169 
00173     class CdrInputFile : public FileBase {
00174     public:
00176         CdrInputFile();
00177 
00178     private:
00180         CdrInputFile(const CdrInputFile&);
00182         CdrInputFile& operator=(const CdrInputFile&);
00183 
00184     public:                             // manipulation
00192         int open(
00193             const std::string& path,
00194                   bool         binary
00195         );
00204         int open(
00205             const std::string& dir,
00206             const std::string& name,
00207                   bool         binary
00208         );
00209 
00217         bool readLine(std::string* dest);
00218 
00225         bool readAsn1(Asn1Reader* dest);
00226     };                                  // class CdrInputFile
00227 
00231     class CdrOutputFile : public FileBase {
00232     public:
00242         CdrOutputFile(
00243             const size_t        blockSize = 0,
00244             const unsigned char filler    = 0x00
00245         );
00246 
00257         virtual int close();
00258 
00259     private:
00261         CdrOutputFile(const CdrOutputFile&);
00263         CdrOutputFile& operator=(const CdrOutputFile&);
00264 
00265     public:
00275         int open(
00276             const std::string& path
00277         );
00278 
00289         int open(
00290             const std::string& dir,
00291             const std::string& name
00292         );
00293 
00300         int flush();
00301 
00311         int write(
00312             const Cdr&        cdr,
00313                   Asn1Writer& writer
00314         );
00315 
00324         int write(const std::string& record);
00325 
00334         int write(const Asn1Data& asn1);
00335 
00336     public:
00337         //@name ASN.1 block support.
00339 
00340         size_t blkSz_;
00342         unsigned char          filler_;
00344         size_t cnt_;
00346     };                                  // class CdrOutputFile
00347 }                                       // namespace OSB_LIB
00348 #endif                                  // #ifndef _CDRFILE_H_

Generated on Sat Sep 2 14:06:32 2006 for OSB Library by  doxygen 1.4.7