summaryrefslogtreecommitdiff
path: root/cosv/inc
diff options
context:
space:
mode:
Diffstat (limited to 'cosv/inc')
-rw-r--r--cosv/inc/cosv/bstream.hxx150
-rw-r--r--cosv/inc/cosv/comdline.hxx70
-rw-r--r--cosv/inc/cosv/comfunc.hxx125
-rw-r--r--cosv/inc/cosv/commandline.hxx180
-rw-r--r--cosv/inc/cosv/csv_env.hxx154
-rw-r--r--cosv/inc/cosv/csv_ostream.hxx134
-rw-r--r--cosv/inc/cosv/csv_precomp.h46
-rw-r--r--cosv/inc/cosv/datetime.hxx84
-rw-r--r--cosv/inc/cosv/dirchain.hxx180
-rw-r--r--cosv/inc/cosv/file.hxx137
-rw-r--r--cosv/inc/cosv/mbstream.hxx93
-rw-r--r--cosv/inc/cosv/openclose.hxx144
-rw-r--r--cosv/inc/cosv/persist.hxx105
-rw-r--r--cosv/inc/cosv/ploc.hxx129
-rw-r--r--cosv/inc/cosv/ploc_dir.hxx118
-rw-r--r--cosv/inc/cosv/plocroot.hxx80
-rw-r--r--cosv/inc/cosv/std_outp.hxx136
-rw-r--r--cosv/inc/cosv/str_types.hxx94
-rw-r--r--cosv/inc/cosv/streamstr.hxx391
-rw-r--r--cosv/inc/cosv/string.hxx579
-rw-r--r--cosv/inc/cosv/stringdata.hxx135
-rw-r--r--cosv/inc/cosv/tpl/dyn.hxx238
-rw-r--r--cosv/inc/cosv/tpl/funcall.hxx307
-rw-r--r--cosv/inc/cosv/tpl/processor.hxx183
-rw-r--r--cosv/inc/cosv/tpl/range.hxx191
-rw-r--r--cosv/inc/cosv/tpl/swelist.hxx369
-rw-r--r--cosv/inc/cosv/tpl/tpltools.hxx228
-rw-r--r--cosv/inc/cosv/tpl/vvector.hxx539
-rw-r--r--cosv/inc/cosv/x.hxx71
29 files changed, 5390 insertions, 0 deletions
diff --git a/cosv/inc/cosv/bstream.hxx b/cosv/inc/cosv/bstream.hxx
new file mode 100644
index 000000000000..0d27c438988a
--- /dev/null
+++ b/cosv/inc/cosv/bstream.hxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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..99c036cfb271
--- /dev/null
+++ b/cosv/inc/cosv/comdline.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_COMDLINE_HXX
+#define CSV_COMDLINE_HXX
+// KORR_DEPRECATED_3.0
+// Replace by cosv/commandline.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..ce78c72d4656
--- /dev/null
+++ b/cosv/inc/cosv/comfunc.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_COMFUNC_HXX
+#define CSV_COMFUNC_HXX
+
+#include <stdlib.h>
+
+
+
+
+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);
+
+class noncopyable
+{
+ protected:
+ noncopyable() {}
+ ~noncopyable() {}
+ private:
+ // Private to make copying impossible:
+ noncopyable(const noncopyable&);
+ noncopyable & operator=(const noncopyable&);
+};
+
+
+
+
+// IMPLEMENTATION
+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_cast< char* >(&o_rNumber);
+ const char * pBack = reinterpret_cast< const char* >(&i_rNumber) + sizeof(NUMTYPE);
+
+ for ( size_t p = 0; p < sizeof(NUMTYPE); --p )
+ {
+ *pFront++ = *(--pBack);
+ }
+}
+
+
+} // namespace csv
+
+
+
+
+#define NON_COPYABLE(xy) \
+ private: xy(const xy &); xy & operator=(const xy &)
+
+
+
+
+#endif
diff --git a/cosv/inc/cosv/commandline.hxx b/cosv/inc/cosv/commandline.hxx
new file mode 100644
index 000000000000..b5fd6a4e0cdc
--- /dev/null
+++ b/cosv/inc/cosv/commandline.hxx
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_COMMANDLINE_HXX
+#define CSV_COMMANDLINE_HXX
+
+#include <cosv/string.hxx>
+
+
+
+
+namespace csv
+{
+
+/** Does the standards in handling command line parameters.
+
+ This class provides a default behaviour this way:
+
+ * Each option can have several forms
+
+ like: "-f" and "--file"
+
+ which are identified by having the same id.
+ The option id is used when calling ->do_HandleOption().
+
+ * For each recognized option together with its parameters
+ ->do_HandleOption() is called.
+
+ * For the first unrecognized argument ->do_HandleFreeArgument() is
+ called.
+ After the first unrecognized argument, ->do_HandleFreeArgument()
+ is called for all remaining arguments.
+
+ @howtoderive
+ - Overwrite ->do_HandleOption() to act on all known options.
+ Overwrite ->do_HandleFreeArgument() to act on additional
+ arguments not connected to an option.
+*/
+class CommandLine
+{
+ public:
+ // LIFECYCLE
+ virtual ~CommandLine() {}
+
+ // OPERATIONS
+ bool Interpret(
+ int argc,
+ char * argv[] );
+ // INQUIRY
+ const StringVector &
+ Arguments() const;
+ bool IsOk() const;
+
+ protected:
+ CommandLine();
+ void Add_Option(
+ intt i_id,
+ String i_text );
+ void Set_Error();
+
+ private:
+ // public for use by struct commandline.cxx-anonymous::FindOptionByText;
+ struct OptionDescription
+ {
+ intt nId;
+ String sText;
+
+ OptionDescription(
+ intt i_id,
+ String i_text );
+ }; private:
+
+ struct FindOptionByText;
+
+ typedef std::vector<OptionDescription> OptionList;
+ typedef std::vector<StringVector::const_iterator> StringCIteratorList;
+ typedef std::vector<intt> OptionIdList;
+
+ // Locals
+ void Get_Arguments(
+ int argc,
+ char * argv[] );
+ intt Find_Option(
+ const String & i_text ) const;
+ bool Store_Argument(
+ const String & i_arg );
+ void Find_OptionPoints();
+ void Handle_FreeArguments(
+ StringVector::const_iterator
+ i_begin,
+ StringVector::const_iterator
+ i_end );
+
+ // Helpers for options included via file
+ bool Try2Include_Options(
+ const String & i_optionsFile );
+ bool Include_Options(
+ const String & i_optionsFile );
+ bool Load_Options(
+ StreamStr & o_text,
+ const String & i_optionsFile );
+
+ /** Handles an option found in the command line.
+ Needs to be overwritten.
+
+ @return
+ The first argument within the range
+ i_next_argument .. i_comandLine_end that does not belong as a
+ parameter to the handled option.
+ */
+ virtual StringVector::const_iterator
+ do_HandleOption(
+ intt i_id,
+ StringVector::const_iterator
+ i_paramsBegin,
+ StringVector::const_iterator
+ i_paramsEnd ) = 0;
+ /** Handles arguments on the command line that do not belong to
+ an option.
+ */
+ virtual void do_HandleFreeArgument(
+ const String & i_argument ) = 0;
+ // DATA
+ OptionList aOptions;
+
+ /// Used during and after ->GetArguments()
+ StringVector aCommandLine;
+ StringCIteratorList aOptionPoints;
+ OptionIdList aOptionIds;
+ bool bIsOk;
+};
+
+
+inline const StringVector &
+CommandLine::Arguments() const
+{
+ return aCommandLine;
+}
+
+inline bool
+CommandLine::IsOk() const
+{
+ return bIsOk;
+}
+
+inline void
+CommandLine::Set_Error()
+{
+ bIsOk = false;
+}
+
+
+
+
+} // 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..d6feb055c0f2
--- /dev/null
+++ b/cosv/inc/cosv/csv_env.hxx
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_CSV_ENV_HXX
+#define CSV_CSV_ENV_HXX
+
+
+
+//******* Include c-language-types ************//
+// size_t, wchar_t
+#include <stdlib.h>
+
+
+
+//******* 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; // standard sized integer.
+typedef UINT32 uintt; // standard sized unsigned integer.
+typedef REAL64 real; // standard sized 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
+
+#ifdef CSV_USE_CSV_ASSERTIONS
+#define csv_assert(x) ( (x) ? (void)(0) : ::csv::PerformAssertion( #x, __FILE__, __LINE__) )
+#else
+
+// Save NDEBUG state
+#ifdef NDEBUG
+#define CSV_CSV_ENV_HXX_HAD_NDEBUG
+#undef NDEBUG
+#endif
+
+#if OSL_DEBUG_LEVEL == 0
+#define NDEBUG
+#endif
+#include <assert.h>
+
+#define csv_assert(x) assert(x);
+
+// Restore NDEBUG state
+#ifdef CSV_CSV_ENV_HXX_HAD_NDEBUG
+#define NDEBUG
+#else
+#undef NDEBUG
+#endif
+
+#endif
+
+#else // #ifndef CSV_NO_ASSERTIONS else
+
+#define csv_assert(x)
+
+#endif // end ifndef CSV_NO_ASSERTIONS 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.
+ - pass_ := 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_'.
+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..7e657f875eb9
--- /dev/null
+++ b/cosv/inc/cosv/csv_ostream.hxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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/tpl/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..d6dd85c53084
--- /dev/null
+++ b/cosv/inc/cosv/csv_precomp.h
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __CSV_PRECOMP_H_06071998__
+#define __CSV_PRECOMP_H_06071998__
+
+
+
+
+#define CSV_USE_CSV_ASSERTIONS
+#include <cosv/csv_env.hxx>
+
+#include <cosv/comfunc.hxx>
+#include <cosv/string.hxx>
+#include <cosv/streamstr.hxx>
+#include <cosv/std_outp.hxx>
+#include <cosv/tpl/dyn.hxx>
+
+
+
+
+#endif
diff --git a/cosv/inc/cosv/datetime.hxx b/cosv/inc/cosv/datetime.hxx
new file mode 100644
index 000000000000..ee773df66380
--- /dev/null
+++ b/cosv/inc/cosv/datetime.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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..e62af1d1a8a4
--- /dev/null
+++ b/cosv/inc/cosv/dirchain.hxx
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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/tpl/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 );
+ DirectoryChain & operator-=(
+ uintt i_nLevelsUp );
+
+ // 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 DirectoryChain &
+DirectoryChain::operator-=( uintt i_nLevelsUp )
+ { PopBack(i_nLevelsUp); 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..7039964769ad
--- /dev/null
+++ b/cosv/inc/cosv/file.hxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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..0778d8333952
--- /dev/null
+++ b/cosv/inc/cosv/mbstream.hxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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..2f3ade89440a
--- /dev/null
+++ b/cosv/inc/cosv/openclose.hxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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 =
+ static_cast< UINT32 >(rwReadWrite) | static_cast< UINT32 >(omCreate);
+const UINT32 CFM_READ =
+ static_cast< UINT32 >(rwRead) | static_cast< UINT32 >(omCreateNot) |
+ static_cast< UINT32 >(shmShareRead);
+
+
+
+class OpenClose
+{
+ public:
+ virtual ~OpenClose() {}
+
+ 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()
+ { if (rOpenClose.is_open()) 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..11b198fe6ac2
--- /dev/null
+++ b/cosv/inc/cosv/persist.hxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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 all pathes without completing delimiter, even directories.
+ 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..f00321d81948
--- /dev/null
+++ b/cosv/inc/cosv/ploc.hxx
@@ -0,0 +1,129 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_PLOC_HXX
+#define CSV_PLOC_HXX
+
+// USED SERVICES
+#include <cosv/string.hxx>
+#include <cosv/plocroot.hxx>
+#include <cosv/dirchain.hxx>
+#include <cosv/tpl/dyn.hxx>
+#include <cosv/csv_ostream.hxx>
+
+
+
+
+namespace csv
+{
+ class bostream;
+
+namespace ploc
+{
+ class Root;
+
+
+/** Represents a path in the file system.
+
+ The path can be relative or absolute and in Unix- or Windows-syntax.
+*/
+class Path
+{
+ public:
+
+ // LIFECYCLE
+ explicit 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 * FileExtension() const;
+ bool IsValid() const;
+ bool IsDirectory() const { return sFile.length() == 0; }
+ bool IsFile() const { return sFile.length() > 0; }
+
+ /// Directories have a delimiter at the end, files not.
+ void Get(
+ ostream & o_rPath ) const;
+ /// Directories have a delimiter at the end, files not.
+ void Get(
+ bostream & o_rPath ) const;
+ // ACCESS
+ DirectoryChain & DirChain() { return aPath; }
+
+ private:
+ Dyn<Root> pRoot;
+ DirectoryChain aPath;
+ String sFile;
+};
+
+
+
+
+} // namespace ploc
+} // namespace csv
+
+
+
+/// Directories produce a delimiter at the end, files not.
+inline csv::ostream &
+operator<<( csv::ostream & o_rOut,
+ const csv::ploc::Path & i_rPath )
+{
+ i_rPath.Get(o_rOut);
+ return o_rOut;
+}
+
+/// Directories produce a delimiter at the end, files not.
+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..2e133307ea72
--- /dev/null
+++ b/cosv/inc/cosv/ploc_dir.hxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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 ) const;
+
+ // 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() const;
+ 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..e83327fab876
--- /dev/null
+++ b/cosv/inc/cosv/plocroot.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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..705aa8312a02
--- /dev/null
+++ b/cosv/inc/cosv/std_outp.hxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_STD_OUTP_HXX
+#define CSV_STD_OUTP_HXX
+
+// USED SERVICES
+ // BASE CLASSES
+ // COMPONENTS
+#include <cosv/csv_ostream.hxx>
+ // PARAMETERS
+
+
+
+
+namespace csv
+{
+
+#ifdef CSV_NO_IOSTREAMS
+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_;
+};
+#endif // defined(CSV_NO_IOSTREAMS)
+
+
+inline ostream &
+Cout()
+{
+
+#ifndef CSV_NO_IOSTREAMS
+// return redirect_out::useme_()
+// ? (ostream&)( redirect_out::std_() )
+// : (ostream&)( std::cout );
+ return (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 );
+ return (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 );
+ (*i_fFlushingFunc)( io_rStream, false, 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..1eb9d5ad9729
--- /dev/null
+++ b/cosv/inc/cosv/str_types.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef COSV_STR_TYPES_HXX
+#define COSV_STR_TYPES_HXX
+
+
+namespace csv
+{
+
+/** Provides some generally used constants.
+*/
+struct str
+{
+ public:
+ typedef ::size_t position;
+ typedef ::size_t size;
+
+ enum constants
+ {
+ npos = position(-1),
+ maxsize = size(-1)
+ };
+
+ enum insert_mode
+ {
+ overwrite = 0,
+ insert = 1
+ };
+};
+
+
+/** Is used for string comparisons.
+
+ @collab String
+ @collab various csv::compare(...) functions
+*/
+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[ UINT8(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..d61fbc6edf22
--- /dev/null
+++ b/cosv/inc/cosv/streamstr.hxx
@@ -0,0 +1,391 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_STREAMSTR_HXX
+#define CSV_STREAMSTR_HXX
+
+// BASE CLASSES
+#include <cosv/bstream.hxx>
+// USED SERVICES
+#include <cosv/str_types.hxx>
+#include <string.h>
+
+
+
+
+namespace csv
+{
+ class String;
+
+
+void c_str(); // Dummy needed for StreamStr::operator<<(StreamStr::F_CSTR);
+
+
+/** A string buffer class for all kinds of string manipulation.
+*/
+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)();
+
+
+ /** Represents an area within a string.
+ */
+ 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 .
+ StreamStr(
+ csv::bstream & i_source );
+ /// Copies also insert_mode and current position.
+ StreamStr(
+ const self & i_rOther );
+ ~StreamStr();
+
+ // OPERATORS
+ /// Copies also insert_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 );
+
+ /** This operator is used to finish a sequence of streaming
+ oeprators by returning the c-string of the complete string.
+
+ @return The same as ->c_str().
+
+ @example
+ csv::StreamStr s(100);
+ const char *
+ fullname = s << qualifier() << "::" << name() << csv::c_str;
+ */
+ 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();
+ void swap(
+ StreamStr & io_swap );
+
+ /** 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 );
+ self & reset() { return seekp(0); }
+ /** Sets the insertion mode of all and only the operator<<() calls.
+
+ Default is str::overwrite:
+ 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 );
+
+ /// Works like operator<<(). Does the same as Perl's join().
+ self & operator_join(
+ std::vector<String>::const_iterator
+ i_rBegin,
+ std::vector<String>::const_iterator
+ i_rEnd,
+ const char * i_sLink );
+ /// Works like operator<<()
+ self & operator_add_substr(
+ const char * i_sText,
+ size_type i_nLength );
+ /// Works like operator<<()
+ self & operator_add_token(
+ const char * i_sText,
+ char i_cDelimiter );
+ /// Works like operator<<()
+ self & operator_read_line(
+ bstream & i_src );
+
+ 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();
+
+ /** @precond i_begin is valid
+ @precond i_end is valid
+ @precond i_end >= i_begin
+ */
+ void remove(
+ iterator i_begin,
+ iterator i_end );
+ 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; /// Capacity of characters to contain + 1 for terminating 0.
+ 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;
+};
+
+/** Splits a string into tokens by whitespace.
+
+ The tokens are added to the end of o_list.
+*/
+void Split(
+ std::vector<String> &
+ o_list,
+ const char * i_text );
+inline void Join(
+ StreamStr & o_text,
+ std::vector<String> &
+ i_list,
+ const char * i_sLink = " ");
+
+// 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; }
+
+inline void
+Join( StreamStr & o_text,
+ std::vector<String> & i_list,
+ const char * i_sLink )
+{
+ o_text.operator_join(i_list.begin(),i_list.end(),i_sLink);
+}
+
+
+
+
+} // namespace csv
+#endif
diff --git a/cosv/inc/cosv/string.hxx b/cosv/inc/cosv/string.hxx
new file mode 100644
index 000000000000..bba6af8e6b3b
--- /dev/null
+++ b/cosv/inc/cosv/string.hxx
@@ -0,0 +1,579 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef COSV_STRING_HXX
+#define COSV_STRING_HXX
+
+// USED SERVICES
+#include <cosv/stringdata.hxx>
+#include <cosv/str_types.hxx>
+#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();
+
+ /// Intentionally not explicit, smooth casting is intended.
+ 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 );
+ /** @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;
+
+ 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 );
+
+ /** @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 char & char_at(
+ position_type i_nPosition ) 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;
+
+ /** @param i_strToSearch [i_strToSearch != 0]
+ i_strToSearch == "" will return npos.
+ */
+ 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;
+
+//*********** Not yet implemented *********************//
+ 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.
+ explicit 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 String & i_s2 );
+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 );
+int compare(
+ const char * i_s1,
+ const String & i_s2,
+ csv::str::position i_nStartPosition2,
+ csv::str::size i_nLength );
+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 );
+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 );
+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::char_at( 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 String & i_s2 )
+{ return i_s1.compare(i_s2); }
+
+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..fec8ed0126f6
--- /dev/null
+++ b/cosv/inc/cosv/stringdata.hxx
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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>
+typename StringData<CHAR>::size_type
+StringData<CHAR>::Size() const
+{
+ return nSize;
+}
+
+
+
+} // namespace csv
+
+
+#endif
+
+
diff --git a/cosv/inc/cosv/tpl/dyn.hxx b/cosv/inc/cosv/tpl/dyn.hxx
new file mode 100644
index 000000000000..ab305b264ae8
--- /dev/null
+++ b/cosv/inc/cosv/tpl/dyn.hxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_DYN_HXX
+#define CSV_DYN_HXX
+
+
+
+
+namespace csv
+{
+
+
+/** Dyn owns an object on the heap, which will be automatically
+ deleted in its D'tor.
+
+ Dyn's main purpose is for class members on the heap:
+ You can't forget to delete them in the D'tor. Constness will be transfered
+ to the hold object.
+
+ Dyn forbids the CopyC'tor and operator=(). So you can't incidentally
+ run into problems with compiler defined CopyC'tor or operator=() of the
+ owning class. If you need those, you have to define them explicitely - as
+ you should do anyway with all classes, that own members on the heap.
+
+ Dyn also works with incomplete types.
+ You only need to write
+ class DX;
+ but needn't include #include <DX>.hxx.
+ This is a difference to std::auto_ptr, where it is not absolutely clear
+ if it is allowed to use it with incomplete types.
+
+ You can also use Dyn within function bodies, to make them exception safe.
+
+ @attention
+ If you use Dyn with an incomplete type, the owning class needs to
+ define a non-inline D'tor. Else the compiler will complain.
+*/
+template <class DX>
+class Dyn
+{
+ public:
+ // LIFECYCLE
+ /// From now on, let_dpObject is owned by this Dyn-object.
+ explicit Dyn(
+ DX * let_dpObject = 0);
+ ~Dyn();
+ // OPERATORS
+ /** This deletes a prevoiusly existing dpObject!
+ From now on, let_dpObject is owned by this Dyn-object.
+ */
+ Dyn<DX> & operator=(
+ DX * let_dpObject);
+ /// @return true, if any valid object is hold, false else.
+ operator bool() const;
+
+ const DX * operator->() const;
+ DX * operator->();
+
+ const DX & operator*() const;
+ DX & operator*();
+
+ // OPERATIONS
+ /** @return The hold object on the heap.
+
+ @ATTENTION
+ The caller of the function is responsible to delete
+ the returned object
+
+ @postcond
+ this->dpObject == 0.
+ */
+ DX * Release();
+
+ // INQUIRY
+ /// Shorthand for operator->(), if implicit overloading of -> can not be used.
+ const DX * Ptr() const;
+
+ // ACCESS
+ /// Shorthand for operator->(), if implicit overloading of -> can not be used.
+ DX * Ptr();
+ /// So const objects can return mutable pointers to the owned object.
+ DX * MutablePtr() const;
+
+ private:
+ /* Does NOT set dpObject to zero! Because it is only used
+ internally in situations where dpObject is set immediately
+ after.
+ */
+ void Delete();
+
+ /** Forbidden function!
+ -------------------
+ Help ensure, that classes with
+ dynamic pointers use a selfdefined copy constructor
+ and operator=(). If the default versions of these
+ functions are used, the compiler will throw an error.
+ **/
+ Dyn( const Dyn<DX> & );
+ /** Forbidden function!
+ -------------------
+ Help ensure, that classes with
+ dynamic pointers use a selfdefined copy constructor
+ and operator=(). If the default versions of these
+ functions are used, the compiler will throw an error.
+ **/
+ Dyn<DX> & operator=( const Dyn<DX> & );
+
+ // DATA
+ /// An owned heap object. Needs to be deleted by this class.
+ DX * dpObject;
+};
+
+
+
+
+// IMPLEMENTATION
+template <class DX>
+void
+Dyn<DX>::Delete()
+{
+ if (dpObject != 0)
+ delete dpObject;
+}
+
+template <class DX>
+inline
+Dyn<DX>::Dyn( DX * let_dpObject )
+ : dpObject(let_dpObject) {}
+
+template <class DX>
+inline
+Dyn<DX>::~Dyn()
+{ Delete(); }
+
+
+template <class DX>
+inline Dyn<DX> &
+Dyn<DX>::operator=( DX * let_dpObject )
+{
+ if ( dpObject == let_dpObject )
+ return *this;
+
+ Delete();
+ dpObject = let_dpObject;
+ return *this;
+}
+
+template <class DX>
+inline
+Dyn<DX>::operator bool() const
+{ return dpObject != 0; }
+
+template <class DX>
+inline
+const DX *
+Dyn<DX>::operator->() const
+{ return dpObject; }
+
+template <class DX>
+inline DX *
+Dyn<DX>::operator->()
+{ return dpObject; }
+
+template <class DX>
+inline const DX &
+Dyn<DX>::operator*() const
+{ csv_assert(dpObject != 0);
+ return *dpObject;
+}
+
+template <class DX>
+inline DX &
+Dyn<DX>::operator*()
+{ csv_assert(dpObject != 0);
+ return *dpObject;
+}
+
+template <class DX>
+inline DX *
+Dyn<DX>::Release()
+{ DX * ret = dpObject;
+ dpObject = 0;
+ return ret;
+}
+
+template <class DX>
+inline const DX *
+Dyn<DX>::Ptr() const
+{ return dpObject; }
+
+template <class DX>
+inline DX *
+Dyn<DX>::Ptr()
+{ return dpObject; }
+
+template <class DX>
+inline DX *
+Dyn<DX>::MutablePtr() const
+{ return dpObject; }
+
+} // namespace csv
+
+
+
+
+#ifndef CSV_HIDE_DYN
+#define Dyn ::csv::Dyn
+#endif
+
+
+
+
+#endif
diff --git a/cosv/inc/cosv/tpl/funcall.hxx b/cosv/inc/cosv/tpl/funcall.hxx
new file mode 100644
index 000000000000..03ff8a3bba55
--- /dev/null
+++ b/cosv/inc/cosv/tpl/funcall.hxx
@@ -0,0 +1,307 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_TPL_FUNCALL_HXX
+#define CSV_TPL_FUNCALL_HXX
+
+// BASE CLASSES
+#include <algorithm>
+
+
+
+
+namespace csv
+{
+namespace func
+{
+
+
+/** @concept "csv:: Function Objects"
+
+ A set of function objects that can be generated from any kind of
+ function or member function with none or one parameter by the
+ helper function ->make_func().
+
+ Naming Scheme
+ =============
+
+ The naming scheme consists of three variables
+ f - the kind of function
+ p - the parameter of the function
+ c - call operator() of the function object with these arguments
+
+ Each of those may have the following values:
+ f:
+ f - free, no owning class
+ c - const member function of a class
+ m - modifying member function of a class
+ p:
+ n - no parameter
+ c - const parameter by reference
+ m - modifyable parameter by reference,
+ v - parameter by value
+ c:
+ n - none
+ o - the owning object on which the function shall be called
+ a - the argument of the function
+ b - both, the object on which the function shall be called
+ and the argument of the function
+
+ Which gives the following 35 possible combinations:
+ ff_pn_cn
+ ff_pc_cn
+ ff_pc_ca
+ ff_pm_cn
+ ff_pm_ca
+ ff_pv_cn
+ ff_pv_ca
+
+ fc_pn_cn
+ fc_pn_co
+ fc_pc_cn
+ fc_pc_co
+ fc_pc_ca
+ fc_pc_cb
+ fc_pm_cn
+ fc_pm_co
+ fc_pm_ca
+ fc_pm_cb
+ fc_pv_cn
+ fc_pv_co
+ fc_pv_ca
+ fc_pv_cb
+
+ fm_pn_cn
+ fm_pn_co
+ fm_pc_cn
+ fm_pc_co
+ fm_pc_ca
+ fm_pc_cb
+ fm_pm_cn
+ fm_pm_co
+ fm_pm_ca
+ fm_pm_cb
+ fm_pv_cn
+ fm_pv_co
+ fm_pv_ca
+ fm_pv_cb
+
+ These function objects are complicate to handle, so they can be created
+ with the overloaded function
+ <function_object> csv::make_func(<function_type>, <argument_types>);
+
+ For the rare, but possible case that the owning class and the function
+ argument have the same type, these clarifying variations to make_func()
+ can be used:
+ make_func_callwith_obj(), make_func_callwith_arg().
+*/
+
+
+/** Function object.
+
+ @concept ->"csv::func Function Objects"
+ @see csv::make_func()
+*/
+template <class R>
+struct ff_pn_cn
+{
+ typedef R result_type;
+ typedef R (* function_type )();
+
+ R operator()() const
+ { return (*f)(); }
+
+ ff_pn_cn(
+ function_type i_f)
+ : f(i_f) {}
+ private:
+ function_type f;
+};
+
+
+/** Function object.
+
+ @concept ->"csv::func Function Objects"
+ @see csv::make_func()
+*/
+template <class R, class C>
+struct fc_pn_co
+{
+ typedef R result_type;
+ typedef R (C::* function_type )() const;
+
+ R operator()(
+ const C & i_c ) const
+ { return (i_c.*f)(); }
+
+ fc_pn_co(
+ function_type i_f)
+ : f(i_f) {}
+ private:
+ function_type f;
+};
+
+
+
+/** Function object.
+
+ @concept ->"csv::func Function Objects"
+ @see csv::make_func()
+*/
+template <class R, class C, class P>
+struct fc_pm_co
+{
+ typedef R result_type;
+ typedef R (C::* function_type )(P&) const;
+
+ R operator()(
+ const C & i_c ) const
+ { return (i_c.*f)(p); }
+
+ fc_pm_co(
+ function_type i_f,
+ P & i_p)
+ : f(i_f), p(i_p) {}
+ private:
+ function_type f;
+ P & p;
+};
+
+
+
+
+
+
+
+} // namespace func
+
+
+/** Creates a function object of type ff_pn_cn.
+ @concept ->"csv::func Function Objects"
+*/
+template <class R>
+inline func::ff_pn_cn<R>
+make_func( R(*i_f)() )
+{
+ return func::ff_pn_cn<R>(i_f);
+}
+
+///** Creates a function object of type ff_py_cn.
+// @concept ->"csv::func Function Objects"
+//*/
+//template <class R, class P>
+//inline func::ff_py_cn<R,P>
+//make_func( R(*i_f)(P), P i_p )
+//{
+// return func::ff_py_cn<R,A>(i_f, i_p);
+//}
+//
+///** Creates a function object of type ff_py_ca.
+// @concept ->"csv::func Function Objects"
+//*/
+//template <class R, class P>
+//inline func::ff_py_ca<R,P>
+//make_func( R(*i_f)(P) )
+//{
+// return func::ff_py_ca<R,P>(i_f);
+//}
+
+
+/** Creates a function object of type fc_pn_co.
+ @concept ->"csv::func Function Objects"
+*/
+template <class R, class C>
+inline func::fc_pn_co<R,C>
+make_func( R(C::*i_f)() const )
+{
+ return func::fc_pn_co<R,C>(i_f);
+}
+
+
+
+/** Creates a function object of type fc_pm_co.
+ @concept ->"csv::func Function Objects"
+*/
+template <class R, class C, class P>
+inline func::fc_pm_co<R,C,P>
+make_func( R(C::*i_f)(P &) const, P & i_p)
+{
+ return func::fc_pm_co<R,C,P>(i_f, i_p);
+}
+
+
+
+/* Because std::for_each is defined as a non-modifying algorithm
+ it is redefined here. It is also provided for containers.
+*/
+
+template <class I, class F>
+F
+for_each(I i_itBegin, I i_itEnd, F io_functionToBeCalled)
+{
+ for (I it = i_itBegin; it != i_itEnd; ++it)
+ {
+ io_functionToBeCalled(*it);
+ }
+ return io_functionToBeCalled;
+}
+
+template <class C, class F>
+F
+for_each_in(const C & i_container, F io_functionToBeCalled)
+{
+ typename C::const_iterator const
+ itEnd = i_container.end();
+ for ( typename C::const_iterator it = i_container.begin();
+ it != itEnd;
+ ++it )
+ {
+ io_functionToBeCalled(*it);
+ }
+ return io_functionToBeCalled;
+}
+
+template <class C, class F>
+F
+for_each_in(C & i_container, F io_functionToBeCalled)
+{
+ typename C::iterator const
+ itEnd = i_container.end();
+ for ( typename C::iterator it = i_container.begin();
+ it != itEnd;
+ ++it )
+ {
+ io_functionToBeCalled(*it);
+ }
+ return io_functionToBeCalled;
+}
+
+
+
+
+} // namespace csv
+#endif
diff --git a/cosv/inc/cosv/tpl/processor.hxx b/cosv/inc/cosv/tpl/processor.hxx
new file mode 100644
index 000000000000..fc9a8277568a
--- /dev/null
+++ b/cosv/inc/cosv/tpl/processor.hxx
@@ -0,0 +1,183 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_TPL_PROCESSOR_HXX
+#define CSV_TPL_PROCESSOR_HXX
+
+// USED SERVICES
+
+
+
+
+namespace csv
+{
+
+
+/** Implements an acyclic visitor pattern. This is the abstract
+ base for the classes doing the work (the "visitors").
+*/
+class ProcessorIfc
+{
+ public:
+ virtual ~ProcessorIfc() {}
+};
+
+
+
+/** Implements an acyclic visitor pattern. This is the abstract
+ base for the classes to be processed (the "visitables").
+*/
+class ConstProcessorClient
+{
+ public:
+ virtual ~ConstProcessorClient() {}
+
+ void Accept(
+ ProcessorIfc & io_processor ) const
+ { do_Accept(io_processor); }
+ private:
+ virtual void do_Accept(
+ ProcessorIfc & io_processor ) const = 0;
+};
+
+/** Implements an acyclic visitor pattern. This is the abstract
+ base for the classes to be processed (the "visitables").
+*/
+class ProcessorClient
+{
+ public:
+ virtual ~ProcessorClient() {}
+
+ void Accept(
+ ProcessorIfc & io_processor )
+ { do_Accept(io_processor); }
+ private:
+ virtual void do_Accept(
+ ProcessorIfc & io_processor ) = 0;
+};
+
+
+
+
+
+/** Typed base for "visitor" classes, leaving the visited
+ object const.
+
+ @see ProcessorIfc
+ @see Processor<>
+*/
+template <typename X, typename R = void>
+class ConstProcessor
+{
+ public:
+ virtual ~ConstProcessor() {}
+
+ R Process(
+ const X & i_object )
+ { return do_Process(i_object ); }
+ private:
+ virtual R do_Process(
+ const X & i_object ) = 0;
+};
+
+
+/** Typed base for "visitor" classes which may change the visited
+ object.
+
+ @see ProcessorIfc
+ @see ConstProcessor<>
+*/
+template <typename X, typename R = void>
+class Processor
+{
+ public:
+ virtual ~Processor() {}
+
+ R Process(
+ X & i_object )
+ { return do_Process(i_object ); }
+ private:
+ virtual R do_Process(
+ X & i_object ) = 0;
+};
+
+
+template <class C>
+inline void
+CheckedCall( ProcessorIfc & io_processor,
+ const C & i_client )
+{
+ ConstProcessor<C> *
+ pProcessor = dynamic_cast< csv::ConstProcessor<C> * >
+ (&io_processor);
+ if (pProcessor != 0)
+ pProcessor->Process(i_client);
+}
+
+template <class C>
+inline void
+CheckedCall( ProcessorIfc & io_processor,
+ C & io_client )
+{
+ Processor<C> *
+ pProcessor = dynamic_cast< csv::Processor<C> * >
+ (&io_processor);
+ if (pProcessor != 0)
+ pProcessor->Process(io_client);
+}
+
+template <class C>
+inline void
+AssertedCall( ProcessorIfc & io_processor,
+ const C & i_client )
+{
+ ConstProcessor<C> *
+ pProcessor = dynamic_cast< csv::ConstProcessor<C> * >
+ (&io_processor);
+ csv_assert( pProcessor != 0
+ && "csv::AssertedCall() failed. Processed object did not match processor." );
+ pProcessor->Process(i_client);
+}
+
+template <class C>
+inline void
+AssertedCall( ProcessorIfc & io_processor,
+ C & io_client )
+{
+ Processor<C> *
+ pProcessor = dynamic_cast< csv::Processor<C> * >
+ (&io_processor);
+ csv_assert( pProcessor != 0
+ && "csv::AssertedCall() failed. Processed object did not match processor." );
+ pProcessor->Process(io_client);
+}
+
+
+
+
+} // namespace csv
+#endif
diff --git a/cosv/inc/cosv/tpl/range.hxx b/cosv/inc/cosv/tpl/range.hxx
new file mode 100644
index 000000000000..ea6ce84fa480
--- /dev/null
+++ b/cosv/inc/cosv/tpl/range.hxx
@@ -0,0 +1,191 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_RANGE_HXX
+#define CSV_RANGE_HXX
+
+#include <cstring> // for std::size_t
+
+
+
+
+namespace csv
+{
+
+
+/** Represents a range of integer or iterator values.
+
+ @tpl T
+ Has to be assignable, add- and subtractable. That is:
+ either it is
+ - an integral type
+ - or a random access iterator.
+*/
+template <class T>
+class range
+{
+ public:
+ typedef T element_type; /// Provided for generic programming.
+ typedef range<T> self;
+
+ // LIFECYCLE
+ range(
+ T i_inclusiveLowerBorder,
+ T i_exclusiveUpperBorder );
+ ~range();
+ // INQUIRY
+ T begin() const;
+ T end() const;
+ std::size_t size() const;
+
+ bool contains(
+ T i_value ) const;
+ bool contains(
+ const self & i_other ) const;
+ bool overlaps(
+ const self & i_other ) const;
+ /// @return i_other.begin() - this->end()
+ long distance_to(
+ const self & i_other ) const;
+ private:
+ // DATA
+ T nBegin;
+ T nEnd;
+};
+
+
+template <class T>
+inline range<T>
+make_range(T i1, T i2)
+{
+ return range<T>(i1, i2);
+}
+
+template <class T>
+inline range<typename T::const_iterator>
+range_of(const T & i_container)
+{
+ return make_range( i_container.begin(),
+ i_container.end()
+ );
+}
+
+template <class T>
+inline range<typename T::iterator>
+range_of(T & io_container)
+{
+ return make_range( io_container.begin(),
+ io_container.end()
+ );
+}
+
+
+
+
+
+// IMPLEMENTATION
+
+template <class T>
+range<T>::range( T i_inclusiveLowerBorder,
+ T i_exclusiveUpperBorder )
+ : nBegin(i_inclusiveLowerBorder),
+ nEnd(i_exclusiveUpperBorder)
+{
+ csv_assert( nBegin <= nEnd
+ && "Invalid parameters for range<> constructor.");
+}
+
+template <class T>
+range<T>::~range()
+{
+}
+
+template <class T>
+inline T
+range<T>::begin() const
+{
+ return nBegin;
+}
+
+template <class T>
+inline T
+range<T>::end() const
+{
+ return nEnd;
+}
+
+template <class T>
+inline std::size_t
+range<T>::size() const
+{
+ csv_assert( nBegin <= nEnd
+ && "Invalid range limits in range<>::size().");
+ return static_cast<std::size_t>( end() - begin() );
+}
+
+template <class T>
+bool
+range<T>::contains(T i_value ) const
+{
+ return begin() <= i_value
+ && i_value < end();
+}
+
+template <class T>
+bool
+range<T>::contains(const self & i_other) const
+{
+ // This is subtle, because this would be wrong:
+ // begin() <= i_other.begin()
+ // && i_other.end() <= end();
+ // An empty range that begins and starts at my end()
+ // must not be contained.
+
+ return contains(i_other.begin())
+ && i_other.end() <= end();
+}
+
+template <class T>
+bool
+range<T>::overlaps(const self & i_other) const
+{
+ return contains(i_other.begin())
+ || i_other.contains(begin());
+}
+
+template <class T>
+long
+range<T>::distance_to(const self & i_other) const
+{
+ return i_other.begin() - end();
+}
+
+
+
+
+} // namespace csv
+#endif
diff --git a/cosv/inc/cosv/tpl/swelist.hxx b/cosv/inc/cosv/tpl/swelist.hxx
new file mode 100644
index 000000000000..0a56fae1e16e
--- /dev/null
+++ b/cosv/inc/cosv/tpl/swelist.hxx
@@ -0,0 +1,369 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_SWELIST_HXX
+#define CSV_SWELIST_HXX
+
+// USED SERVICES
+ // BASE CLASSES
+ // COMPONENTS
+ // PARAMETERS
+#include <cosv/tpl/dyn.hxx>
+
+
+namespace csv
+{
+
+
+template <class XX>
+class SweListElement
+{
+ public:
+ typedef SweListElement<XX> self;
+
+ SweListElement(
+ const XX & in_aObj )
+ : aObj(in_aObj), pNext(0) {}
+
+ const XX & Obj() const { return aObj; }
+ XX & Obj() { return aObj; }
+ self * Next() const { return pNext; }
+
+ void SetNext(
+ self * i_pNext )
+ { pNext = i_pNext; }
+ private:
+ XX aObj;
+ self * pNext;
+};
+
+
+
+template <class XX> class SweListIterator;
+template <class XX> class SweListCIterator;
+
+
+template <class XX>
+class SweList
+{
+ public:
+ // TYPES
+ typedef SweList<XX> self;
+ typedef XX value_type;
+ typedef SweListIterator<XX> iterator;
+ typedef SweListCIterator<XX> const_iterator;
+ private:
+ typedef SweListElement<XX> elem;
+
+ public:
+ // LIFECYCLE
+ SweList() : pTop(0), pTail(0) {}
+ ~SweList() { erase_all(); }
+ // OPERATIONS
+ void push_front(
+ const XX & i_aObj );
+ void pop_front();
+ void push_back(
+ const XX & i_aObj );
+ void erase_all();
+
+ // INQUIRY
+ const_iterator begin() const { return pTop; }
+ iterator begin() { return pTop; }
+ const_iterator end() const { return (elem*)0; }
+ iterator end() { return (elem*)0; }
+ const XX & front() const { return pTop->Obj(); }
+ XX & front() { return pTop->Obj(); }
+ const XX & back() const { return pTail->Obj(); }
+ XX & back() { return pTail->Obj(); }
+
+ bool empty() const { return pTop == 0; }
+ uintt size() const;
+
+
+ private:
+ // Forbiddden methods.
+ SweList(
+ const self & i_rList );
+ self & operator=(
+ const self & i_rList );
+
+ // DATA
+ DYN elem * pTop;
+ elem * pTail;
+};
+
+template <class XX>
+class SweList_dyn
+{
+ public:
+ // TYPES
+ typedef SweList_dyn<XX> self;
+ typedef SweListElement< XX* > elem;
+ typedef SweListIterator< XX* > iterator;
+
+ // LIFECYCLE
+ SweList_dyn() : pTop(0), pTail(0) {}
+ ~SweList_dyn() { erase_all(); }
+ // OPERATIONS
+ void push_front(
+ XX * i_pObj );
+ void push_back(
+ XX * i_pObj );
+ void pop_front();
+ void erase_all();
+
+ // INQUIRY
+ iterator begin() const { return pTop; }
+ iterator end() const { return (elem*)0; }
+ XX * front() const { return pTop->Obj(); }
+ XX * back() const { return pTail->Obj(); }
+
+ bool empty() const { return pTop == 0; }
+ uintt size() const;
+
+ private:
+ // Forbiddden methods.
+ SweList_dyn(
+ const self & i_rList );
+ self & operator=(
+ const self & i_rList );
+
+ DYN elem * pTop;
+ elem * pTail;
+};
+
+
+
+
+template<class XX>
+class SweListIterator
+{
+ public:
+ typedef SweListIterator<XX> self;
+ typedef SweListElement<XX> elem;
+
+ SweListIterator(
+ elem * i_pElem = 0)
+ : pElem(i_pElem) { }
+
+ // OPERATORS
+ XX & operator*() const { return pElem->Obj(); }
+ self & operator++() { if (pElem != 0) pElem = pElem->Next();
+ return *this; }
+ bool operator==(
+ const self & i_rIter ) const
+ { return pElem == i_rIter.pElem; }
+ bool operator!=(
+ const self & i_rIter ) const
+ { return pElem != i_rIter.pElem; }
+ private:
+ friend class SweListCIterator<XX>;
+
+ elem * pElem;
+};
+
+template<class XX>
+class SweListCIterator
+{
+ public:
+ typedef SweListCIterator<XX> self;
+ typedef SweListElement<XX> elem;
+
+ SweListCIterator(
+ const elem * i_pElem = 0)
+ : pElem(i_pElem) { }
+
+ // OPERATORS
+ self & operator=(
+ const SweListIterator<XX> &
+ i_rIter )
+ { pElem = i_rIter.pElem; return *this; }
+
+ const XX & operator*() const { return pElem->Obj(); }
+ self & operator++() { if (pElem != 0) pElem = pElem->Next();
+ return *this; }
+ bool operator==(
+ const self & i_rIter ) const
+ { return pElem == i_rIter.pElem; }
+ bool operator!=(
+ const self & i_rIter ) const
+ { return pElem != i_rIter.pElem; }
+ private:
+ const elem * pElem;
+};
+
+// Implementierung
+
+template <class XX>
+void
+SweList<XX>::push_front( const XX & i_aObj )
+{
+ DYN elem * dpNew = new elem(i_aObj);
+ dpNew->SetNext(pTop);
+ pTop = dpNew;
+ if (pTail == 0)
+ pTail = pTop;
+}
+
+template <class XX>
+void
+SweList<XX>::push_back( const XX & i_aObj)
+{
+ if (pTail != 0)
+ {
+ pTail->SetNext(new elem(i_aObj));
+ pTail = pTail->Next();
+ }
+ else
+ {
+ pTop = pTail = new elem(i_aObj);
+ }
+}
+
+template <class XX>
+void
+SweList<XX>::pop_front()
+{
+ if (pTop != 0)
+ {
+ elem * pDel = pTop;
+ pTop = pTop->Next();
+ delete pDel;
+ if (pTop == 0)
+ pTail = 0;
+ }
+}
+
+template <class XX>
+uintt
+SweList<XX>::size() const
+{
+ uintt ret = 0;
+ for ( const_iterator iter = begin();
+ iter != end();
+ ++iter )
+ {
+ ++ret;
+ }
+ return ret;
+}
+
+
+template <class XX>
+void
+SweList<XX>::erase_all()
+{
+ for (pTail = pTop ; pTop != 0; pTail = pTop)
+ {
+ pTop = pTop->Next();
+ delete pTail;
+ }
+ pTop = pTail = 0;
+}
+
+
+template <class XX>
+void
+SweList_dyn<XX>::push_front( XX * i_pObj )
+{
+ DYN elem * dpNew = new elem(i_pObj);
+ dpNew->SetNext(pTop);
+ pTop = dpNew;
+ if (pTail == 0)
+ pTail = pTop;
+}
+
+template <class XX>
+void
+SweList_dyn<XX>::push_back( XX * i_pObj )
+{
+ if (pTail != 0)
+ {
+ pTail->SetNext(new elem(i_pObj));
+ pTail = pTail->Next();
+ }
+ else
+ {
+ pTop = pTail = new elem(i_pObj);
+ }
+}
+
+template <class XX>
+void
+SweList_dyn<XX>::pop_front()
+{
+ if (pTop != 0)
+ {
+ elem * pDel = pTop;
+ pTop = pTop->Next();
+ if (pDel->Obj() != 0)
+ Delete_dyn(pDel->Obj());
+ delete pDel;
+ if (pTop == 0)
+ pTail = 0;
+ }
+}
+
+
+template <class XX>
+void
+SweList_dyn<XX>::erase_all()
+{
+ for (pTail = pTop ; pTop != 0; pTail = pTop)
+ {
+ pTop = pTop->Next();
+ if (pTail->Obj() != 0)
+ {
+ delete pTail->Obj();
+ }
+ delete pTail;
+ }
+ pTop = pTail = 0;
+}
+
+template <class XX>
+uintt
+SweList_dyn<XX>::size() const
+{
+ uintt ret = 0;
+ for ( iterator iter = begin();
+ iter != end();
+ ++iter )
+ {
+ ++ret;
+ }
+ return ret;
+}
+
+
+} // namespace csv
+
+
+#endif
+
+
diff --git a/cosv/inc/cosv/tpl/tpltools.hxx b/cosv/inc/cosv/tpl/tpltools.hxx
new file mode 100644
index 000000000000..98d5190310d9
--- /dev/null
+++ b/cosv/inc/cosv/tpl/tpltools.hxx
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_TPLTOOLS_HXX
+#define CSV_TPLTOOLS_HXX
+
+#include <vector>
+#include <map>
+
+
+
+
+namespace csv
+{
+
+
+template <class COLLECTION>
+inline void erase_container(
+ COLLECTION & o_rCollection );
+
+/// Version for std::map
+template <class COLLECTION>
+void erase_map_of_heap_ptrs(
+ COLLECTION & o_rCollection );
+
+/// Version for other containers than std::map, with non-pair value_type.
+template <class COLLECTION>
+void erase_container_of_heap_ptrs(
+ COLLECTION & o_rCollection );
+
+template <class VECTOR_ELEM>
+void adjust_vector_size(
+ std::vector<VECTOR_ELEM> &
+ io_rVector,
+ uintt i_nSize,
+ const VECTOR_ELEM & i_nFill );
+
+
+template <class KEY, class VAL>
+const VAL * find_in_map( /// Usable for all kinds of values
+ const std::map< KEY, VAL > &
+ i_rMap,
+ const KEY & i_rKey );
+
+
+/** @return the value in the map, if it is in there, else 0.
+ @precond VAL has to be convertable to "0".
+*/
+template <class KEY, class VAL>
+VAL value_from_map(
+ const std::map< KEY, VAL > &
+ i_rMap,
+ const KEY & i_rKey );
+
+/** @return the value in the map, if it is in there, else i_notFound.
+*/
+template <class KEY, class VAL>
+VAL value_from_map(
+ const std::map< KEY, VAL > &
+ i_rMap,
+ const KEY & i_rKey,
+ VAL i_notFound );
+
+template <class COLLECTION, class VALUE>
+bool contains(
+ const COLLECTION & i_collection,
+ const VALUE & i_value );
+
+// Object oriented for_each:
+template <class COLLECTION, class CLASS, class MEMFUNC>
+void call_for_each(
+ const COLLECTION & i_rList,
+ CLASS * io_pThis,
+ MEMFUNC i_fMethod );
+
+
+
+
+// IMPLEMENTATION
+template <class COLLECTION>
+inline void
+erase_container( COLLECTION & o_rCollection )
+{
+ o_rCollection.erase( o_rCollection.begin(),
+ o_rCollection.end() );
+}
+
+template <class COLLECTION>
+void
+erase_map_of_heap_ptrs( COLLECTION & o_rCollection )
+{
+ typename COLLECTION::iterator itEnd = o_rCollection.end();
+ for ( typename COLLECTION::iterator it = o_rCollection.begin();
+ it != itEnd;
+ ++it )
+ {
+ delete (*it).second;
+ }
+
+ o_rCollection.erase( o_rCollection.begin(),
+ o_rCollection.end() );
+}
+
+template <class COLLECTION>
+void
+erase_container_of_heap_ptrs( COLLECTION & o_rCollection )
+{
+ typename COLLECTION::iterator itEnd = o_rCollection.end();
+ for ( typename COLLECTION::iterator it = o_rCollection.begin();
+ it != itEnd;
+ ++it )
+ {
+ delete *it;
+ }
+
+ o_rCollection.erase( o_rCollection.begin(),
+ o_rCollection.end() );
+}
+
+template <class VECTOR_ELEM>
+void
+adjust_vector_size( std::vector<VECTOR_ELEM> & io_rVector,
+ uintt i_nSize,
+ const VECTOR_ELEM & i_nFill )
+{
+ if ( io_rVector.size() > i_nSize )
+ {
+ io_rVector.erase( io_rVector.begin() + i_nSize, io_rVector.end() );
+ }
+ else
+ {
+ io_rVector.reserve(i_nSize);
+ while ( io_rVector.size() < i_nSize )
+ io_rVector.push_back(i_nFill);
+ }
+}
+
+
+template <class KEY, class VAL>
+const VAL *
+find_in_map( const std::map< KEY, VAL > & i_rMap,
+ const KEY & i_rKey )
+{
+ typename std::map< KEY, VAL >::const_iterator
+ ret = i_rMap.find(i_rKey);
+ return ret != i_rMap.end()
+ ? & (*ret).second
+ : (const VAL*)0;
+}
+
+template <class KEY, class VAL>
+VAL
+value_from_map( const std::map< KEY, VAL > & i_rMap,
+ const KEY & i_rKey )
+{
+ typename std::map< KEY, VAL >::const_iterator
+ ret = i_rMap.find(i_rKey);
+ return ret != i_rMap.end()
+ ? (*ret).second
+ : VAL(0);
+}
+
+template <class KEY, class VAL>
+VAL
+value_from_map( const std::map< KEY, VAL > & i_rMap,
+ const KEY & i_rKey,
+ VAL i_notFound )
+{
+ typename std::map< KEY, VAL >::const_iterator
+ ret = i_rMap.find(i_rKey);
+ return ret != i_rMap.end()
+ ? (*ret).second
+ : i_notFound;
+}
+
+template <class COLLECTION, class VALUE>
+bool
+contains( const COLLECTION & i_collection,
+ const VALUE & i_value )
+{
+ return std::find(i_collection.begin(), i_collection.end(), i_value)
+ !=
+ i_collection.end();
+}
+
+template <class COLLECTION, class CLASS, class MEMFUNC>
+void
+call_for_each( const COLLECTION & i_rList,
+ CLASS * io_pThis,
+ MEMFUNC i_fMethod )
+{
+ typename COLLECTION::const_iterator it = i_rList.begin();
+ typename COLLECTION::const_iterator itEnd = i_rList.end();
+ for ( ; it != itEnd; ++it )
+ {
+ (io_pThis->*i_fMethod)(*it);
+ }
+}
+
+
+
+
+} // namespace csv
+#endif
diff --git a/cosv/inc/cosv/tpl/vvector.hxx b/cosv/inc/cosv/tpl/vvector.hxx
new file mode 100644
index 000000000000..312a79d4f229
--- /dev/null
+++ b/cosv/inc/cosv/tpl/vvector.hxx
@@ -0,0 +1,539 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CSV_VVECTOR_HXX
+#define CSV_VVECTOR_HXX
+
+// USED SERVICES
+#include <vector>
+#include <cosv/tpl/tpltools.hxx>
+
+
+
+
+namespace csv
+{
+namespace vvector
+{
+
+
+template <class TYPE>
+struct delete_ptrs
+{
+ static void Destruct(
+ std::vector< TYPE* > &
+ v)
+ { csv::erase_container_of_heap_ptrs(v); }
+
+ /// @precond ->it is a valid iterator within v
+ static void Erase(
+ std::vector< TYPE* > &
+ v,
+ typename std::vector< TYPE* >::iterator
+ it2erase )
+ { delete *it2erase; v.erase(it2erase); }
+
+ /// @precond ->v.size() > 0
+ static void PopBack(
+ std::vector< TYPE* > &
+ v )
+ { delete v.back(); v.pop_back(); }
+
+ /// @precond ->it is a valid iterator
+ static void ReplacePtr(
+ typename std::vector< TYPE* >::iterator
+ it,
+ DYN TYPE * pass_new )
+ { delete *it; *it = pass_new; }
+};
+
+
+/** One helper class for the ->csv::VirtualVector.
+ Implements a
+*/
+template <class TYPE>
+struct keep_ptrs
+{
+ static void Destruct(std::vector< TYPE* > & v)
+ {}
+
+ static void Erase(
+ std::vector< TYPE* > &
+ v,
+ typename std::vector< TYPE* >::iterator
+ it2erase )
+ { v.erase(it2erase); }
+
+ static void PopBack(
+ std::vector< TYPE* > &
+ v )
+ { v.pop_back(); }
+
+ /// @precond ->it is a valid iterator
+ static void ReplacePtr(
+ typename std::vector< TYPE* >::iterator
+ it,
+ TYPE * io_new )
+ { *it = io_new; }
+};
+
+
+} // namespace vvector
+
+
+
+
+/** Implements a vector of different implementations of a base
+ class.
+
+ Implementation has to be by pointers to get the polymorphic
+ behaviour, however access is by references to the base class.
+
+ @tpl XX
+ The common base class of vector elements.
+
+ @tpl PTRDEL
+ Has two possible values:
+ vvector::delete_ptrs<XX> Elements have to be on the heap and
+ are deleted when removed (default).
+ vvector::keep_ptrs<XX> Elements are only referenced and not
+ deleted when removed.
+
+*/
+template <class XX, class PTRDEL = vvector::delete_ptrs<XX> >
+class VirtualVector
+{
+ public:
+ typedef VirtualVector<XX,PTRDEL> self;
+ typedef std::vector< DYN XX* > impl_type;
+ typedef typename impl_type::size_type size_type;
+ typedef ptrdiff_t difference_type;
+
+ class const_iterator;
+ class iterator;
+
+ // LIFECYCLE
+ VirtualVector();
+ explicit VirtualVector(
+ int i_size );
+ ~VirtualVector();
+
+ // OPERATORS
+ const XX & operator[](
+ size_type i_pos ) const;
+ XX & operator[](
+ size_type i_pos );
+
+ // OPERATIONS
+ void push_back(
+ DYN XX & i_drElement );
+ void pop_back();
+
+ iterator insert(
+ iterator i_pos,
+ DYN XX & i_drElement );
+ void erase(
+ iterator i_pos );
+ void replace(
+ iterator i_pos,
+ DYN XX & i_drElement );
+ void reserve(
+ size_type i_size );
+
+ // INQUIRY
+ bool empty() const;
+ size_t size() const;
+ const_iterator begin() const;
+ const_iterator end() const;
+ const XX & front() const;
+ const XX & back() const;
+
+ // ACCESS
+ iterator begin();
+ iterator end();
+ XX & front();
+ XX & back();
+
+ private:
+ // Forbidden:
+ VirtualVector(const VirtualVector&);
+ VirtualVector & operator=(const VirtualVector&);
+
+ // DATA
+ std::vector< DYN XX* >
+ aData;
+};
+
+
+
+
+/** Should be usable for all STL algorithms.
+ Implements the Random Access Iterator concept.
+*/
+template <class XX, class PTRDEL>
+class VirtualVector<XX,PTRDEL>::
+ const_iterator
+
+ // This derivation provides type information for the STL
+ // It introduces the types "value_type" and "difference_type".
+ : public std::iterator<std::random_access_iterator_tag,
+ const XX>
+{
+ public:
+ typedef VirtualVector<XX,PTRDEL> my_container;
+ typedef typename my_container::impl_type::const_iterator impl_iterator;
+
+ // LIFECYCLE
+ const_iterator(
+ impl_iterator i_implIter )
+ : itImpl(i_implIter) {}
+
+
+ /////////// STL ITERATOR CONCEPT IMPLEMENTATION //////////////
+
+ // Default Constructible functions:
+ const_iterator()
+ : itImpl() {}
+
+ // Assignable functions:
+ // Assignment and copy constructor use the compiler generated versions.
+
+ // Equality Comparable functions:
+ bool operator==(
+ const_iterator i_other ) const
+ { return itImpl == i_other.itImpl; }
+ bool operator!=(
+ const_iterator i_other ) const
+ { return itImpl != i_other.itImpl; }
+
+ // Trivial Iterator functions:
+ const XX & operator*() const
+ { return *(*itImpl); }
+
+ // Input Iterator functions:
+ const_iterator & operator++()
+ { ++itImpl; return *this; }
+ const_iterator operator++(int)
+ { return const_iterator(itImpl++); }
+
+ // Bidirectional Iterator functions:
+ const_iterator & operator--()
+ { --itImpl; return *this; }
+ const_iterator operator--(int)
+ { return const_iterator(itImpl--); }
+
+ // Less Than Comparable functions:
+ bool operator<(
+ const_iterator i_other ) const
+ { return itImpl < i_other.itImpl; }
+
+ // Random Access Iterator functions:
+ const_iterator & operator+=(
+ difference_type i_diff )
+ { itImpl += i_diff; return *this; }
+ const_iterator operator+(
+ difference_type i_diff ) const
+ { const_iterator ret(itImpl);
+ return ret += i_diff; }
+ const_iterator & operator-=(
+ difference_type i_diff )
+ { itImpl -= i_diff; return *this; }
+ const_iterator operator-(
+ difference_type i_diff ) const
+ { const_iterator ret(itImpl);
+ return ret -= i_diff; }
+ difference_type operator-(
+ const_iterator i_it ) const
+ { return itImpl - i_it.itImpl; }
+ const XX & operator[](
+ difference_type i_index )
+ { return *(*itImpl[i_index]); }
+
+ //////////////////////////////////////////////////////////////////////////
+
+ private:
+ friend class VirtualVector<XX,PTRDEL>;
+ impl_iterator ImplValue() const { return itImpl; }
+
+ // DATA
+ impl_iterator itImpl;
+};
+
+
+
+
+/** Should be usable for all STL algorithms.
+ Implements the Random Access Iterator concept.
+*/
+template <class XX, class PTRDEL>
+class VirtualVector<XX,PTRDEL>::
+ iterator
+
+ // This derivation provides type information for the STL
+ // It introduces the types "value_type" and "difference_type".
+ : public std::iterator<std::random_access_iterator_tag,
+ XX>
+{
+ public:
+ typedef VirtualVector<XX,PTRDEL> my_container;
+ typedef typename my_container::impl_type::iterator impl_iterator;
+
+ // LIFECYCLE
+ iterator(
+ impl_iterator i_implIter )
+ : itImpl(i_implIter) {}
+
+
+ /////////// STL ITERATOR CONCEPT IMPLEMENTATION //////////////
+
+ // Default Constructible functions:
+ iterator()
+ : itImpl() {}
+
+ // Assignable functions:
+ // Assignment and copy constructor use the compiler generated versions.
+
+ // Equality Comparable functions:
+ bool operator==(
+ iterator i_other ) const
+ { return itImpl == i_other.itImpl; }
+ bool operator!=(
+ iterator i_other ) const
+ { return itImpl != i_other.itImpl; }
+
+ // Trivial Iterator functions:
+ XX & operator*() const
+ { return *(*itImpl); }
+
+ // Input Iterator functions:
+ iterator & operator++()
+ { ++itImpl; return *this; }
+ iterator operator++(int)
+ { return iterator(itImpl++); }
+
+ // Bidirectional Iterator functions:
+ iterator & operator--()
+ { --itImpl; return *this; }
+ iterator operator--(int)
+ { return iterator(itImpl--); }
+
+ // Less Than Comparable functions:
+ bool operator<(
+ iterator i_other ) const
+ { return itImpl < i_other.itImpl; }
+
+ // Random Access Iterator functions:
+ iterator & operator+=(
+ difference_type i_diff )
+ { itImpl += i_diff; return *this; }
+ iterator operator+(
+ difference_type i_diff ) const
+ { iterator ret(itImpl);
+ return ret += i_diff; }
+ iterator & operator-=(
+ difference_type i_diff )
+ { itImpl -= i_diff; return *this; }
+ iterator operator-(
+ difference_type i_diff ) const
+ { iterator ret(itImpl);
+ return ret -= i_diff; }
+ difference_type operator-(
+ iterator i_it ) const
+ { return itImpl - i_it.itImpl; }
+ XX & operator[](
+ difference_type i_index )
+ { return *(*itImpl[i_index]); }
+
+ //////////////////////////////////////////////////////////////////////////
+
+ private:
+ friend class VirtualVector<XX,PTRDEL>;
+ impl_iterator ImplValue() const { return itImpl; }
+
+ // DATA
+ impl_iterator itImpl;
+};
+
+
+
+
+// IMPLEMENTATION
+template <class XX, class PTRDEL>
+inline
+VirtualVector<XX,PTRDEL>::VirtualVector()
+ : aData()
+{
+}
+
+template <class XX, class PTRDEL>
+inline
+VirtualVector<XX,PTRDEL>::VirtualVector(int i_size)
+ : aData(i_size, 0)
+{
+}
+
+template <class XX, class PTRDEL>
+inline
+VirtualVector<XX,PTRDEL>::~VirtualVector()
+{
+ PTRDEL::Destruct(aData);
+}
+
+template <class XX, class PTRDEL>
+inline const XX &
+VirtualVector<XX,PTRDEL>::operator[]( size_type i_pos ) const
+{
+ return *aData[i_pos];
+}
+
+template <class XX, class PTRDEL>
+inline XX &
+VirtualVector<XX,PTRDEL>::operator[]( size_type i_pos )
+{
+ return *aData[i_pos];
+}
+
+template <class XX, class PTRDEL>
+inline void
+VirtualVector<XX,PTRDEL>::push_back( DYN XX & i_drElement )
+{
+ aData.push_back(&i_drElement);
+}
+
+template <class XX, class PTRDEL>
+inline void
+VirtualVector<XX,PTRDEL>::pop_back()
+{
+ if (NOT aData.empty())
+ PTRDEL::PopBack(aData);
+}
+
+template <class XX, class PTRDEL>
+inline typename VirtualVector<XX,PTRDEL>::iterator
+VirtualVector<XX,PTRDEL>::insert( iterator i_pos,
+ DYN XX & i_drElement )
+{
+ return iterator(aData.insert(i_pos.ImplValue(), &i_drElement));
+}
+
+template <class XX, class PTRDEL>
+inline void
+VirtualVector<XX,PTRDEL>::erase( iterator i_pos )
+{
+ PTRDEL::Erase(aData, i_pos.ImplValue());
+}
+
+template <class XX, class PTRDEL>
+inline void
+VirtualVector<XX,PTRDEL>::replace( iterator i_pos,
+ DYN XX & i_drElement )
+{
+ PTRDEL::ReplacePtr(*i_pos, &i_drElement);
+}
+
+template <class XX, class PTRDEL>
+inline void
+VirtualVector<XX,PTRDEL>::reserve( size_type i_size )
+{
+ aData.reserve(i_size);
+}
+
+template <class XX, class PTRDEL>
+inline bool
+VirtualVector<XX,PTRDEL>::empty() const
+{
+ return aData.empty();
+}
+
+template <class XX, class PTRDEL>
+inline size_t
+VirtualVector<XX,PTRDEL>::size() const
+{
+ return aData.size();
+}
+
+template <class XX, class PTRDEL>
+inline typename VirtualVector<XX,PTRDEL>::const_iterator
+VirtualVector<XX,PTRDEL>::begin() const
+{
+ return const_iterator(aData.begin());
+}
+
+template <class XX, class PTRDEL>
+inline typename VirtualVector<XX,PTRDEL>::const_iterator
+VirtualVector<XX,PTRDEL>::end() const
+{
+ return const_iterator(aData.end());
+}
+
+template <class XX, class PTRDEL>
+inline const XX &
+VirtualVector<XX,PTRDEL>::front() const
+{
+ return *aData.front();
+}
+
+template <class XX, class PTRDEL>
+inline const XX &
+VirtualVector<XX,PTRDEL>::back() const
+{
+ return *aData.back();
+}
+
+template <class XX, class PTRDEL>
+inline typename VirtualVector<XX,PTRDEL>::iterator
+VirtualVector<XX,PTRDEL>::begin()
+{
+ return iterator(aData.begin());
+}
+
+template <class XX, class PTRDEL>
+inline typename VirtualVector<XX,PTRDEL>::iterator
+VirtualVector<XX,PTRDEL>::end()
+{
+ return iterator(aData.end());
+}
+
+template <class XX, class PTRDEL>
+inline XX &
+VirtualVector<XX,PTRDEL>::front()
+{
+ return *aData.front();
+}
+
+template <class XX, class PTRDEL>
+inline XX &
+VirtualVector<XX,PTRDEL>::back()
+{
+ return *aData.back();
+}
+
+
+
+
+} // namespace csv
+#endif
diff --git a/cosv/inc/cosv/x.hxx b/cosv/inc/cosv/x.hxx
new file mode 100644
index 000000000000..a2532ab3cee3
--- /dev/null
+++ b/cosv/inc/cosv/x.hxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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
+
+
+