diff options
author | Nikolai Pretzell <np@openoffice.org> | 2002-03-08 13:25:40 +0000 |
---|---|---|
committer | Nikolai Pretzell <np@openoffice.org> | 2002-03-08 13:25:40 +0000 |
commit | 8913e1e75efa377a107fa37d22680ec223cb043c (patch) | |
tree | f2c7a438e6bfaab1a6c708a43afa1b2fc71ef6bc /cosv/inc | |
parent | d4bc2730f1d2088e5d4537ce7eb7333822c747d6 (diff) |
Moving Autodoc to OpenOffice.org, module cosv: CommonServices
Diffstat (limited to 'cosv/inc')
-rw-r--r-- | cosv/inc/cosv/bstream.hxx | 184 | ||||
-rw-r--r-- | cosv/inc/cosv/comdline.hxx | 103 | ||||
-rw-r--r-- | cosv/inc/cosv/comfunc.hxx | 137 | ||||
-rw-r--r-- | cosv/inc/cosv/csv_env.hxx | 197 | ||||
-rw-r--r-- | cosv/inc/cosv/csv_ostream.hxx | 168 | ||||
-rw-r--r-- | cosv/inc/cosv/csv_precomp.h | 78 | ||||
-rw-r--r-- | cosv/inc/cosv/datetime.hxx | 118 | ||||
-rw-r--r-- | cosv/inc/cosv/dirchain.hxx | 208 | ||||
-rw-r--r-- | cosv/inc/cosv/file.hxx | 171 | ||||
-rw-r--r-- | cosv/inc/cosv/mbstream.hxx | 127 | ||||
-rw-r--r-- | cosv/inc/cosv/openclose.hxx | 173 | ||||
-rw-r--r-- | cosv/inc/cosv/persist.hxx | 139 | ||||
-rw-r--r-- | cosv/inc/cosv/ploc.hxx | 161 | ||||
-rw-r--r-- | cosv/inc/cosv/ploc_dir.hxx | 152 | ||||
-rw-r--r-- | cosv/inc/cosv/plocroot.hxx | 114 | ||||
-rw-r--r-- | cosv/inc/cosv/std_outp.hxx | 165 | ||||
-rw-r--r-- | cosv/inc/cosv/str_types.hxx | 123 | ||||
-rw-r--r-- | cosv/inc/cosv/streamstr.hxx | 369 | ||||
-rw-r--r-- | cosv/inc/cosv/string.hxx | 602 | ||||
-rw-r--r-- | cosv/inc/cosv/stringdata.hxx | 169 | ||||
-rw-r--r-- | cosv/inc/cosv/x.hxx | 105 |
21 files changed, 3763 insertions, 0 deletions
diff --git a/cosv/inc/cosv/bstream.hxx b/cosv/inc/cosv/bstream.hxx new file mode 100644 index 000000000000..55f04a0a9c9d --- /dev/null +++ b/cosv/inc/cosv/bstream.hxx @@ -0,0 +1,184 @@ +/************************************************************************* + * + * $RCSfile: bstream.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_BSTREAM_HXX +#define CSV_BSTREAM_HXX + +#include <string.h> +#include <cosv/string.hxx> + + +namespace csv +{ + + +enum seek_dir +{ + beg = 0, + cur = 1, + end = 2 +}; + + +class bistream +{ + public: + // LIFECYCLE + virtual ~bistream() {} + + // OPERATIONS + /// @return Number of actually read bytes. + uintt read( + void * out_pDest, + uintt i_nNrofBytes); + // INQUIRY + /** @return True, if already one try to read had failed. + There is no guarantee, that it returns true, if end of data + is just reached. + Though it will return false, if there is still somemething + to read. + */ + bool eod() const; + + private: + virtual uintt do_read( + void * out_pDest, + uintt i_nNrofBytes) = 0; + virtual bool inq_eod() const = 0; +}; + + +class bostream +{ + public: + // LIFECYCLE + virtual ~bostream() {} + + // OPERATIONS + /// @return Number of actually written bytes. + uintt write( + const void * i_pSrc, + uintt i_nNrofBytes); + /// @return Number of actually written bytes. + uintt write( + const char * i_pSrc ); + /// @return Number of actually written bytes. + uintt write( + const String & i_pSrc ); + private: + virtual uintt do_write( + const void * i_pSrc, + uintt i_nNrofBytes) = 0; +}; + + +class bstream : public bistream, + public bostream +{ + public: + uintt seek( + intt i_nDistanceFromBegin, + seek_dir i_eStartPoint = ::csv::beg ); + uintt position() const; + + private: + virtual uintt do_seek( + intt i_nDistance, + seek_dir i_eStartPoint = ::csv::beg ) = 0; + virtual uintt inq_position() const = 0; +}; + + +// IMPLEMENTATION +inline uintt +bistream::read( void * o_pDest, + uintt i_nNrofBytes) + { return do_read(o_pDest, i_nNrofBytes); } +inline bool +bistream::eod() const + { return inq_eod(); } + +inline uintt +bostream::write( const void * i_pSrc, + uintt i_nNrofBytes) + { return do_write( i_pSrc, i_nNrofBytes ); } +inline uintt +bostream::write( const char * i_sSrc ) + { return write( i_sSrc, strlen(i_sSrc) ); } +inline uintt +bostream::write( const String & i_sSrc ) + { return write( i_sSrc.c_str(), i_sSrc.length() ); } + +inline uintt +bstream::seek( intt i_nDistance, + seek_dir i_eStartPoint ) + { return do_seek( i_nDistance, i_eStartPoint ); } +inline uintt +bstream::position() const + { return inq_position(); } + + + +} // namespace csv + + +#endif + diff --git a/cosv/inc/cosv/comdline.hxx b/cosv/inc/cosv/comdline.hxx new file mode 100644 index 000000000000..14fcdaf0128d --- /dev/null +++ b/cosv/inc/cosv/comdline.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * $RCSfile: comdline.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_COMDLINE_HXX +#define CSV_COMDLINE_HXX + + + +namespace csv +{ + +class CommandLine_Ifc +{ + public: + virtual ~CommandLine_Ifc() {} + + void Init( + int argc, + char * argv[] ); + void PrintUse() const; + bool CheckParameters() const; + + private: + virtual void do_Init( + int argc, + char * argv[] ) = 0; + + virtual void do_PrintUse() const = 0; + virtual bool inq_CheckParameters() const = 0; +}; + +inline void +CommandLine_Ifc::Init( int argc, + char * argv[] ) + { do_Init( argc, argv ); } +inline void +CommandLine_Ifc::PrintUse() const + { do_PrintUse(); } + +} // namespace csv + + + +#endif + diff --git a/cosv/inc/cosv/comfunc.hxx b/cosv/inc/cosv/comfunc.hxx new file mode 100644 index 000000000000..076d0553834c --- /dev/null +++ b/cosv/inc/cosv/comfunc.hxx @@ -0,0 +1,137 @@ +/************************************************************************* + * + * $RCSfile: comfunc.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_COMFUNC_HXX +#define CSV_COMFUNC_HXX + +namespace csv +{ + +class String; + +// min, max and range functions +template <class E> +inline E max(E in1, E in2); +template <class E> +inline E min(E in1, E in2); +template <class E> +inline bool in_range(E low, E val, E high); // return low <= val < high; + + +// string functions +inline const char * valid_str(const char * str); +inline bool no_str(const char * str); // return !str || !strlen(str) +intt count_chars(const char * str, char c); + + +// endian functions +template <class NUMTYPE> +void switch_endian( + NUMTYPE & o_rNumber, + const NUMTYPE & i_rNumber ); + +// Zeit-Typecasts +bool str2date(const char * str, int & out_day, int & out_month, int & out_year); +void date2str(String & out_Str, int day, int month, int year); +bool str2time(const char * str, int & out_hour, int & out_min, int & out_sec); +void time2str(String & out_Str, int hour, int min, int sec); + + +template <class E> +inline E +max(E in1, E in2) { return in1 < in2 ? in2 : in1; } +template <class E> +inline E +min(E in1, E in2) { return in1 < in2 ? in1 : in2; } +template <class E> +inline bool +in_range(E low, E val, E high) { return low <= val AND val < high; } + +inline const char * +valid_str(const char * str) { return str != 0 ? str : ""; } +inline bool +no_str(const char * str) { return str != 0 ? *str == '\0' : true; } + + +template <class NUMTYPE> +void +switch_endian( NUMTYPE & o_rNumber, + const NUMTYPE & i_rNumber ) +{ + char * pFront = reinterpret< char* >(&o_rNumber); + const char * pBack = reinterpret< char* >(&i_rNumber) + (sizeof(NUMTYPE) - 1); + + for ( unsigned int p = sizeof(NUMTYPE); p != 0; --p ) + { + *pFront++ = *pBack--; + } +} + + + +} // namespace csv + + + + +#endif + + diff --git a/cosv/inc/cosv/csv_env.hxx b/cosv/inc/cosv/csv_env.hxx new file mode 100644 index 000000000000..746cfb7822d4 --- /dev/null +++ b/cosv/inc/cosv/csv_env.hxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * $RCSfile: csv_env.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_CSV_ENV_HXX +#define CSV_CSV_ENV_HXX + + + +// BEGIN Compiler dependent defines regarding standard compliance, +// subject to changes: +// #define CSV_NO_BOOL_TYPE // States that no system type 'bool' exists +#define CSV_NO_MUTABLE // No keyword mutable +#define CSV_NO_EXPLICIT // No keyword explicit +// #define CSV_NO_IOSTREAMS // No iostreams +// END Compiler dependent defines, subject to changes + + +// BEGIN Compiler dependent defines, controlled by above defines +#ifdef CSV_NO_BOOL_TYPE +typedef int bool_int; +#define bool bool_int +#define false 0 +#define true 1 +#endif // CSV_NO_BOOL_TYPE + +#ifdef CSV_NO_MUTABLE +#define mutable +#endif // CSV_NO_MUTABLE + +#ifdef CSV_NO_EXPLICIT +#define explicit +#endif // CSV_NO_EXPLICIT +// END Compiler dependent defines, controlled by above defines + + +//******* Builtin types of exact length ************// + +// Exact length builtin types +typedef signed char INT8; +typedef unsigned char UINT8; +typedef short INT16; +typedef unsigned short UINT16; +typedef long INT32; +typedef unsigned long UINT32; +typedef float REAL32; +typedef double REAL64; + + +// Additional builtin types +typedef INT32 intt; // Um ein exakt definiertes Standard-int zu haben. +typedef UINT32 uintt; // Das dazu passende Standard-unsigned-int. +typedef REAL64 real; + +// Constants +// --------- +// Zero-pointer for use in ellipsed (...) parameter lists which expect a +// pointer which may have another size than an int. +// Must be a define to be used in precompiled headers: +#define NIL ((void*)0) +// char '\0' +#define NULCH '\0' + + + +// Boolesche Operatoren +#define AND && +#define OR || +#define NOT ! + +// Macro for distinguishing dynamic allocated pointers from +// referencing pointers +#define DYN // Exact specification: DYN has to be used if and only if: + // 1. DYN specifies a class member pointer or reference variable and + // the class must free the referenced memory. + // 2. DYN specifies a pointer or reference (return-) parameter of a function + // and for in-parameters the function or its class + // must free the referenced memory, the parameter is then called + // a let-parameter. + // For out- and inout-parameters + // or return values the caller of the function hast to + // free the referenced memory. + // + // It is irrelevant who allocated the memory! + // + // DYN - variables use the prefixes "dp" or "dr" instead of "p" or "r". + + +//****** Assertions ******// + +namespace csv +{ +void PerformAssertion( + const char * condition, + const char * file, + unsigned line ); +} + +// Programming by contract +#ifndef CSV_NO_ASSERTIONS +// Subject to change to more sophisticated handling +#define precond(x) csv_assert(x) +#define postcond(x) csv_assert(x) +#define csv_assert(x) ( (x) ? (void)(0) : csv::PerformAssertion( #x, __FILE__, __LINE__) ) +#define csv_noimpl(x) csv::PerformAssertion( "Functon " #x " is not yet implemented.", __FILE__, __LINE__) +#define csv_exception csv::PerformAssertion( "Exception to be raised.", __FILE__, __LINE__) +#else +#define precond(x) +#define postcond(x) +#define csv_assert(x) +#define csv_noimpl(x) +#define csv_exception +#endif // end ifndef NDEBUG else + + + + + + + + + +/* Additional Programming Conventions +1. see above at "#define DYN" +2. function parameters get one of these prefixes: + - i_ := Function uses only the value, but must not change a referenced variable. + - o_ := Parameter is undefined until function has set it. + Parametere must be set by the function. + - io_ := Function may use and change the referenced variable. + - let_ := Funktion may use and change the referenced variable and HAS TO free the + associated memory. +3. Global constants get the prefix 'C_', global variables the prefix + 'G_', local constants the prefix 'c_' . +4. Static members end with an underscore '_'. + +*/ + + +#endif + diff --git a/cosv/inc/cosv/csv_ostream.hxx b/cosv/inc/cosv/csv_ostream.hxx new file mode 100644 index 000000000000..e852701ab870 --- /dev/null +++ b/cosv/inc/cosv/csv_ostream.hxx @@ -0,0 +1,168 @@ +/************************************************************************* + * + * $RCSfile: csv_ostream.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_CSV_OSTREAM_HXX +#define CSV_CSV_OSTREAM_HXX + +// USED SERVICES + // BASE CLASSES + // COMPONENTS + // PARAMETERS + + + +#ifndef CSV_NO_IOSTREAMS + +#include <iostream> + + +namespace csv +{ + +typedef std::ios ios; +typedef std::ostream ostream; + +} // namespace csv + + +#else + +#include <cosv/template/dyn.hxx> + +namespace csv +{ + +class StreamStr; + +class ios +{ + public: + enum seek_dir + { + beg=0, + cur=1, + end=2 + }; +}; + +class ostream : public ios +{ + public: + typedef ostream self; + + virtual ~ostream(); + + self & operator<<( + const char * i_s ); + self & operator<<( + char i_c ); + self & operator<<( + unsigned char i_c ); + self & operator<<( + signed char i_c ); + + self & operator<<( + short i_n ); + self & operator<<( + unsigned short i_n ); + self & operator<<( + int i_n ); + self & operator<<( + unsigned int i_n ); + self & operator<<( + long i_n ); + self & operator<<( + unsigned long i_n ); + + self & operator<<( + float i_n ); + self & operator<<( + double i_n ); + + self & seekp( + intt i_nOffset, + seek_dir i_eStart = ios::beg ); + protected: + ostream( + uintt i_nStartSize ); + const StreamStr & Data() const; + + private: + Dyn<StreamStr> pData; +}; + + + +inline const StreamStr & +ostream::Data() const + { return *pData; } + + +} // namespace csv + + +#endif + + + + +#endif + diff --git a/cosv/inc/cosv/csv_precomp.h b/cosv/inc/cosv/csv_precomp.h new file mode 100644 index 000000000000..301776c6283c --- /dev/null +++ b/cosv/inc/cosv/csv_precomp.h @@ -0,0 +1,78 @@ +/************************************************************************* + * + * $RCSfile: csv_precomp.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef __CSV_PRECOMP_H_06071998__ +#define __CSV_PRECOMP_H_06071998__ + + +#include <cosv/csv_env.hxx> +#include <cosv/comfunc.hxx> +#include <cosv/string.hxx> +#include <cosv/streamstr.hxx> +#include <cosv/std_outp.hxx> +#include <cosv/template/dyn.hxx> + + + + + +#endif + diff --git a/cosv/inc/cosv/datetime.hxx b/cosv/inc/cosv/datetime.hxx new file mode 100644 index 000000000000..7500a7bef1ed --- /dev/null +++ b/cosv/inc/cosv/datetime.hxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * $RCSfile: datetime.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_DATETIME_HXX +#define CSV_DATETIME_HXX + + + +namespace csv +{ + + +class Date +{ + public: + Date(); + Date( + unsigned i_nDay, + unsigned i_nMonth, + unsigned i_nYear ); + + unsigned Day() const { return nData >> 24; } + unsigned Month() const { return (nData & 0x00FF0000) >> 16; } + unsigned Year() const { return nData & 0x0000FFFF; } + + static const Date & Null_(); + + private: + UINT32 nData; +}; + +class Time +{ + public: + Time(); + Time( + unsigned i_nHour, + unsigned i_nMinutes, + unsigned i_nSeconds = 0, + unsigned i_nSeconds100 = 0 ); + + unsigned Hour() const { return nData >> 24; } + unsigned Minutes() const { return (nData & 0x00FF0000) >> 16; } + unsigned Seconds() const { return (nData & 0x0000FF00) >> 8; } + unsigned Seconds100() const { return nData & 0x000000FF; } + + static const Time & Null_(); + + private: + UINT32 nData; +}; + + +} // namespace csv + + + + +#endif + diff --git a/cosv/inc/cosv/dirchain.hxx b/cosv/inc/cosv/dirchain.hxx new file mode 100644 index 000000000000..e7556ee0348f --- /dev/null +++ b/cosv/inc/cosv/dirchain.hxx @@ -0,0 +1,208 @@ +/************************************************************************* + * + * $RCSfile: dirchain.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_DIRCHAIN_HXX +#define CSV_DIRCHAIN_HXX + + +// USED SERVICES + // BASE CLASSES + // COMPONENTS +#include <cosv/string.hxx> + // PARAMETERS +#include <cosv/csv_ostream.hxx> + +#include <cosv/persist.hxx> +#include <cosv/template/tpltools.hxx> + + + +namespace csv +{ + class bostream; + +namespace ploc +{ + + +class DirectoryChain +{ + public: + DirectoryChain(); + DirectoryChain( + const char * i_sPath, + bool i_bPathIsAlwaysDir = false, + const char * i_sDelimiter = Delimiter() ); + DirectoryChain( + const DirectoryChain & + i_rDC ); + ~DirectoryChain(); + + // OPERATORS + DirectoryChain & operator=( + const DirectoryChain & + i_rDC ); + DirectoryChain & operator+=( + const String & i_sName ); + DirectoryChain & operator+=( + const DirectoryChain & + i_rDC ); + // OPERATIONS + void Set( + const char * i_sPath, + bool i_bPathIsAlwaysDir = false, + const char * i_sDelimiter = Delimiter() ); + void PushFront( + const String & i_sName ); + void PushFront( + const DirectoryChain & + i_sPath ); + void PushBack( + const String & i_sName ); + void PushBack( + const DirectoryChain & + i_sPath ); + void PopFront( + uintt i_nCount = 1 ); + void PopBack( + uintt i_nCount = 1 ); + + // INQUIRY + uintt Size() const; + + StringVector::const_iterator + Begin() const; + StringVector::const_iterator + End() const; + + const String & Front() const; + const String & Back() const; + + void Get( + ostream & o_rPath, + const char * i_sDelimiter ) const; + void Get( + bostream & o_rPath, + const char * i_sDelimiter ) const; + private: + StringVector aPath; +}; + + +// IMPLEMENTATION +inline +DirectoryChain::DirectoryChain( const DirectoryChain & i_rDC ) + { PushBack(i_rDC); } + + // OPERATORS +inline DirectoryChain & +DirectoryChain::operator=( const DirectoryChain & i_rDC ) + { csv::erase_container(aPath); PushBack(i_rDC); return *this; } +inline DirectoryChain & +DirectoryChain::operator+=( const String & i_sName ) + { PushBack(i_sName); return *this; } +inline DirectoryChain & +DirectoryChain::operator+=( const DirectoryChain & i_rDC ) + { PushBack(i_rDC); return *this; } +inline uintt +DirectoryChain::Size() const + { return aPath.size(); } + +inline StringVector::const_iterator +DirectoryChain::Begin() const + { return aPath.begin(); } +inline StringVector::const_iterator +DirectoryChain::End() const + { return aPath.end(); } +inline const String & +DirectoryChain::Front() const + { return aPath.empty() ? String::Null_() : aPath.front(); } +inline const String & +DirectoryChain::Back() const + { return aPath.empty() ? String::Null_() : aPath.back(); } + + +} // namespace ploc +} // namespace csv + + +inline csv::ostream & +operator<<( csv::ostream & o_rOut, + const csv::ploc::DirectoryChain & i_rSubPath ) +{ + i_rSubPath.Get(o_rOut, csv::ploc::Delimiter()); + return o_rOut; +} + +inline csv::bostream & +operator<<( csv::bostream & o_rOut, + const csv::ploc::DirectoryChain & i_rSubPath ) +{ + i_rSubPath.Get(o_rOut, csv::ploc::Delimiter()); + return o_rOut; +} + + + +#endif + + + diff --git a/cosv/inc/cosv/file.hxx b/cosv/inc/cosv/file.hxx new file mode 100644 index 000000000000..01173555a92e --- /dev/null +++ b/cosv/inc/cosv/file.hxx @@ -0,0 +1,171 @@ +/************************************************************************* + * + * $RCSfile: file.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_FILE_HXX +#define CSV_FILE_HXX + +// USED SERVICES + // BASE CLASSES +#include <cosv/bstream.hxx> +#include <cosv/openclose.hxx> + // COMPONENTS +#include <stdio.h> +#include <cosv/string.hxx> + // PARAMETERS +#include <cosv/persist.hxx> +#include <cosv/ploc.hxx> + + +class FileStrategy; + + +namespace csv +{ + + +/** @task + File is a class representing a file. +*/ +class File : public bstream, + public OpenClose, + public ploc::Persistent +{ + public: + // LIFECYCLE + File( + uintt i_nMode = CFM_RW ); + File( + const ::csv::ploc::Path & + i_rLocation, + uintt i_nMode = CFM_RW ); + File( + const char * i_sLocation, + uintt in_nMode = CFM_RW ); + File( + const String & i_sLocation, + uintt in_nMode = CFM_RW ); + virtual ~File(); + + // OPERATIONS + bool Assign( + ploc::Path i_rLocation ); + bool Assign( + const char * i_sLocation ); + bool Assign( + const String & i_sLocation ); + // INQUIRY + uintt Mode() const; + + private: + enum E_LastIO + { + io_none = 0, + io_read, + io_write + }; + + // Interface bistream: + virtual uintt do_read( + void * out_pDest, + uintt i_nNrofBytes); + virtual bool inq_eod() const; + // Interface bostream: + virtual uintt do_write( + const void * i_pSrc, + uintt i_nNrofBytes); + // Interface bstream: + virtual uintt do_seek( + intt i_nDistance, + seek_dir i_eStartPoint = ::csv::beg ); + virtual uintt inq_position() const; + // Interface OpenClose: + virtual bool do_open( + uintt in_nOpenModeInfo ); + virtual void do_close(); + virtual bool inq_is_open() const; + // Interface Persistent: + virtual const ploc::Path & + inq_MyPath() const; + // DATA + ploc::Path aPath; + FILE * pStream; + + uintt nMode; /// RWMode, OpenMode and ShareMode. + E_LastIO eLastIO; +}; + + + +// IMPLEMENTATION + +inline uintt +File::Mode() const + { return nMode; } + + +} // namespace csv + + + + +#endif + + diff --git a/cosv/inc/cosv/mbstream.hxx b/cosv/inc/cosv/mbstream.hxx new file mode 100644 index 000000000000..45756568de08 --- /dev/null +++ b/cosv/inc/cosv/mbstream.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $RCSfile: mbstream.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_MBSTREAM_HXX +#define CSV_MBSTREAM_HXX + +// USED SERVICES + // BASE CLASSES +#include <cosv/bstream.hxx> + // COMPONENTS + // PARAMETERS + + +namespace csv +{ + +class mbstream : public bstream +{ + public: + // LIFECYCLE + mbstream( + uintt i_nSize); + ~mbstream(); + // OPERATIONS + void resize( + uintt i_nSize ); + // INQUIRY + uintt size() const; + const void * data() const; + + private: + // Interface bistream: + virtual uintt do_read( + void * out_pDest, + uintt i_nNrofBytes); + virtual bool inq_eod() const; + // Interface bostream: + virtual uintt do_write( + const void * i_pSrc, + uintt i_nNrofBytes); + // Interface bstream: + virtual uintt do_seek( + intt i_nDistance, + seek_dir i_eStartPoint = ::csv::beg ); + virtual uintt inq_position() const; + + // DYN + DYN char * dpOwnedMemorySpace; + uintt nSize; + uintt nCurPosition; +}; + + +// IMPLEMENTATION + +inline uintt +mbstream::size() const + { return nSize; } +inline const void * +mbstream::data() const + { return dpOwnedMemorySpace; } + + +} // namespace csv + + +#endif + + diff --git a/cosv/inc/cosv/openclose.hxx b/cosv/inc/cosv/openclose.hxx new file mode 100644 index 000000000000..1c4bf59805bc --- /dev/null +++ b/cosv/inc/cosv/openclose.hxx @@ -0,0 +1,173 @@ +/************************************************************************* + * + * $RCSfile: openclose.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_OPENCLOSE_HXX +#define CSV_OPENCLOSE_HXX + + +namespace csv +{ + +// Open modes for storages: +enum E_RWMode +{ + rwDefault = 0x0000, // Keep old settings. If there are none, set default. + rwRead = 0x0001, // Reads only + rwWrite = 0x0002, // Writes only + rwReadWrite = 0x0003 // Reads and writes. +}; + +enum E_OpenMode +{ + omCreateIfNecessary = 0x0000, // Creates a new file only, if file does not exist. + omCreateNot = 0x0010, // Open fails, if file does not exist. + omCreate = 0x0020 // Existing file will be deleted. +}; +enum E_ShareMode +{ + shmShareNot = 0x0000, // Allow others nothing + shmShareRead = 0x0004, // Allow others to read + shmShareAll = 0x000C // Allow others to read and write +}; + +/** Constants for filemode combinations + These combinations are the only ones, guaranteed to be supported. +*/ +const UINT32 CFM_RW = rwReadWrite; +const UINT32 CFM_CREATE = rwReadWrite | omCreate; +const UINT32 CFM_READ = rwRead | omCreateNot | shmShareRead; + + + +class OpenClose +{ + public: + bool open( + UINT32 in_nOpenModeInfo = 0 ); /// Combination of values of E_RWMode and E_ShareMode und E_OpenMode. 0 := Keep existing mode. + void close(); + + bool is_open() const; + + private: + virtual bool do_open( + UINT32 in_nOpenModeInfo ) = 0; + virtual void do_close() = 0; + virtual bool inq_is_open() const = 0; +}; + + + +class OpenCloseGuard +{ + public: + OpenCloseGuard( + OpenClose & i_rOpenClose, + UINT32 i_nOpenModeInfo = 0 ); + ~OpenCloseGuard(); + operator bool() const; + + private: + // Forbidden: + OpenCloseGuard(OpenCloseGuard&); + OpenCloseGuard & operator=(OpenCloseGuard&); + + // DATA + OpenClose & rOpenClose; +}; + + +// IMPLEMENTATION + +inline bool +OpenClose::open( UINT32 i_nOpenModeInfo ) + { return do_open(i_nOpenModeInfo); } +inline void +OpenClose::close() + { do_close(); } +inline bool +OpenClose::is_open() const + { return inq_is_open(); } + +inline +OpenCloseGuard::OpenCloseGuard( OpenClose & i_rOpenClose, + UINT32 i_nOpenModeInfo ) + : rOpenClose(i_rOpenClose) + { rOpenClose.open(i_nOpenModeInfo); } +inline +OpenCloseGuard::~OpenCloseGuard() + { rOpenClose.close(); } +inline +OpenCloseGuard::operator bool() const + { return rOpenClose.is_open(); } + + + + +} // namespace csv + + + + + + +#endif + + diff --git a/cosv/inc/cosv/persist.hxx b/cosv/inc/cosv/persist.hxx new file mode 100644 index 000000000000..579754ff4682 --- /dev/null +++ b/cosv/inc/cosv/persist.hxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * $RCSfile: persist.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_PERSIST_HXX +#define CSV_PERSIST_HXX + + +// USED SERVICES + // BASE CLASSES + // COMPONENTS +#include <cosv/string.hxx> + // PARAMETERS + + +namespace csv +{ +namespace ploc +{ + +class Path; + + +inline const char * +Delimiter() +{ +#ifdef WNT + return "\\"; +#elif defined(UNX) + return "/"; +#else +#error For using csv::ploc there has to be defined: WNT or UNX. +#endif +} + + + +class Persistent +{ + public: + virtual ~Persistent() {} + + const Path & MyPath() const; + /// @return Path of directories without completing delimiter. + const char * StrPath() const; + bool Exists() const; + + protected: + Persistent(); + void InvalidatePath(); + + private: + virtual const Path & + inq_MyPath() const = 0; + // DATA + mutable StreamStr sPath; +}; + + + +// IMPLEMENTATION + +inline +Persistent::Persistent() + : sPath(30) { } +inline const Path & +Persistent::MyPath() const + { return inq_MyPath(); } +inline void +Persistent::InvalidatePath() + { sPath.clear(); } + + + +} // namespace csv +} // namespace ploc + + +#endif + + + diff --git a/cosv/inc/cosv/ploc.hxx b/cosv/inc/cosv/ploc.hxx new file mode 100644 index 000000000000..3ec4542693f6 --- /dev/null +++ b/cosv/inc/cosv/ploc.hxx @@ -0,0 +1,161 @@ +/************************************************************************* + * + * $RCSfile: ploc.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_PLOC_HXX +#define CSV_PLOC_HXX + + +// USED SERVICES + // BASE CLASSES + // COMPONENTS +#include <cosv/string.hxx> +#include <cosv/plocroot.hxx> +#include <cosv/dirchain.hxx> +#include <cosv/template/dyn.hxx> + // PARAMETERS +#include <cosv/csv_ostream.hxx> + + +namespace csv +{ + class bostream; + + +namespace ploc +{ + class Root; + +class Path +{ + public: + + // LIFECYCLE + Path( + const char * i_sPath = ".", /// Dirs have to be ended with a '\\ or '/'. + bool i_bPathIsAlwaysDir = false, /// This overrides a missing Delimiter at the end of the i_sPath, if true. + const char * i_sDelimiter = Delimiter() ); + Path( + const Path & i_rPath ); + ~Path(); + // OPERATORS + Path & operator=( + const Path & i_rPath ); + // OPERATIONS + void Set( + const char * i_sPath, + bool i_bPathIsAlwaysDir = false, + const char * i_sDelimiter = Delimiter() ); + void SetFile( // If there is already a file, that is exchanged. + const String & i_sName ); + // INQUIRY + const Root & RootDir() const { return *pRoot; } + const DirectoryChain & + DirChain() const { return aPath; } + const String & File() const { return sFile; } + const char * FileEnding() const; + bool IsValid() const; + bool IsDirectory() const { return sFile.length() == 0; } + bool IsFile() const { return sFile.length() > 0; } + + virtual void Get( + ostream & o_rPath ) const; + virtual void Get( + bostream & o_rPath ) const; + // ACCESS + DirectoryChain & DirChain() { return aPath; } + + private: + Dyn<Root> pRoot; + DirectoryChain aPath; + String sFile; +}; + + + + +} // namespace ploc +} // namespace csv + + + +inline csv::ostream & +operator<<( csv::ostream & o_rOut, + const csv::ploc::Path & i_rPath ) +{ + i_rPath.Get(o_rOut); + return o_rOut; +} + +inline csv::bostream & +operator<<( csv::bostream & o_rOut, + const csv::ploc::Path & i_rPath ) +{ + i_rPath.Get(o_rOut); + return o_rOut; +} + + + + +#endif + + + diff --git a/cosv/inc/cosv/ploc_dir.hxx b/cosv/inc/cosv/ploc_dir.hxx new file mode 100644 index 000000000000..585af589fae0 --- /dev/null +++ b/cosv/inc/cosv/ploc_dir.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: ploc_dir.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_PLOCDIR_HXX +#define CSV_PLOCDIR_HXX + + +// USED SERVICES + // BASE CLASSES +#include <cosv/persist.hxx> + // COMPONENTS +#include <cosv/ploc.hxx> + // PARAMETERS + +namespace csv +{ +namespace ploc +{ + +class DirectoryChain; + +enum E_Recursivity +{ + flat, + recursive +}; + +class Directory : public Persistent +{ + public: + // LIFECYCLE + Directory(); + Directory( + const Path & i_rLocation ); + Directory( + const char * i_rLocation ); + Directory( + const String & i_rLocation ); + Directory( + const Directory & i_rDir ); + virtual ~Directory(); + + // OPERATORS + Directory & operator+=( + const String & i_sName ); + Directory & operator+=( + const DirectoryChain & + i_sDirChain ); + Directory & operator-=( + uintt i_nLevels ); + + // OPERATIONS + bool PhysicalCreate( + bool i_bCreateParentsIfNecessary = true ); + + // INQUIRY + void GetContainedDirectories( + StringVector & o_rResult ) const; + /** @param i_sFilter + Currently only filters of the form "*.ending" or "*.*" + (the default) are processed correctly under UNIX. Under WNT this + restriction does not apply. + */ + void GetContainedFiles( + StringVector & o_rResult, + const char * i_sFilter = "*.*", + E_Recursivity i_eRecursivity = flat ) const; + private: + // Interface Peristent: + virtual const Path & + inq_MyPath() const; + + // Locals: + /** @return + true, if parent(!) directory exists or could be created. + false, if this is a root directory. + */ + bool Check_Parent(); + bool PhysicalCreate_Dir( + const char * i_sStr ) const; + // DATA + Path aPath; +}; + + + +} // namespace ploc +} // namespace csv + + + +#endif + + diff --git a/cosv/inc/cosv/plocroot.hxx b/cosv/inc/cosv/plocroot.hxx new file mode 100644 index 000000000000..9989ea7af36b --- /dev/null +++ b/cosv/inc/cosv/plocroot.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * $RCSfile: plocroot.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_PLOCROOT_HXX +#define CSV_PLOCROOT_HXX + + +// USED SERVICES + // BASE CLASSES + // COMPONENTS +#include <cosv/string.hxx> + // PARAMETERS +#include <cosv/csv_ostream.hxx> +#include <cosv/persist.hxx> + + +namespace csv +{ + +class bostream; + + +namespace ploc +{ + + +class Root +{ + public: + virtual ~Root(); + + static DYN Root * Create_( + const char * & o_sPathAfterRoot, + const char * i_sPath, + const char * i_sDelimiter = Delimiter() ); + + virtual void Get( /// Does not add a '\0' at the end, + ostream & o_rPath ) const = 0; + virtual void Get( /// Does not add a '\0' at the end. + bostream & so_rPath ) const = 0; + virtual DYN Root * CreateCopy() const = 0; + virtual const char * + OwnDelimiter() const = 0; +}; + + + +} // namespace ploc +} // namespace csv + + + +#endif + + + diff --git a/cosv/inc/cosv/std_outp.hxx b/cosv/inc/cosv/std_outp.hxx new file mode 100644 index 000000000000..ac1b193f4e3b --- /dev/null +++ b/cosv/inc/cosv/std_outp.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * $RCSfile: std_outp.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_STD_OUTP_HXX +#define CSV_STD_OUTP_HXX + +// USED SERVICES + // BASE CLASSES + // COMPONENTS +#include <cosv/csv_ostream.hxx> + // PARAMETERS + + + + +namespace csv +{ + +class redirect_out : public ostream +{ + public: + virtual ~redirect_out() {} + + void re_endl() { do_re_endl(); } + void re_flush() { do_re_flush(); } + + static void set_( + redirect_out & o_rStdOut, + redirect_out & o_rStdErr ) + { pStdOut_ = &o_rStdOut; + pStdErr_ = &o_rStdErr; } + + static redirect_out & + std_() { return *pStdOut_; } + static redirect_out & + err_() { return *pStdErr_; } + static bool useme_() { return pStdOut_ != 0; } + + private: + virtual void do_re_endl() = 0; + virtual void do_re_flush() = 0; + + // DATA + static redirect_out * + pStdOut_; + static redirect_out * + pStdErr_; +}; + + + +inline ostream & +Cout() +{ +#ifndef CSV_NO_IOSTREAMS + return redirect_out::useme_() + ? (ostream&)( redirect_out::std_() ) + : (ostream&)( std::cout ); +#else + csv_assert( redirect_out::useme_() ); + return redirect_out::std_(); +#endif +} + +inline ostream & +Cerr() +{ +#ifndef CSV_NO_IOSTREAMS + return redirect_out::useme_() + ? (ostream&)( redirect_out::err_() ) + : (ostream&)( std::cerr ); +#else + csv_assert( redirect_out::useme_() ); + return redirect_out::err_(); +#endif +} + + + +typedef void (*F_FLUSHING_FUNC)(ostream&, bool, int*); + +void Endl( ostream&, bool, int* ); + +void Flush( ostream&, bool, int* ); + + +} // namespace csv + + + +inline csv::ostream & +operator<<( csv::ostream & io_rStream, + csv::F_FLUSHING_FUNC i_fFlushingFunc ) +{ +#ifndef CSV_NO_IOSTREAMS + (*i_fFlushingFunc)( io_rStream, csv::redirect_out::useme_(), 0 ); +#else + csv_assert( csv::redirect_out::useme_() ); + (*i_fFlushingFunc)( io_rStream, true, 0 ); +#endif + return io_rStream; +} + + +#endif + + diff --git a/cosv/inc/cosv/str_types.hxx b/cosv/inc/cosv/str_types.hxx new file mode 100644 index 000000000000..0e3c239e161f --- /dev/null +++ b/cosv/inc/cosv/str_types.hxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * $RCSfile: str_types.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef COSV_STR_TYPES_HXX +#define COSV_STR_TYPES_HXX + + +namespace csv +{ + +struct str +{ + public: + typedef uintt position; + typedef position size; + + enum constants + { + npos = position(-1), + maxsize = size(-1) + }; + + enum insert_mode + { + overwrite = 0, + insert = 1 + }; +}; + + +class CharOrder_Table +{ + public: + /** @precond + Parameter i_pCharWeightsArray + must have size of 256. + */ + CharOrder_Table( + const int * i_pCharWeightsArray ); + + /** @return the weight of the char i_c. + @precond + Even with unusual implementations, where char has more than 8 bit, + there must be true: 0 <= i_c < 256. + */ + int operator()( + char i_c ) const; + private: + int cWeights[256]; +}; + + +// IMPLEMENTATION + +inline int +CharOrder_Table::operator()( char i_c ) const + { return cWeights[i_c]; } + + + +} // namespace csv + +#endif + + diff --git a/cosv/inc/cosv/streamstr.hxx b/cosv/inc/cosv/streamstr.hxx new file mode 100644 index 000000000000..e17b8cdd3001 --- /dev/null +++ b/cosv/inc/cosv/streamstr.hxx @@ -0,0 +1,369 @@ +/************************************************************************* + * + * $RCSfile: streamstr.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_STREAMSTR_HXX +#define CSV_STREAMSTR_HXX + + +// USED SERVICES + // BASE CLASSES +#include <cosv/bstream.hxx> + // COMPONENTS +#include <cosv/str_types.hxx> + // PARAMETERS +#include <string.h> + + + +namespace csv +{ + + +void c_str(); // Dummy needed for StreamStr::operator<<(StreamStr::F_CSTR); + +/** Diese Klasse hat alle Funktionalitaet von strstream. + Der Buffer braucht jedoch weder uebergeben noch + (nach Gebrauch) geloescht zu werden. Seine Groesse wird + mit 'length' im Constructor angegeben. +*/ + +class StreamStr : public bostream +{ + public: + typedef StreamStr self; + + typedef str::size size_type; + typedef str::position position_type; + typedef intt seek_type; + typedef str::insert_mode insert_mode; + + typedef const char * const_iterator; + typedef char * iterator; + + typedef void (*F_CSTR)(); + + + struct Area + { + typedef str::size size_type; + + Area( + const char * i_str = "", + size_type i_nLength = str::maxsize ) + : sStr(i_str), + nLength( i_nLength == str::maxsize + ? strlen(i_str) + : i_nLength ) {} + const char * sStr; + size_type nLength; + }; + + // LIFECYCLE + StreamStr( + size_type i_nCapacity ); + StreamStr( + const char * i_sInitStr, + size_type i_nCapacity ); /// Only used if > strlen(i_sInitStr). + StreamStr( + size_type i_nGuessedCapacity, + const char * str1, // [!= 0] + const char * str2, // [!= 0] + ... ); // Has to end with NIL . + /// Copies also inssert_mode and current position. + StreamStr( + const self & i_rOther ); + ~StreamStr(); + + // OPERATORS + /// Copies also inssert_mode and current position. + self & operator=( + const self & i_rOther ); + + self & operator<<( + const char * i_s ); + self & operator<<( + const String & i_s ); + self & operator<<( + char i_c ); + self & operator<<( + unsigned char i_c ); + self & operator<<( + signed char i_c ); + + self & operator<<( + short i_n ); + self & operator<<( + unsigned short i_n ); + self & operator<<( + int i_n ); + self & operator<<( + unsigned int i_n ); + self & operator<<( + long i_n ); + self & operator<<( + unsigned long i_n ); + + self & operator<<( + float i_n ); + self & operator<<( + double i_n ); + + const char * operator<<( + F_CSTR i_f ); + + const char & operator[]( + position_type i_nPosition ) const; + char & operator[]( + position_type i_nPosition ); + + // OPERATIONS + void resize( + size_type i_nMinimumCapacity ); + + void clear(); + + /** Sets start point for the next operator<<() call. + if the intended position is not reachable, nothing happens. + */ + self & seekp( + seek_type i_nCount, + seek_dir i_eDirection = ::csv::beg ); + /** Sets the insertion mode of all and only the operator<<() calls. + + str::overwrite: seekp() always sets the cur end of the string. + operator<<() calls push the end of the string forward. + str::insert: seekp() only sets the insertion point. + operator<<() calls insert their text at the tellp() + position and keep the rest of the string. tellp() is + then after the inserted text, on the beginning of the + rest of the string. + */ + self & set_insert_mode( + insert_mode i_eMode ); + + void push_front( + const char * i_str ); + void push_front( + char i_c ); + void push_back( + const char * i_str ); + void push_back( + char i_c ); + void pop_front( + size_type i_nCount ); + void pop_back( + size_type i_nCount ); + +//*********** Not yet implemented *********************// + void strip_front( + char i_cToRemove ); + void strip_back( + char i_cToRemove ); + void strip_frontback( + char i_cToRemove ); + void strip_front_whitespace(); /// removes space, tab and crlf. + void strip_back_whitespace(); + void strip_frontback_whitespace(); +//*********** end - not yet implemented *****************// + + void replace( + position_type i_nStart, + size_type i_nSize, + Area i_aReplacement ); + + void replace_all( + char i_cCarToSearch, + char i_cReplacement ); + void replace_all( + Area i_aStrToSearch, + Area i_aReplacement ); + + StreamStr & to_lower( + position_type i_nStart = 0, + size_type i_nLength = str::maxsize ); + StreamStr & to_upper( + position_type i_nStart = 0, + size_type i_nLength = str::maxsize ); + + // INQUIRY + const char * c_str() const; + const char * data() const; + + bool empty() const; + size_type size() const; + size_type length() const; + + size_type capacity() const; + + position_type tellp() const; + + const_iterator begin() const; + const_iterator cur() const; + const_iterator end() const; + + size_type token_count( + char i_cSplit ) const; + String token( + position_type i_nNr, /// Starting with 0. + char i_cSpli ) const; + + // ACCESS + iterator begin(); + iterator cur(); + iterator end(); + + private: + // Interface bostream + virtual UINT32 do_write( + const void * i_pSrc, + UINT32 i_nNrofBytes); + // Locals + void ProvideAddingSize( + size_type i_nSize2Add ); + /// Resizes with the factor 2.0 (under 128), 1.5 or until i_nMinimumCapacity, whatever is bigger. + void Resize( + size_type i_nMinimumCapacity = 0 ); + void Advance( + size_type i_nAddedSize ); + void MoveData( + char * i_pStart, + char * i_pEnd, + seek_type i_nDiff ); + // DATA + size_type nCapacity1; + DYN char * dpData; + char * pEnd; + char * pCur; + insert_mode eMode; +}; + + + +class StreamStrLock +{ + public: + StreamStrLock( + uintt i_nMinimalSize ); + ~StreamStrLock(); + + StreamStr & operator()() { return *pStr; } + + private: + StreamStr * pStr; +}; + + +// IMPLEMENTATION + +inline const char * +StreamStr::operator<<( F_CSTR ) + { return dpData; } +inline void +StreamStr::clear() + { pEnd = pCur = dpData; *pEnd = '\0'; } +inline const char * +StreamStr::c_str() const + { return dpData; } +inline const char * +StreamStr::data() const + { return dpData; } +inline bool +StreamStr::empty() const + { return dpData == pEnd; } +inline StreamStr::size_type +StreamStr::size() const + { return pEnd - dpData; } +inline StreamStr::size_type +StreamStr::length() const + { return size(); } +inline StreamStr::size_type +StreamStr::capacity() const + { return nCapacity1-1; } +inline StreamStr::position_type +StreamStr::tellp() const + { return size_type(pCur-dpData); } +inline StreamStr::const_iterator +StreamStr::begin() const + { return dpData; } +inline StreamStr::const_iterator +StreamStr::cur() const + { return pCur; } +inline StreamStr::const_iterator +StreamStr::end() const + { return pEnd; } +inline StreamStr::iterator +StreamStr::begin() + { return dpData; } +inline StreamStr::iterator +StreamStr::cur() + { return pCur; } +inline StreamStr::iterator +StreamStr::end() + { return pEnd; } + + +} // namespace csv + + + + +#endif + diff --git a/cosv/inc/cosv/string.hxx b/cosv/inc/cosv/string.hxx new file mode 100644 index 000000000000..7baacbd0b77c --- /dev/null +++ b/cosv/inc/cosv/string.hxx @@ -0,0 +1,602 @@ +/************************************************************************* + * + * $RCSfile: string.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef COSV_STRING_HXX +#define COSV_STRING_HXX + + +// USED SERVICES + // BASE CLASSES + // COMPONENTS +#include <cosv/stringdata.hxx> +#include <cosv/str_types.hxx> + // PARAMETERS +#include <string.h> +#include <cosv/csv_ostream.hxx> +#include <vector> + + + +namespace csv +{ + +/** The Simple String: + It is used to just hold short to middle long texts as + data, which are constant at most times. They are reference + counted, so they are space efficient and have constant time + copy semantics. + + For all compare() functions the return value is like in strcmp(). + + @attention + The present version of this class is NOT thread safe. +*/ + + +class String +{ + public: + typedef String self; + + typedef str::size size_type; + typedef str::position position_type; + + typedef const char * const_iterator; + + // LIFECYCLE + String(); + + explicit String( + const char * i_str ); + /// @precond i_nLength <= strlen(i_str) or i_nLength == str::maxsize. + String( + const char * i_str, + size_type i_nLength ); + String( + const self & i_rStr, + position_type i_nStartPosition); + /** @precond i_nLength == str::maxsize + || i_nStartPosition+i_nLength <= i_rStr.Size(). + */ + String( + const self & i_rStr, + position_type i_nStartPosition, + size_type i_nLength ); + /** @precond i_itBegin and i_itEnd are in the same valid + memory-area, such that zero to finite times repetition of + ++i_itBegin leads to i_itBegin == i_itEnd. + */ + String( + const_iterator i_itBegin, + const_iterator i_itEnd ); + + String( + const self & i_rStr ); + + ~String(); + // OPERATORS + self & operator=( + const self & i_rStr ); + self & operator=( + const char * i_str ); + + operator const char * () const; + + const char & operator[]( + position_type i_nPosition ) const; + + bool operator==( + const self & i_rStr ) const; + bool operator!=( + const self & i_rStr ) const; + bool operator<( + const self & i_rStr ) const; + bool operator>( + const self & i_rStr ) const; + bool operator<=( + const self & i_rStr ) const; + bool operator>=( + const self & i_rStr ) const; + + // OPERATIONS + void clear(); + + void swap( + self & i_rStr ); + + void assign( + const self & i_rStr, + position_type i_nStartPosition); + /** @precond i_nLength == str::maxsize + || i_nStartPosition+i_nLength <= i_rStr.Size(). + */ + void assign( + const self & i_rStr, + position_type i_nStartPosition, + size_type i_nLength ); + void assign( + const char * i_str ); + /// @precond i_nLength == str::maxsize OR i_nLength < strlen(i_str) . + void assign( + const char * i_str, + size_type i_nLength ); + /// Create a string consisting of a sequence of i_nCount times the same char. + void assign( + size_type i_nCount, + char i_c ); + /** @precond i_itBegin and i_itEnd are in the same valid + memory-area, such that zero to finite times repetition of + ++i_itBegin leads to i_itBegin == i_itEnd. + */ + void assign( + const_iterator i_itBegin, + const_iterator i_itEnd ); + + // INQUIRY + const char * c_str() const; + const char * data() const; + + bool empty() const; + size_type size() const; + size_type length() const; + + const_iterator begin() const; + + /// This is inefficient, so shouldn't be used within loops. + const_iterator end() const; + + int compare( + const self & i_rStr ) const; + int compare( + const CharOrder_Table & + i_rOrder, + const self & i_rStr ) const; + + self substr( + position_type i_nStartPosition = 0, + size_type i_nLength = str::maxsize ) const; + +//*********** Not yet implemented *********************// + position_type find( + const char * i_strToSearch, + position_type i_nSearchStartPosition = 0 ) const; + position_type find( + char i_charToSearch, + position_type i_nSearchStartPosition = 0 ) const; + + position_type rfind( + const char * i_strToSearch, + position_type i_nSearchStartPosition = str::npos ) const; + position_type rfind( + char i_charToSearch, + position_type i_nSearchStartPosition = str::npos ) const; + + position_type find_first_not_of( + const char * i_strToSearch, + position_type i_nSearchStartPosition = 0 ) const; + position_type find_first_not_of( + char i_charToSearch, + position_type i_nSearchStartPosition = 0 ) const; + + position_type find_last_not_of( + const char * i_strToSearch, + position_type i_nSearchStartPosition = str::npos ) const; + position_type find_last_not_of( + char i_charToSearch, + position_type i_nSearchStartPosition = str::npos ) const; +//*********** end - not yet implemented *****************// + + static const self & Null_(); + static const char & Nulch_(); + + private: + struct S_Data + { + S_Data(); + /// @precond i_nValidLength <= strlen(i_sData) or i_nValidLength == str::maxsize. + S_Data( + const char * i_sData, + size_type i_nValidLength = str::maxsize ); + ~S_Data(); + + const S_Data * Acquire() const; + + /// Deletes this, if nCount becomes 0. + void Release() const; + + StringData<char> aStr; + mutable UINT32 nCount; + + private: + // Forbidden functions, because this is a refcounted structure. + S_Data(const S_Data&); + S_Data & operator=(const S_Data&); + }; + + // Locals + const StringData<char> & + Str() const; + + // DATA + const S_Data * pd; +}; + + +//********** Global compare functions ***************// + + //*** Natural order, no substrings + +inline int compare( + const String & i_s1, + const char * i_s2 ); +inline int compare( + const char * i_s1, + const String & i_s2 ); +inline int compare( + const char * i_s1, + const char * i_s2 ); + + //*** Natural order, substrings + +int compare( + const String & i_s1, + csv::str::position i_nStartPosition1, + const char * i_s2, + csv::str::size i_nLength = csv::str::maxsize ); +int compare( + const char * i_s1, + const String & i_s2, + csv::str::position i_nStartPosition2, + csv::str::size i_nLength = csv::str::maxsize ); +inline int compare( + const char * i_s1, + const char * i_s2, + csv::str::size i_nLength ); + + //*** Defined order, no substrings + +inline int compare( + const CharOrder_Table & i_rOrder, + const String & i_s1, + const char * i_s2 ); +inline int compare( + const CharOrder_Table & i_rOrder, + const char * i_s1, + const String & i_s2 ); +int compare( + const CharOrder_Table & i_rOrder, + const char * i_s1, + const char * i_s2 ); + + //*** Defined order, substrings + +int compare( + const CharOrder_Table & i_rOrder, + const String & i_s1, + csv::str::position i_nStartPosition1, + const char * i_s2, + csv::str::size i_nLength2 = csv::str::maxsize ); +int compare( + const CharOrder_Table & i_rOrder, + const char * i_s1, + const String & i_s2, + csv::str::position i_nStartPosition2, + csv::str::size i_nLength = csv::str::maxsize ); +int compare( + const CharOrder_Table & i_rOrder, + const char * i_s1, + const char * i_s2, + csv::str::size i_nLength ); + +} // namespace csv + + +//****************** global comparation operators *********************// + +inline bool operator==( + const csv::String & i_s1, + const char * i_s2 ); +inline bool operator!=( + const csv::String & i_s1, + const char * i_s2 ); +inline bool operator<( + const csv::String & i_s1, + const char * i_s2 ); +inline bool operator>( + const csv::String & i_s1, + const char * i_s2 ); +inline bool operator<=( + const csv::String & i_s1, + const char * i_s2 ); +inline bool operator>=( + const csv::String & i_s1, + const char * i_s2 ); + +inline bool operator==( + const char * i_s1, + const csv::String & i_s2 ); +inline bool operator!=( + const char * i_s1, + const csv::String & i_s2 ); +inline bool operator<( + const char * i_s1, + const csv::String & i_s2 ); +inline bool operator>( + const char * i_s1, + const csv::String & i_s2 ); +inline bool operator<=( + const char * i_s1, + const csv::String & i_s2 ); +inline bool operator>=( + const char * i_s1, + const csv::String & i_s2 ); + + +//****************** global stream operators *********************// + + +inline csv::ostream & +operator<<( csv::ostream & o_rOut, + const csv::String & i_rSrc ); + + +// IMPLEMENTATION + + +namespace csv +{ + +inline const StringData<char> & +String::Str() const +{ return pd->aStr; } + + +inline const char & +String::operator[]( position_type i_nPosition ) const +{ if ( i_nPosition < Str().Size() ) + return Str().Data()[i_nPosition]; + return Nulch_(); +} + +inline bool +String::operator==( const self & i_rStr ) const +{ return compare(i_rStr) == 0; } + +inline bool +String::operator!=( const self & i_rStr ) const +{ return compare(i_rStr) != 0; } + +inline bool +String::operator<( const self & i_rStr ) const +{ return compare(i_rStr) < 0; } + +inline bool +String::operator>( const self & i_rStr ) const +{ return compare(i_rStr) > 0; } + +inline bool +String::operator<=( const self & i_rStr ) const +{ return compare(i_rStr) <= 0; } + +inline bool +String::operator>=( const self & i_rStr ) const +{ return compare(i_rStr) >= 0; } + +inline void +String::clear() +{ operator=( String::Null_() ); } + +inline const char * +String::c_str() const +{ return Str().Data(); } + +inline +String::operator const char * () const +{ return c_str(); } + +inline const char * +String::data() const +{ return c_str(); } + +inline String::size_type +String::size() const +{ return Str().Size(); } + +inline bool +String::empty() const +{ return size() == 0; } + +inline String::size_type +String::length() const +{ return size(); } + +inline String::const_iterator +String::begin() const +{ return data(); } + +inline String::const_iterator +String::end() const +{ return data() + size(); } + + + +//****************** global compare-functions ********************// +inline int +compare( const String & i_s1, + const char * i_s2 ) +{ return strcmp(i_s1.c_str(), i_s2); } + +inline int +compare( const char * i_s1, + const String & i_s2 ) +{ return strcmp(i_s1, i_s2.c_str()); } + +inline int +compare( const char * i_s1, + const char * i_s2 ) +{ return strcmp(i_s1, i_s2); } + +inline int +compare( const char * i_s1, + const char * i_s2, + str::size i_nLength ) +{ return strncmp( i_s1, i_s2, i_nLength ); } + +inline int +compare( const CharOrder_Table & i_rOrder, + const String & i_s1, + const char * i_s2 ) +{ return compare( i_rOrder, i_s1.c_str(), i_s2 ); } + +inline int +compare( const CharOrder_Table & i_rOrder, + const char * i_s1, + const String & i_s2 ) +{ return compare( i_rOrder, i_s1, i_s2.c_str() ); } + + +} // namespace csv + + +inline bool +operator==( const csv::String & i_s1, + const char * i_s2 ) +{ return csv::compare( i_s1, i_s2 ) == 0; } + +inline bool +operator!=( const csv::String & i_s1, + const char * i_s2 ) +{ return csv::compare( i_s1, i_s2 ) != 0; } + +inline bool +operator<( const csv::String & i_s1, + const char * i_s2 ) +{ return csv::compare( i_s1, i_s2 ) < 0; } + +inline bool +operator>( const csv::String & i_s1, + const char * i_s2 ) +{ return csv::compare( i_s1, i_s2 ) > 0; } + +inline bool +operator<=( const csv::String & i_s1, + const char * i_s2 ) +{ return csv::compare( i_s1, i_s2 ) <= 0; } + +inline bool +operator>=( const csv::String & i_s1, + const char * i_s2 ) +{ return csv::compare( i_s1, i_s2 ) >= 0; } + + +inline bool +operator==( const char * i_s1, + const csv::String & i_s2 ) +{ return csv::compare( i_s1, i_s2 ) == 0; } + +inline bool +operator!=( const char * i_s1, + const csv::String & i_s2 ) +{ return csv::compare( i_s1, i_s2 ) != 0; } + +inline bool +operator<( const char * i_s1, + const csv::String & i_s2 ) +{ return csv::compare( i_s1, i_s2 ) < 0; } + +inline bool +operator>( const char * i_s1, + const csv::String & i_s2 ) +{ return csv::compare( i_s1, i_s2 ) > 0; } + +inline bool +operator<=( const char * i_s1, + const csv::String & i_s2 ) +{ return csv::compare( i_s1, i_s2 ) <= 0; } + +inline bool +operator>=( const char * i_s1, + const csv::String & i_s2 ) +{ return csv::compare( i_s1, i_s2 ) >= 0; } + + + //************ global stream operators **************// + + +inline csv::ostream & +operator<<( csv::ostream & o_rOut, + const csv::String & i_rSrc ) + { o_rOut << i_rSrc.c_str(); return o_rOut; } + + +//****************** typedefs *********************// + + +namespace csv +{ +typedef std::vector<String> StringVector; +} + + + +#endif + + diff --git a/cosv/inc/cosv/stringdata.hxx b/cosv/inc/cosv/stringdata.hxx new file mode 100644 index 000000000000..9d08933a363d --- /dev/null +++ b/cosv/inc/cosv/stringdata.hxx @@ -0,0 +1,169 @@ +/************************************************************************* + * + * $RCSfile: stringdata.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef COSV_STRINGDATA_HXX +#define COSV_STRINGDATA_HXX + + +#include <cosv/str_types.hxx> + + + +namespace csv +{ + +/** @tpl CHAR + The expression CHAR(0) has to be valid. +*/ +template <class CHAR> +class StringData +{ + public: + typedef StringData self; + + typedef str::size size_type; + typedef str::position position_type; + + // LIFECYCLE + StringData(); + /** @precond i_pData != 0 + @precond i_nValidLength <= strlen(i_pData) + */ + StringData( + const CHAR * i_pData, + size_type i_nValidLength ); + ~StringData(); + // OPERATORS + + // OPERATIONS + + // INQUIRY + const CHAR * Data() const; + + /** @returns the allocated number of CHAR. + This may be different from the number of bytes. + There is actually allocated one more CHAR, + which is guaranteed to be CHAR(0) in all circumstances. + */ + size_type Size() const; + + private: + /* Because this is used only within a refcounted structure, + these functions are forbidden - at least yet. + */ + StringData(const self&); + self & operator=(const self&); + + // DATA + DYN CHAR * dpData; + size_type nSize; /// The allocated size - 1 (for the finishing 0). +}; + + + +// IMPLEMENTATION + +template <class CHAR> +StringData<CHAR>::StringData() + : dpData( new CHAR[1] ), + nSize(0) +{ + *dpData = CHAR(0); +} + +template <class CHAR> +StringData<CHAR>::StringData( const CHAR * i_pData, + size_type i_nValidLength ) + : dpData( new CHAR[i_nValidLength + 1] ), + nSize(i_nValidLength) +{ + memcpy( dpData, i_pData, i_nValidLength * sizeof(CHAR) ); + dpData[nSize] = CHAR(0); +} + +template <class CHAR> +StringData<CHAR>::~StringData() +{ + delete [] dpData; +} + +template <class CHAR> +const CHAR * +StringData<CHAR>::Data() const +{ + return dpData; +} + +template <class CHAR> +StringData<CHAR>::size_type +StringData<CHAR>::Size() const +{ + return nSize; +} + + + +} // namespace csv + + +#endif + + diff --git a/cosv/inc/cosv/x.hxx b/cosv/inc/cosv/x.hxx new file mode 100644 index 000000000000..d013d024096b --- /dev/null +++ b/cosv/inc/cosv/x.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * $RCSfile: x.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef CSV_X_HXX +#define CSV_X_HXX + +// USED SERVICES + // BASE CLASSES + // COMPONENTS +#include <cosv/string.hxx> + // PARAMETERS +#include <cosv/csv_ostream.hxx> + + +namespace csv +{ + +class Exception +{ + public: + virtual ~Exception() {} + virtual void GetInfo( + ostream & o_rOutputMedium ) const = 0; +}; + + +class X_Default : public Exception +{ + public: + X_Default( + const char * i_sMessage ) + : sMessage(i_sMessage) {} + virtual void GetInfo( // Implemented in comfunc.cxx + ostream & o_rOutputMedium ) const; + private: + String sMessage; +}; + + +} // namespace csv + + + +#endif + + + |