diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-05-06 21:02:03 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-06-04 12:01:12 +0200 |
commit | 7a5a19218707ab580d58a3fbadec1148368661f1 (patch) | |
tree | 94137a4084019d6cfadac34f31351375a05c10b9 /cosv | |
parent | be49d3a25bc867c4f523cc6ff51ed2e8df9211d7 (diff) |
remove cosv, udm and autodoc
implementing UNO IDL support in doxygen: 9 days of work
converting IDL file comments to doxygen: 5 days of work
removing 57k lines of unmaintained buggy
autodoc, bespoke String and File classes: priceless
Change-Id: I566edb4f91454baa35e07d901432a8dfd35b9c29
Diffstat (limited to 'cosv')
-rw-r--r-- | cosv/Makefile | 7 | ||||
-rw-r--r-- | cosv/Module_cosv.mk | 19 | ||||
-rw-r--r-- | cosv/README | 3 | ||||
-rw-r--r-- | cosv/StaticLibrary_cosv.mk | 29 | ||||
-rw-r--r-- | cosv/source/comphelp/badcast.cxx | 43 | ||||
-rw-r--r-- | cosv/source/service/comdline.cxx | 57 | ||||
-rw-r--r-- | cosv/source/service/comfunc.cxx | 48 | ||||
-rw-r--r-- | cosv/source/service/csv_ostream.cxx | 90 | ||||
-rw-r--r-- | cosv/source/service/std_outp.cxx | 78 | ||||
-rw-r--r-- | cosv/source/storage/dirchain.cxx | 116 | ||||
-rw-r--r-- | cosv/source/storage/file.cxx | 191 | ||||
-rw-r--r-- | cosv/source/storage/persist.cxx | 103 | ||||
-rw-r--r-- | cosv/source/storage/ploc.cxx | 129 | ||||
-rw-r--r-- | cosv/source/storage/ploc_dir.cxx | 359 | ||||
-rw-r--r-- | cosv/source/storage/plocroot.cxx | 525 | ||||
-rw-r--r-- | cosv/source/strings/str_types.cxx | 44 | ||||
-rw-r--r-- | cosv/source/strings/streamstr.cxx | 606 | ||||
-rw-r--r-- | cosv/source/strings/string.cxx | 235 | ||||
-rw-r--r-- | cosv/source/unittest/file_ut.cxx | 121 | ||||
-rw-r--r-- | cosv/source/unittest/string_ut.cxx | 71 | ||||
-rw-r--r-- | cosv/source/unittest/ut.hxx | 46 | ||||
-rw-r--r-- | cosv/source/unittest/ut_main.cxx | 47 |
22 files changed, 0 insertions, 2967 deletions
diff --git a/cosv/Makefile b/cosv/Makefile deleted file mode 100644 index ccb1c85a04da..000000000000 --- a/cosv/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- - -module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) - -include $(module_directory)/../solenv/gbuild/partial_build.mk - -# vim: set noet sw=4 ts=4: diff --git a/cosv/Module_cosv.mk b/cosv/Module_cosv.mk deleted file mode 100644 index 31351a6aa484..000000000000 --- a/cosv/Module_cosv.mk +++ /dev/null @@ -1,19 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -$(eval $(call gb_Module_Module,cosv)) - -ifneq (,$(filter ODK,$(BUILD_TYPE))) - -$(eval $(call gb_Module_add_targets,cosv,\ - StaticLibrary_cosv \ -)) - -endif - -# vim:set noet sw=4 ts=4: diff --git a/cosv/README b/cosv/README deleted file mode 100644 index 6f0df4c23787..000000000000 --- a/cosv/README +++ /dev/null @@ -1,3 +0,0 @@ -"Common Services" part of autodoc. - -Part of the SDK; to build you need to add --enable-odk. diff --git a/cosv/StaticLibrary_cosv.mk b/cosv/StaticLibrary_cosv.mk deleted file mode 100644 index 9c2ad6b4bcf7..000000000000 --- a/cosv/StaticLibrary_cosv.mk +++ /dev/null @@ -1,29 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_StaticLibrary_StaticLibrary,cosv)) - -$(eval $(call gb_StaticLibrary_add_exception_objects,cosv,\ - cosv/source/comphelp/badcast \ - cosv/source/service/comdline \ - cosv/source/service/comfunc \ - cosv/source/service/csv_ostream \ - cosv/source/service/std_outp \ - cosv/source/storage/dirchain \ - cosv/source/storage/file \ - cosv/source/storage/persist \ - cosv/source/storage/ploc \ - cosv/source/storage/ploc_dir \ - cosv/source/storage/plocroot \ - cosv/source/strings/streamstr \ - cosv/source/strings/string \ - cosv/source/strings/str_types \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/cosv/source/comphelp/badcast.cxx b/cosv/source/comphelp/badcast.cxx deleted file mode 100644 index 09afc27ddfc0..000000000000 --- a/cosv/source/comphelp/badcast.cxx +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - - -/* Include this for instantiating bad-cast, - due to problems with WNT-STL-headers. -*/ - -// If anybody who happens to read this has any idea what dark magic -// this is supposed to achieve, and whether it is needed or in any way -// relevant with MSVC2008 (or eventually newer), please add a -// comment... - -#if defined(WNT) && !defined(__MINGW32__) - -#define _NTSDK -#include<typeinfo> - -_STD_BEGIN -bad_cast G_Dummy_Inst_bad_cast; -_STD_END -#endif // WNT - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/service/comdline.cxx b/cosv/source/service/comdline.cxx deleted file mode 100644 index 7f3188eb3a4f..000000000000 --- a/cosv/source/service/comdline.cxx +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/comdline.hxx> - -// NOT FULLY DECLARED SERVICES - - -namespace csv -{ - - -bool -CommandLine_Ifc::CheckParameters() const -{ - if ( NOT inq_CheckParameters() ) - { - PrintUse(); - return false; - } - - return true; -} - - - - -} // namespace csv - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/service/comfunc.cxx b/cosv/source/service/comfunc.cxx deleted file mode 100644 index a8ec5f8e4549..000000000000 --- a/cosv/source/service/comfunc.cxx +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> - -#include <ctype.h> -#include <cosv/x.hxx> - - - -namespace csv -{ - - -void -X_Default::GetInfo( ostream & o_rOutputMedium ) const -{ - o_rOutputMedium << "Error (general exception): "; - o_rOutputMedium << sMessage - << Endl; -} - -} // namespace csv - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/service/csv_ostream.cxx b/cosv/source/service/csv_ostream.cxx deleted file mode 100644 index 698616ac0555..000000000000 --- a/cosv/source/service/csv_ostream.cxx +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/csv_ostream.hxx> - -// NOT FULLY DECLARED SERVICES - - -#ifndef CSV_NO_IOSTREAMS -#else - -namespace csv -{ - -ostream::~ostream() { } - -ostream & ostream::operator<<( - const char * i_s ) { *pData << i_s; return *this; } -ostream & ostream::operator<<( - char i_c ) { *pData << i_c; return *this; } -ostream & ostream::operator<<( - unsigned char i_c ) { *pData << i_c; return *this; } -ostream & ostream::operator<<( - signed char i_c ) { *pData << i_c; return *this; } - -ostream & ostream::operator<<( - short i_n ) { *pData << i_n; return *this; } -ostream & ostream::operator<<( - unsigned short i_n ) { *pData << i_n; return *this; } -ostream & ostream::operator<<( - int i_n ) { *pData << i_n; return *this; } -ostream & ostream::operator<<( - unsigned int i_n ) { *pData << i_n; return *this; } -ostream & ostream::operator<<( - long i_n ) { *pData << i_n; return *this; } -ostream & ostream::operator<<( - unsigned long i_n ) { *pData << i_n; return *this; } - -ostream & ostream::operator<<( - float i_n ) { *pData << i_n; return *this; } -ostream & ostream::operator<<( - double i_n ) { *pData << i_n; return *this; } - -ostream & -ostream::seekp( intt i_nOffset, - seek_dir i_eStart ) -{ - pData->seekp(i_nOffset, csv::seek_dir(int(i_eStart)) ); - return *this; -} - -ostream::ostream( uintt i_nStartSize ) - : pData( new StreamStr(i_nStartSize) ) -{ -} - - - -} // namespace csv - -#endif - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/service/std_outp.cxx b/cosv/source/service/std_outp.cxx deleted file mode 100644 index 69a9e789e5b5..000000000000 --- a/cosv/source/service/std_outp.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> - -// NOT FULLY DECLARED SERVICES -#include <stdlib.h> - - -namespace csv -{ - -#ifdef CSV_NO_IOSTREAMS -redirect_out * redirect_out::pStdOut_ = 0; -redirect_out * redirect_out::pStdErr_ = 0; -#endif // defined(CSV_NO_IOSTREAMS) - - -void -Endl( ostream & io_rStream ) -{ -#ifndef CSV_NO_IOSTREAMS -// if (NOT bUseRedirect) - io_rStream << std::endl; -// else -#endif -} - -void -Flush( ostream & io_rStream ) -{ -#ifndef CSV_NO_IOSTREAMS -// if (NOT bUseRedirect) - io_rStream << std::flush; -// else -#endif -} - -void -PerformAssertion(const char * condition, const char * file, unsigned line) -{ - Cout() << "assertion failed: " - << condition - << " in file: " - << file - << " at line: " - << line - << Endl; - - exit(3); -} - -} // namespace csv - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/storage/dirchain.cxx b/cosv/source/storage/dirchain.cxx deleted file mode 100644 index 06e4b09d2b96..000000000000 --- a/cosv/source/storage/dirchain.cxx +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/dirchain.hxx> - -// NOT FULLY DECLARED SERVICES -#include <cosv/bstream.hxx> - - - - -namespace csv -{ -namespace ploc -{ - - -DirectoryChain::DirectoryChain() -{ -} - -DirectoryChain::~DirectoryChain() -{ -} - -void -DirectoryChain::Set( const char * i_sSubPath, - bool i_bPathIsAlwaysDir, - const char * i_sDelimiter ) -{ - csv_assert(i_sDelimiter != 0); - if (i_sSubPath == 0) - return; - - const char * pRestPath = i_sSubPath; - if (*pRestPath == *i_sDelimiter) - ++pRestPath; - - for ( const char * pDirEnd = strchr(pRestPath,*i_sDelimiter); - pDirEnd != 0; - pDirEnd = strchr(pRestPath,*i_sDelimiter) ) - { - aPath.push_back( String(pRestPath, pDirEnd) ); - pRestPath = pDirEnd + 1; - } - if (*pRestPath != 0 AND i_bPathIsAlwaysDir) - aPath.push_back( String(pRestPath) ); -} - -void -DirectoryChain::PushBack( const String & i_sName ) -{ - aPath.push_back(i_sName); -} - -void -DirectoryChain::PushBack( const DirectoryChain & i_sPath ) -{ - aPath.insert( aPath.end(), i_sPath.Begin(), i_sPath.End() ); -} - -void -DirectoryChain::PopBack( uintt i_nCount ) -{ - if (i_nCount <= aPath.size()) - aPath.erase( aPath.end() - i_nCount, aPath.end() ); - else - aPath.erase( aPath.begin(), aPath.end() ); -} - -void -DirectoryChain::Get( bostream & o_rPath, - const char * i_sDelimiter ) const -{ - uintt deliLen = strlen(i_sDelimiter); - - for ( std::vector<String>::const_iterator it = aPath.begin(); - it != aPath.end(); - ++it ) - { - o_rPath.write( (*it).c_str() ); - o_rPath.write( i_sDelimiter, deliLen); - } -} - - - - -} // namespace ploc -} // namespace csv - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/storage/file.cxx b/cosv/source/storage/file.cxx deleted file mode 100644 index c9eed642d545..000000000000 --- a/cosv/source/storage/file.cxx +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/file.hxx> - -// NOT FULLY DECLARED SERVICES - - -namespace csv -{ - - -File::File( const char * i_sLocation, - uintt i_nMode ) - : aPath(i_sLocation), - pStream(0), - nMode(i_nMode), - eLastIO(io_none) -{ -} - -File::File( const String & i_sLocation, - uintt i_nMode ) - : aPath(i_sLocation), - pStream(0), - nMode(i_nMode), - eLastIO(io_none) -{ -} - -File::~File() -{ - if ( inq_is_open() ) - close(); -} - -uintt -File::do_read( void * out_pDest, - uintt i_nNrofBytes ) -{ - if ( NOT inq_is_open() ) - return 0; - - if ( eLastIO == io_write ) - ::fseek( pStream, 0, SEEK_CUR ); - uintt ret = position(); - int iRet= ::fread( out_pDest, 1, i_nNrofBytes, pStream ); - if ( iRet < 0 ) { - fprintf(stderr, "warning: read failed in %s line %d \n", __FILE__, __LINE__); - } - ret = position() - ret; - - eLastIO = io_read; - return ret; -} - -bool -File::inq_eod() const -{ - if ( NOT inq_is_open() ) - return true; - return feof(pStream) != 0; -} - -uintt -File::do_write( const void * i_pSrc, - uintt i_nNrofBytes ) -{ - if ( NOT inq_is_open() ) - return 0; - - if ( eLastIO == io_write ) - ::fseek( pStream, 0, SEEK_CUR ); - - uintt ret = ::fwrite( i_pSrc, 1, i_nNrofBytes, pStream ); - - eLastIO = io_write; - return ret; -} - -uintt -File::do_seek( intt i_nDistance, - seek_dir i_eStartPoint ) -{ - if ( NOT inq_is_open() ) - return uintt(-1); - - static int eSearchDir[3] = { SEEK_SET, SEEK_CUR, SEEK_END }; - - ::fseek( pStream, - intt(i_nDistance), - eSearchDir[i_eStartPoint] ); - return position(); -} - -uintt -File::inq_position() const -{ - if ( inq_is_open() ) - return uintt( ::ftell(pStream) ); - else - return uintt(-1); -} - -bool -File::do_open( uintt i_nOpenMode ) -{ - if ( inq_is_open() ) - { - if ( i_nOpenMode == 0 OR i_nOpenMode == nMode ) - return true; - close(); - } - - if ( i_nOpenMode != 0 ) - nMode = i_nOpenMode; - - const char * sFacadeMode = ""; - switch ( nMode ) - { - case CFM_RW: sFacadeMode = "r+b"; - break; - case CFM_CREATE: sFacadeMode = "w+b"; - break; - case CFM_READ: sFacadeMode = "rb"; - break; - default: - sFacadeMode = "rb"; - } - - pStream = ::fopen( StrPath(), sFacadeMode ); - if ( pStream == 0 AND nMode == CFM_RW ) - { - sFacadeMode = "w+b"; - pStream = ::fopen( StrPath(), sFacadeMode ); - } - - return pStream != 0; -} - -void -File::do_close() -{ - if ( inq_is_open() ) - { - ::fclose(pStream); - pStream = 0; - } - eLastIO = io_none; -} - -bool -File::inq_is_open() const -{ - return pStream != 0; -} - -const ploc::Path & -File::inq_MyPath() const -{ - return aPath; -} - - -} // namespace csv - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/storage/persist.cxx b/cosv/source/storage/persist.cxx deleted file mode 100644 index 486eaea5fa44..000000000000 --- a/cosv/source/storage/persist.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/persist.hxx> - -// NOT FULLY DECLARED SERVICES -#include <cosv/ploc.hxx> - - -#ifdef WNT -#include <io.h> - -namespace csv -{ -namespace ploc -{ - -bool -Persistent::Exists() const -{ - return access( StrPath(), 00) == 0; -} - -} // namespace ploc -} // namespace csv - - -#elif defined(UNX) -#include <unistd.h> - -namespace csv -{ -namespace ploc -{ - -bool -Persistent::Exists() const -{ - return access( StrPath(), F_OK ) == 0; -} - - -} // namespace ploc -} // namespace csv - -#else -#error For using csv::ploc there has to be defined: WNT or UNX. -#endif - -namespace csv -{ -namespace ploc -{ - -const char * -Persistent::StrPath() const -{ - if (sPath.empty() ) - { -#ifndef CSV_NO_MUTABLE - StreamStr & rsPath = sPath; -#else - StreamStr & rsPath = const_cast< StreamStr& >(sPath); -#endif - rsPath.seekp(0); - rsPath << MyPath(); - if (MyPath().IsDirectory()) - rsPath.pop_back(1); // Remove closing delimiter. - } - return sPath.c_str(); -} - -} // namespace ploc -} // namespace csv - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/storage/ploc.cxx b/cosv/source/storage/ploc.cxx deleted file mode 100644 index 7dd6d0e997dd..000000000000 --- a/cosv/source/storage/ploc.cxx +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/ploc.hxx> - -// NOT FULLY DECLARED SERVICES -#include <cosv/bstream.hxx> - - - - -namespace csv -{ -namespace ploc -{ - - -Path::Path( const char * i_sPath, - bool i_bPathIsAlwaysDir, - const char * i_sDelimiter ) - : pRoot(0) - // aPath, - // sFile -{ - Set(i_sPath, i_bPathIsAlwaysDir, i_sDelimiter ); -} - -Path::Path( const Path & i_rPath ) - : pRoot(i_rPath.pRoot->CreateCopy()), - aPath(i_rPath.aPath), - sFile(i_rPath.sFile) -{ -} - -Path::~Path() -{ -} - -Path & -Path::operator=( const Path & i_rPath ) -{ - pRoot = i_rPath.pRoot->CreateCopy(); - aPath = i_rPath.aPath; - sFile = i_rPath.sFile; - return *this; -} - - -void -Path::Set( const char * i_sPath, - bool i_bPathIsAlwaysDir, - const char * i_sDelimiter ) -{ - if ( *i_sDelimiter != '\\' AND *i_sDelimiter != '/' ) - return; - - const char * - restPath = 0; - pRoot = Root::Create_( restPath, i_sPath, i_sDelimiter ); - if (restPath == 0) - return; - - aPath.Set(restPath, i_bPathIsAlwaysDir, i_sDelimiter); - - if (NOT i_bPathIsAlwaysDir) - { - const char * - file = strrchr( restPath, *i_sDelimiter ); - if (file == 0) - file = restPath; - else - file++; - sFile = file; - } -} - -void -Path::SetFile( const String & i_sName ) -{ - sFile = i_sName; -} - -bool -Path::IsValid() const -{ - return RootDir().OwnDelimiter() != 0; -} - -void -Path::Get( bostream & o_rPath ) const -{ - if (NOT IsValid()) - return; - - pRoot->Get( o_rPath ); - aPath.Get( o_rPath, pRoot->OwnDelimiter() ); - - if ( sFile.length() > 0 ) - o_rPath.write( sFile ); -} - -} // namespace ploc -} // namespace csv - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/storage/ploc_dir.cxx b/cosv/source/storage/ploc_dir.cxx deleted file mode 100644 index 234a2d3fbf79..000000000000 --- a/cosv/source/storage/ploc_dir.cxx +++ /dev/null @@ -1,359 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/ploc_dir.hxx> - -// NOT FULLY DECLARED SERVICES -#include <cosv/ploc.hxx> - - -namespace csv -{ -namespace ploc -{ - -Directory::Directory() -{ -} - -Directory::Directory( const Path & i_rPath ) - : aPath(i_rPath) - // sPath -{ -} - -Directory::Directory( const Directory & i_rDir ) - : Persistent(), aPath(i_rDir.aPath) - // sPath -{ -} - -Directory::Directory( const char * i_rLocation ) - : aPath(i_rLocation, true) -{ -} - -Directory::~Directory() -{ -} - -Directory & -Directory::operator+=( const String & i_sName ) -{ - InvalidatePath(); - aPath.DirChain() += i_sName; - return *this; -} - -Directory & -Directory::operator+=( const DirectoryChain & i_sDirChain ) -{ - InvalidatePath(); - aPath.DirChain() += i_sDirChain; - return *this; -} - -Directory & -Directory::operator-=( uintt i_nLevels ) -{ - InvalidatePath(); - aPath.DirChain().PopBack(i_nLevels); - return *this; -} - -bool -Directory::PhysicalCreate( bool i_bCreateParentsIfNecessary ) const -{ - bool ret = PhysicalCreate_Dir( StrPath() ); - if ( ret OR NOT i_bCreateParentsIfNecessary ) - return ret; - - ret = Check_Parent(); - if (ret) - ret = PhysicalCreate_Dir( StrPath() ); - return ret; -} - -bool -Directory::Check_Parent() const -{ - // There is no parent of root directories: - if ( aPath.DirChain().Size() == 0 ) - return false; - - // Become my own parent: - String sLastToken = aPath.DirChain().Back(); - const_cast< Directory* >(this)->operator-=(1); - - // Begin behaving as parent: - bool ret = Exists(); - if (NOT ret) - { - ret = Check_Parent(); - if (ret) - ret = PhysicalCreate_Dir( StrPath() ); - } - // End behaving as parent. - - // Become myself again: - const_cast< Directory* >(this)->operator+=(sLastToken); - return ret; -} - -} // namespace ploc -} // namespace csv - - -#ifdef WNT -#include <direct.h> -#include <io.h> - -namespace csv -{ -namespace ploc -{ - -bool -Directory::PhysicalCreate_Dir( const char * i_sStr ) const -{ - return mkdir( i_sStr ) == 0; -} - -void -Directory::GetContainedDirectories( StringVector & o_rResult ) const -{ - const char * c_sANYDIR = "\\*.*"; - String sNew; - - StreamStr sFilter(200); - sFilter << StrPath() - << c_sANYDIR; - - struct _finddata_t - aEntry; - long hFile = _findfirst( sFilter.c_str(), &aEntry ); - - for ( int bFindMore = (hFile == -1 ? 1 : 0); - bFindMore == 0; - bFindMore = _findnext( hFile, &aEntry ) ) - { - if ( (aEntry.attrib & _A_SUBDIR) AND *aEntry.name != '.' ) - { - sNew = aEntry.name; - o_rResult.push_back( sNew ); - } - } // end for - _findclose(hFile); -} - -void -Directory::GetContainedFiles( StringVector & o_rResult, - const char * i_sFilter, - E_Recursivity i_eRecursivity ) const -{ - StreamStr sNew(240); - sNew << aPath; - StreamStr::size_type - nStartFilename = sNew.tellp(); - - StreamStr sFilter(200); - sFilter << StrPath() - << "\\" - << i_sFilter; - - struct _finddata_t - aEntry; - long hFile = _findfirst( sFilter.c_str(), &aEntry ); - for ( int bFindMore = (hFile == -1 ? 1 : 0); - bFindMore == 0; - bFindMore = _findnext( hFile, &aEntry ) ) - { - sNew.seekp(nStartFilename); - sNew << aEntry.name; - String sNewAsString( sNew.c_str() ); - o_rResult.push_back(sNewAsString); - } // end for - - _findclose(hFile); - if ( i_eRecursivity == flat ) - return; - - // gathering from subdirectories: - StringVector aSubDirectories; - GetContainedDirectories( aSubDirectories ); - - StringVector::const_iterator dEnd = aSubDirectories.end(); - for ( StringVector::const_iterator d = aSubDirectories.begin(); - d != dEnd; - ++d ) - { - Directory aSub(*this); - aSub += *d; - aSub.GetContainedFiles( o_rResult, - i_sFilter, - i_eRecursivity ); - } -} - -} // namespace ploc -} // namespace csv - - -#elif defined(UNX) -#include <sys/types.h> -#include <sys/stat.h> -#include <dirent.h> - -namespace csv -{ -namespace ploc -{ - -bool -Directory::PhysicalCreate_Dir( const char * i_sStr ) const -{ - return mkdir( i_sStr, 00777 ) == 0; -} - -void -Directory::GetContainedDirectories( StringVector & o_rResult ) const -{ - StreamStr sNew(240); - sNew << aPath; - StreamStr::size_type - nStartFilename = sNew.tellp(); - - DIR * pDir = opendir( StrPath() ); - dirent * pEntry = 0; - struct stat aEntryStatus; - - while ( (pEntry = readdir(pDir)) != 0 ) - { - sNew.seekp(nStartFilename); - sNew << pEntry->d_name; - - stat(sNew.c_str(), &aEntryStatus); - if ( (aEntryStatus.st_mode & S_IFDIR) == S_IFDIR - AND *pEntry->d_name != '.' ) - { - String sNew2(pEntry->d_name); - o_rResult.push_back(sNew2); - } // endif (aEntry.attrib == _A_SUBDIR) - } // end while - closedir( pDir ); -} - -void -Directory::GetContainedFiles( StringVector & o_rResult, - const char * i_sFilter, - E_Recursivity i_eRecursivity ) const -{ - StreamStr sNew(240); - sNew << aPath; - StreamStr::size_type - nStartFilename = sNew.tellp(); - - bool bUseFilter = strcmp( i_sFilter, "*.*" ) != 0 - AND strncmp( i_sFilter, "*.", 2) == 0; - - DIR * pDir = opendir( StrPath() ); - dirent * pEntry = 0; - struct stat aEntryStatus; - - while ( (pEntry = readdir(pDir)) != 0 ) - { - sNew.seekp(nStartFilename); - sNew << pEntry->d_name; - - stat(sNew.c_str(), &aEntryStatus); - if ( (aEntryStatus.st_mode & S_IFDIR) == S_IFDIR ) - continue; // Don't gather directories. - - if ( bUseFilter ) - { - const char * pEnding = strrchr(pEntry->d_name,'.'); - if (pEnding == 0) - continue; - if ( strcasecmp( pEnding + 1, i_sFilter + 2 ) != 0 ) - continue; - } - - sNew.seekp(nStartFilename); - sNew << pEntry->d_name; - String sNewAsString( sNew.c_str() ); - o_rResult.push_back(sNewAsString); - } // end while - - closedir( pDir ); - if ( i_eRecursivity == flat ) - return; - - // gathering from subdirectories: - StringVector aSubDirectories; - GetContainedDirectories( aSubDirectories ); - - StringVector::const_iterator dEnd = aSubDirectories.end(); - for ( StringVector::const_iterator d = aSubDirectories.begin(); - d != dEnd; - ++d ) - { - Directory aSub(*this); - aSub += *d; - aSub.GetContainedFiles( o_rResult, - i_sFilter, - i_eRecursivity ); - } -} - -} // namespace ploc -} // namespace csv - - -#else -#error For using csv::ploc there has to be defined: WNT or UNX. -#endif - - -namespace csv -{ -namespace ploc -{ - -const Path & -Directory::inq_MyPath() const -{ - return aPath; -} - - - -} // namespace ploc -} // namespace csv - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/storage/plocroot.cxx b/cosv/source/storage/plocroot.cxx deleted file mode 100644 index faf48133ad6d..000000000000 --- a/cosv/source/storage/plocroot.cxx +++ /dev/null @@ -1,525 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/ploc.hxx> - -// NOT FULLY DECLARED SERVICES -#include <ctype.h> -#include <cosv/bstream.hxx> -#include <cosv/csv_ostream.hxx> - - -namespace csv -{ -namespace ploc -{ - - -class UnixRootDir : public Root -{ - public: - UnixRootDir(); - - virtual void Get( - ostream & o_rPath ) const; - virtual void Get( - bostream & o_rPath ) const; - virtual DYN Root * CreateCopy() const; - virtual const char * - OwnDelimiter() const; -}; - -class WorkingDir : public Root -{ - public: - WorkingDir( - const char * i_sDelimiter = Delimiter() ); - - virtual void Get( - ostream & o_rPath ) const; - virtual void Get( - bostream & o_rPath ) const; - virtual DYN Root * CreateCopy() const; - virtual const char * - OwnDelimiter() const; - private: - String sOwnDelimiter; -}; - -class WinRootDir : public Root -{ - public: - WinRootDir(); - - virtual void Get( - ostream & o_rPath ) const; - virtual void Get( - bostream & o_rPath ) const; - virtual DYN Root * CreateCopy() const; - virtual const char * - OwnDelimiter() const; -}; - -class WinDrive : public Root -{ - public: - WinDrive( - char i_cDrive ); - virtual void Get( - ostream & o_rPath ) const; - virtual void Get( - bostream & o_rPath ) const; - virtual DYN Root * CreateCopy() const; - virtual const char * - OwnDelimiter() const; - private: - char cDrive; -}; - -class WinDriveRootDir : public Root -{ - public: - WinDriveRootDir( - const char * i_sPath ); - WinDriveRootDir( - char i_cDrive ); - - virtual void Get( - ostream & o_rPath ) const; - virtual void Get( - bostream & o_rPath ) const; - virtual DYN Root * CreateCopy() const; - virtual const char * - OwnDelimiter() const; - private: - char cDrive; -}; - -class UNCRoot : public Root -{ - public: - UNCRoot( - const char * i_sPath ); - UNCRoot( - const String & i_sComputer, - const String & i_sEntryPt ); - - virtual void Get( - ostream & o_rPath ) const; - virtual void Get( - bostream & o_rPath ) const; - virtual DYN Root * CreateCopy() const; - virtual const char * - OwnDelimiter() const; - private: - String sComputer; - String sEntryPt; -}; - -class InvalidRoot : public Root -{ - public: - virtual void Get( - ostream & o_rPath ) const; - virtual void Get( - bostream & o_rPath ) const; - virtual DYN Root * CreateCopy() const; - virtual const char * - OwnDelimiter() const; -}; - - -DYN Root * -Create_WindowsRoot( const char * & o_sPathAfterRoot, - const char * i_sPath ) -{ - if (i_sPath[0] == '\\') - { - if (i_sPath[1] == '\\') - { // UNC path name - o_sPathAfterRoot = strchr(i_sPath+2,'\\'); - if (o_sPathAfterRoot != 0) - { - o_sPathAfterRoot = strchr(o_sPathAfterRoot+1,'\\'); - if (o_sPathAfterRoot != 0) - ++o_sPathAfterRoot; - return new UNCRoot(i_sPath); - } - return new InvalidRoot; // Incomplete UNC root. - } - else - { - o_sPathAfterRoot = i_sPath+1; - return new WinRootDir; - } - } - else if (i_sPath[1] == ':') - { - if ( i_sPath[2] == '\\') - { - o_sPathAfterRoot = i_sPath + 3; - return new WinDriveRootDir(i_sPath); - } - else - { - o_sPathAfterRoot = i_sPath + 2; - return new WinDrive(*i_sPath); - } - } - else - { - o_sPathAfterRoot = i_sPath; - return new WorkingDir("\\"); - } -} - -DYN Root * -Create_UnixRoot( const char * & o_sPathAfterRoot, - const char * i_sPath ) -{ - if (*i_sPath == '/') - { - o_sPathAfterRoot = i_sPath + 1; - return new UnixRootDir; - } - else // - { - o_sPathAfterRoot = i_sPath; - return new WorkingDir("/"); - } // endif -} - - -//********************** Root ****************************// - -Root::~Root() -{ - -} - -DYN Root * -Root::Create_( const char * & o_sPathAfterRoot, - const char * i_sPath, - const char * i_sDelimiter ) -{ - if (i_sPath[0] == '.') - { - switch ( i_sPath[1] ) - { - case '\0': o_sPathAfterRoot = i_sPath + 1; - break; - case '\\': o_sPathAfterRoot = i_sPath + 2; - break; - case '/': o_sPathAfterRoot = i_sPath + 2; - break; - case '.': o_sPathAfterRoot = i_sPath; - break; - default: - o_sPathAfterRoot = 0; - return new InvalidRoot; - } // end switch (i_sPath[1]) - - return new WorkingDir; - } // end if (i_sPath[0] == '.') - - switch (*i_sDelimiter) - { - case '\\': return Create_WindowsRoot(o_sPathAfterRoot, i_sPath); - case '/': return Create_UnixRoot(o_sPathAfterRoot, i_sPath); - } - - o_sPathAfterRoot = 0; - return new InvalidRoot; -} - - - -//********************** UnixRootDir ****************************// - - -UnixRootDir::UnixRootDir() -{ -} - -void -UnixRootDir::Get( ostream & o_rPath ) const -{ - o_rPath << '/'; -} - -void -UnixRootDir::Get( bostream & o_rPath ) const -{ - o_rPath.write( "/", 1 ); -} - -DYN Root * -UnixRootDir::CreateCopy() const -{ - return new UnixRootDir; -} - -const char * -UnixRootDir::OwnDelimiter() const -{ - return "/"; -} - - -//********************** WorkingDir ****************************// - -WorkingDir::WorkingDir( const char * i_sDelimiter ) - : sOwnDelimiter(i_sDelimiter) -{ -} - -void -WorkingDir::Get( ostream & o_rPath ) const -{ - o_rPath << '.' << sOwnDelimiter; -} - -void -WorkingDir::Get( bostream & o_rPath ) const -{ - o_rPath.write( ".", 1 ); - o_rPath.write( sOwnDelimiter ); -} - -DYN Root * -WorkingDir::CreateCopy() const -{ - return new WorkingDir(sOwnDelimiter); -} - -const char * -WorkingDir::OwnDelimiter() const -{ - return sOwnDelimiter; -} - - -//********************** WinRootDir ****************************// - -WinRootDir::WinRootDir() -{ -} - -void -WinRootDir::Get( ostream & o_rPath ) const -{ - o_rPath << '\\'; -} - -void -WinRootDir::Get( bostream & o_rPath ) const -{ - o_rPath.write( "\\", 1 ); -} - -DYN Root * -WinRootDir::CreateCopy() const -{ - return new WinRootDir; -} - -const char * -WinRootDir::OwnDelimiter() const -{ - return "\\"; -} - - -//********************** WinDrive ****************************// - -WinDrive::WinDrive( char i_cDrive ) - : cDrive(static_cast< char >(toupper(i_cDrive))) -{ -} - -void -WinDrive::Get( ostream & o_rPath ) const -{ - o_rPath << cDrive << ':'; -} - -void -WinDrive::Get( bostream & o_rPath ) const -{ - static char buf_[3] = " :"; - buf_[0] = cDrive; - o_rPath.write( &buf_[0], 2 ); -} - -DYN Root * -WinDrive::CreateCopy() const -{ - return new WinDrive(cDrive); -} - -const char * -WinDrive::OwnDelimiter() const -{ - return "\\"; -} - - -//********************** WinDriveRootDir ****************************// - -WinDriveRootDir::WinDriveRootDir( const char * i_sPath ) - : cDrive(static_cast< char >(toupper(*i_sPath))) -{ - if ( 'A' > cDrive OR 'Z' < cDrive ) - cDrive = 0; -} - -WinDriveRootDir::WinDriveRootDir( char i_cDrive ) - : cDrive(i_cDrive) -{ -} - -void -WinDriveRootDir::Get( ostream & o_rPath ) const -{ - o_rPath << cDrive << ":\\"; -} - -void -WinDriveRootDir::Get( bostream & o_rPath ) const -{ - static char buf_[4] = " :\\"; - buf_[0] = cDrive; - o_rPath.write( &buf_[0], 3 ); -} - -DYN Root * -WinDriveRootDir::CreateCopy() const -{ - return new WinDriveRootDir(cDrive); -} - -const char * -WinDriveRootDir::OwnDelimiter() const -{ - return "\\"; -} - - -//********************** UNCRoot ****************************// - -UNCRoot::UNCRoot( const char * i_sPath ) -// : // sComputer, - // sEntryPt -{ - const char * pRestPath = i_sPath + 2; - const char * pDirEnd = strchr(pRestPath, '\\'); - csv_assert(pDirEnd != 0); - - sComputer = String(pRestPath, pDirEnd - pRestPath); - pRestPath = pDirEnd+1; - pDirEnd = strchr(pRestPath, '\\'); - - if ( pDirEnd != 0 ) - { - sEntryPt = String(pRestPath, pDirEnd - pRestPath); - } - else - { - sEntryPt = pRestPath; - } -} - -UNCRoot::UNCRoot( const String & i_sComputer, - const String & i_sEntryPt ) - : sComputer(i_sComputer), - sEntryPt(i_sEntryPt) -{ -} - -void -UNCRoot::Get( ostream & o_rPath ) const -{ - o_rPath << "\\\\" << sComputer << '\\' << sEntryPt << "\\"; -} - -void -UNCRoot::Get( bostream & o_rPath ) const -{ - o_rPath.write( "\\\\", 2 ); - o_rPath.write( sComputer ); - o_rPath.write( "\\", 1 ); - o_rPath.write( sEntryPt ); - o_rPath.write( "\\", 1 ); -} - -DYN Root * -UNCRoot::CreateCopy() const -{ - return new UNCRoot(sComputer,sEntryPt); -} - -const char * -UNCRoot::OwnDelimiter() const -{ - return "\\"; -} - - - -//********************** InvalidRoot ****************************// - -void -InvalidRoot::Get( ostream & ) const -{ -} - -void -InvalidRoot::Get( bostream & ) const -{ -} - -DYN Root * -InvalidRoot::CreateCopy() const -{ - return new InvalidRoot; -} - -const char * -InvalidRoot::OwnDelimiter() const -{ - return 0; -} - - - - -} // namespace ploc -} // namespace csv - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/strings/str_types.cxx b/cosv/source/strings/str_types.cxx deleted file mode 100644 index 8ea037663eb4..000000000000 --- a/cosv/source/strings/str_types.cxx +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/str_types.hxx> - - - -namespace csv -{ - -CharOrder_Table::CharOrder_Table( const int * i_pCharWeightsArray ) -{ - memcpy( cWeights, i_pCharWeightsArray, 256 * sizeof(int) ); -} - - -} // namespace csv - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/strings/streamstr.cxx b/cosv/source/strings/streamstr.cxx deleted file mode 100644 index 809379be0eff..000000000000 --- a/cosv/source/strings/streamstr.cxx +++ /dev/null @@ -1,606 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> - -// NOT FULLY DECLARED SERVICES -#include <string.h> -#include <stdio.h> -#include <stdarg.h> // both are needed to satisfy all compilers -#include <cstdarg> // std::va_list and friends - -#include <cosv/tpl/swelist.hxx> - - - -namespace csv -{ - - -// Maximal sizes of resulting integers in text form: -const uintt C_short_max_size = sizeof(short) * 3; -const uintt C_int_max_size = sizeof(int) * 3; -const uintt C_long_max_size = sizeof(long) * 3; - - -inline void -StreamStr::Advance(size_type i_nAddedSize) -{ pCur += i_nAddedSize; } - - - -StreamStr::StreamStr( size_type i_nCapacity ) - : bostream(), - nCapacity1( i_nCapacity + 1 ), - dpData( new char [i_nCapacity + 1] ), - pEnd(dpData), - pCur(dpData), - eMode(str::overwrite) -{ - *pEnd = '\0'; -} - -StreamStr::StreamStr( const self & i_rOther ) - : bostream(), - nCapacity1( i_rOther.nCapacity1 ), - dpData( new char [i_rOther.nCapacity1] ), - pEnd( dpData + strlen(i_rOther.dpData) ), - pCur( dpData + i_rOther.tellp() ), - eMode(i_rOther.eMode) -{ - strcpy( dpData, i_rOther.dpData ); // SAFE STRCPY (#100211# - checked) -} - -StreamStr::~StreamStr() -{ - delete [] dpData; -} - - -StreamStr & -StreamStr::operator=( const self & i_rOther ) -{ - delete [] dpData; - - nCapacity1 = i_rOther.nCapacity1; - dpData = new char [i_rOther.nCapacity1]; - pEnd = dpData + strlen(i_rOther.dpData); - strcpy( dpData, i_rOther.dpData ); // SAFE STRCPY (#100211# - checked) - pCur = dpData + i_rOther.tellp(); - eMode = i_rOther.eMode; - - return *this; -} - -StreamStr & -StreamStr::operator<<( const char * i_s ) -{ - size_type nLength = strlen(i_s); - - ProvideAddingSize( nLength ); - memcpy( pCur, i_s, nLength ); - Advance(nLength); - - return *this; -} - -StreamStr & -StreamStr::operator<<( const String & i_s ) -{ - size_type nLength = i_s.length(); - - ProvideAddingSize( nLength ); - memcpy( pCur, i_s.c_str(), nLength ); - Advance(nLength); - - return *this; -} - -StreamStr & -StreamStr::operator<<( char i_c ) -{ - ProvideAddingSize( 1 ); - *pCur = i_c; - Advance(1); - - return *this; -} - -StreamStr & -StreamStr::operator<<( unsigned char i_c ) -{ - return operator<<( char(i_c) ); -} - -StreamStr & -StreamStr::operator<<( signed char i_c ) -{ - return operator<<( char(i_c) ); -} - -StreamStr & -StreamStr::operator<<( short i_n ) -{ - char buf[C_short_max_size] = ""; - sprintf( buf, "%hi", i_n ); // SAFE SPRINTF (#100211# - checked) - - size_type nLength = strlen(buf); - ProvideAddingSize( nLength ); - memcpy( pCur, buf, nLength ); - Advance( nLength ); - - return *this; -} - -StreamStr & -StreamStr::operator<<( unsigned short i_n ) -{ - char buf[C_short_max_size] = ""; - sprintf( buf, "%hu", i_n ); // SAFE SPRINTF (#100211# - checked) - - size_type nLength = strlen(buf); - ProvideAddingSize( nLength ); - memcpy( pCur, buf, nLength ); - Advance( nLength ); - - return *this; -} - -StreamStr & -StreamStr::operator<<( int i_n ) -{ - char buf[C_int_max_size] = ""; - sprintf( buf, "%i", i_n ); // SAFE SPRINTF (#100211# - checked) - - size_type nLength = strlen(buf); - ProvideAddingSize( nLength ); - memcpy( pCur, buf, nLength ); - Advance( nLength ); - - return *this; -} - -StreamStr & -StreamStr::operator<<( unsigned int i_n ) -{ - char buf[C_int_max_size] = ""; - sprintf( buf, "%u", i_n ); // SAFE SPRINTF (#100211# - checked) - - size_type nLength = strlen(buf); - ProvideAddingSize( nLength ); - memcpy( pCur, buf, nLength ); - Advance( nLength ); - - return *this; -} - -StreamStr & -StreamStr::operator<<( long i_n ) -{ - char buf[C_long_max_size] = ""; - sprintf( buf, "%li", i_n ); // SAFE SPRINTF (#100211# - checked) - - size_type nLength = strlen(buf); - ProvideAddingSize( nLength ); - memcpy( pCur, buf, nLength ); - Advance( nLength ); - - return *this; -} - -StreamStr & -StreamStr::operator<<( unsigned long i_n ) -{ - char buf[C_long_max_size] = ""; - sprintf( buf, "%lu", i_n ); // SAFE SPRINTF (#100211# - checked) - - size_type nLength = strlen(buf); - ProvideAddingSize( nLength ); - memcpy( pCur, buf, nLength ); - Advance( nLength ); - - return *this; -} - -StreamStr & -StreamStr::operator<<( float i_n ) -{ - const int C_float_max_size = 20; - char buf[C_float_max_size] = ""; - sprintf( buf, "%.*g", C_float_max_size-8, i_n ); // SAFE SPRINTF (#100211# - checked) - - size_type nLength = strlen(buf); - ProvideAddingSize( nLength ); - memcpy( pCur, buf, nLength ); - Advance( nLength ); - - return *this; -} - -StreamStr & -StreamStr::operator<<( double i_n ) -{ - const int C_double_max_size = 30; - char buf[C_double_max_size] = ""; - sprintf( buf, "%.*lg", C_double_max_size-8, i_n ); // SAFE SPRINTF (#100211# - checked) - - size_type nLength = strlen(buf); - ProvideAddingSize( nLength ); - memcpy( pCur, buf, nLength ); - Advance( nLength ); - - return *this; -} - -const char & -StreamStr::operator[]( position_type i_nPosition ) const -{ - static const char aNull_ = '\0'; - - if ( position_type(pEnd - dpData) > i_nPosition ) - return dpData[i_nPosition]; - return aNull_; -} - -char & -StreamStr::operator[]( position_type i_nPosition ) -{ - static char aDummy_ = '\0'; - - if ( position_type(pEnd - dpData) > i_nPosition ) - return dpData[i_nPosition]; - return aDummy_; -} - -void -StreamStr::resize( size_type i_nMinimumCapacity ) -{ - if ( i_nMinimumCapacity <= capacity() ) - return; - - Resize(i_nMinimumCapacity); -} - -StreamStr & -StreamStr::seekp( seek_type i_nCount, - seek_dir i_eDirection ) -{ - seek_type nLength = seek_type( length() ); - seek_type nNewPos = tellp(); - - switch ( i_eDirection ) - { - case ::csv::beg: nNewPos = i_nCount; - break; - case ::csv::cur: nNewPos += i_nCount; - break; - case ::csv::end: nNewPos = nLength + i_nCount; - break; - } - - if ( in_range<seek_type>(0, nNewPos, nLength + 1) ) - { - pCur = dpData + nNewPos; - if (eMode == str::overwrite) - { - pEnd = pCur; - *pEnd = '\0'; - } - } - - return *this; -} - -StreamStr & -StreamStr::set_insert_mode( insert_mode i_eMode ) -{ - eMode = i_eMode; - return *this; -} - -void -StreamStr::pop_front( size_type i_nCount ) -{ - size_type nCount = min(i_nCount, length()); - - MoveData( dpData + nCount, pEnd, -(seek_type(nCount)) ); - - pCur -= nCount; - pEnd -= nCount; - *pEnd = '\0'; -} - -void -StreamStr::pop_back( size_type i_nCount ) -{ - size_type nCount = min(i_nCount, length()); - pEnd -= nCount; - if (pCur > pEnd) - pCur = pEnd; - *pEnd = '\0'; -} - -StreamStr & -StreamStr::operator_join( std::vector<String>::const_iterator i_rBegin, - std::vector<String>::const_iterator i_rEnd, - const char * i_sLink ) -{ - std::vector<String>::const_iterator it = i_rBegin; - if ( it != i_rEnd ) - { - operator<<(*it); - for ( ++it; it != i_rEnd; ++it ) - { - operator<<(i_sLink); - operator<<(*it); - } - } - return *this; -} - -StreamStr & -StreamStr::operator_add_substr( const char * i_sText, - size_type i_nLength ) -{ - size_type nLength = csv::min<size_type>(i_nLength, strlen(i_sText)); - - ProvideAddingSize( nLength ); - memcpy( pCur, i_sText, nLength ); - Advance(nLength); - - return *this; -} - -StreamStr & -StreamStr::operator_add_token( const char * i_sText, - char i_cDelimiter ) -{ - const char * pTokenEnd = strchr(i_sText, i_cDelimiter); - if (pTokenEnd == 0) - operator<<(i_sText); - else - operator_add_substr(i_sText, pTokenEnd-i_sText); - return *this; -} - -StreamStr & -StreamStr::operator_read_line( bstream & i_src ) -{ - char c = 0; - intt nCount = 0; - for ( nCount = i_src.read(&c, 1); - nCount == 1 AND c != 13 AND c != 10; - nCount = i_src.read(&c, 1) ) - { - operator<<(c); - } - - // Check for line-end: - if ( NOT (nCount == 0) AND c != 0 ) - { - char oldc = c; - if (i_src.read(&c, 1) == 1) - { - if ( (c != 13 AND c != 10) OR c == oldc) - i_src.seek(-1,::csv::cur); - } - } - return *this; -} - -void -StreamStr::strip_front_whitespace() -{ - const_iterator it = begin(); - for ( ; - it != end() ? *it < 33 : false; - ++it ) ; - pop_front(it - begin()); -} - -void -StreamStr::strip_back_whitespace() -{ - const_iterator it = end(); - for ( ; - it != begin() ? *(it-1) < 33 : false; - --it ) ; - pop_back(end() - it); -} - -void -StreamStr::strip_frontback_whitespace() -{ - strip_front_whitespace(); - strip_back_whitespace(); -} - -void -StreamStr::replace_all( char i_cCarToSearch, - char i_cReplacement ) -{ - for ( char * p = dpData; p != pEnd; ++p ) - { - if (*p == i_cCarToSearch) - *p = i_cReplacement; - } -} - -class StreamStrPool -{ - public: - StreamStrPool(); - ~StreamStrPool(); - private: - // Non-copyable - StreamStrPool(StreamStrPool &); // not defined - void operator =(StreamStrPool &); // not defined - - // Interface to: - friend class StreamStrLock; - static StreamStr & AcquireFromPool_( - uintt i_nMinimalSize ); - static void ReleaseToPool_( - DYN StreamStr * let_dpUsedStr ); - - // DATA - SweList< DYN StreamStr* > - aPool; -}; - -StreamStrPool::StreamStrPool() -{ -} - -StreamStrPool::~StreamStrPool() -{ - for ( SweList< DYN StreamStr* >::iterator it = aPool.begin(); - it != aPool.end(); - ++it ) - { - delete (*it); - } -} - -namespace -{ - static StreamStrPool aPool_; -} - - -StreamStr & -StreamStrPool::AcquireFromPool_( uintt i_nMinimalSize ) -{ - if ( aPool_.aPool.empty() ) - { - return *new StreamStr(i_nMinimalSize); - } - - StreamStr & ret = *aPool_.aPool.front(); - aPool_.aPool.pop_front(); - ret.resize(i_nMinimalSize); - ret.seekp(0); - ret.set_insert_mode(str::overwrite); - return ret; -} - -void -StreamStrPool::ReleaseToPool_( DYN StreamStr * let_dpUsedStr ) -{ - aPool_.aPool.push_back( let_dpUsedStr ); -} - -StreamStrLock::StreamStrLock( uintt i_nMinimalSize ) - : pStr( &StreamStrPool::AcquireFromPool_(i_nMinimalSize) ) -{ -} - -StreamStrLock::~StreamStrLock() -{ - StreamStrPool::ReleaseToPool_(pStr); -} - - -UINT32 -StreamStr::do_write( const void * i_pSrc, - UINT32 i_nNrofBytes ) -{ - ProvideAddingSize( i_nNrofBytes ); - memcpy( pCur, i_pSrc, i_nNrofBytes ); - Advance(i_nNrofBytes); - - return i_nNrofBytes; -} - -void -StreamStr::ProvideAddingSize( size_type i_nSize2Add ) -{ - size_type nLength = length(); - if ( capacity() - nLength < i_nSize2Add ) - Resize( nLength + i_nSize2Add ); - - pEnd += i_nSize2Add; - *pEnd = '\0'; - - if (eMode == str::insert AND pCur != pEnd) - { - MoveData( pCur, pCur + i_nSize2Add, seek_type(i_nSize2Add) ); - } -} - -void -StreamStr::Resize( size_type i_nMinimumCapacity ) -{ - size_type nNewSize = nCapacity1 < 128 - ? nCapacity1 << 1 - : (nCapacity1 << 1) - (nCapacity1 >> 1); - nCapacity1 = csv::max( nNewSize, size_type(i_nMinimumCapacity + 1) ); - - char * pNew = new char[nCapacity1]; - strcpy ( pNew, dpData ); // SAFE STRCPY (#100211# - checked) - pEnd = pNew + (pEnd - dpData); - pCur = pNew + (pCur - dpData); - - delete [] dpData; - dpData = pNew; -} - -void -StreamStr::MoveData( char * i_pStart, - char * i_pEnd, - seek_type i_nDiff ) -{ - if (i_nDiff > 0) - { - register const char * pSrc = i_pEnd; - register char * pDest = i_pEnd + i_nDiff; - for ( ; pSrc != i_pStart; --pSrc, --pDest ) - { - *pDest = *pSrc; - } - *pDest = *pSrc; - } - else if (i_nDiff < 0) - { - const char * pSrc = i_pStart; - char * pDest = i_pStart + i_nDiff; - for ( ; pSrc != i_pEnd; ++pSrc, ++pDest ) - { - *pDest = *pSrc; - } - } -} - -// Does nothing, only the name of this function is needed. -void -c_str() -{ - // Does nothing. -} - -} // namespace csv - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/strings/string.cxx b/cosv/source/strings/string.cxx deleted file mode 100644 index 57f98a50e077..000000000000 --- a/cosv/source/strings/string.cxx +++ /dev/null @@ -1,235 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> - -// NOT FULLY DECLARED SERVICES -#include <string.h> - - - - -namespace csv -{ - - -inline const char * -str_from_StringOffset( const String & i_rStr, - str::size i_nOffset ) -{ - return i_nOffset < i_rStr.size() - ? i_rStr.c_str() + i_nOffset - : ""; -} - -inline const char * -str_from_ptr( const char * i_str ) -{ - - return valid_str(i_str); -} - - -//********************* String::S_Data **********************// - -inline String:: -S_Data::S_Data() - : nCount(1) -{ -} - -String:: -S_Data::S_Data( const char * i_sData, - size_type i_nValidLength ) - : aStr( str_from_ptr(i_sData), - (i_nValidLength != str::maxsize - ? i_nValidLength - : strlen(i_sData)) ), - nCount(1) -{ -} - -String:: -S_Data::~S_Data() -{ - csv_assert( nCount == 0 ); -} - -const String::S_Data * -String:: -S_Data::Acquire() const -{ -#ifdef CSV_NO_MUTABLE - ++ (const_cast< uintt& >(nCount)); -#else - ++nCount; -#endif - return this; -} - -void -String:: -S_Data::Release() const -{ -#ifdef CSV_NO_MUTABLE - -- (const_cast< uintt& >(nCount)); -#else - --nCount; -#endif - if (nCount == 0) - delete (const_cast< S_Data* >(this)); -} - - -//************************** String **************************// - - -String::String() - : pd( String::Null_().pd->Acquire() ) -{ -} - -String::String( const char * i_str ) - : pd( new S_Data(i_str) ) -{ -} - -String::String( const char * i_str, - size_type i_nLength ) - : pd( new S_Data(i_str, i_nLength) ) -{ -} - -String::String( const_iterator i_itBegin, - const_iterator i_itEnd ) - : pd( new S_Data(i_itBegin, size_type(i_itEnd - i_itBegin)) ) -{ -} - -String::String( const self & i_rStr ) - : pd( i_rStr.pd->Acquire() ) -{ -} - -String::~String() -{ - pd->Release(); -} - - -String & -String::operator=( const self & i_rStr ) -{ - i_rStr.pd->Acquire(); - pd->Release(); - pd = i_rStr.pd; - - return *this; -} - -String & -String::operator=( const char * i_str ) -{ - const S_Data * - pTemp = new S_Data(i_str); - pd->Release(); - pd = pTemp; - - return *this; -} - -void -String::assign( const char * i_str, - size_type i_nLength ) -{ - const S_Data * - pTemp = new S_Data( i_str, i_nLength ); - pd->Release(); - pd = pTemp; -} - -int -String::compare( const self & i_rStr ) const -{ - return strcmp( c_str(), i_rStr.c_str() ); -} - -int -String::compare( const CharOrder_Table & i_rOrder, - const self & i_rStr ) const -{ - return csv::compare( i_rOrder, c_str(), i_rStr.c_str() ); -} - -const String & -String::Null_() -{ - // Must not use the default constructor! Because that one calls - // this function, which would create a circular dependency. - static const String aNull_(""); - return aNull_; -} - -const char & -String::Nulch_() -{ - static const char cNull_ = '\0'; - return cNull_; -} - - -int -compare( const String & i_s1, - csv::str::position i_nStartPosition1, - const char * i_s2, - csv::str::size i_nLength ) -{ - const char * pS1 = str_from_StringOffset( i_s1, i_nStartPosition1 ); - - if ( i_nLength != csv::str::maxsize ) - return strncmp( pS1, - i_s2, - i_nLength ); - else - return strcmp( pS1, - i_s2 ); -} - -int -compare( const CharOrder_Table & i_rOrder, - const char * i_s1, - const char * i_s2 ) -{ - const char * it1 = i_s1; - const char * it2 = i_s2; - for ( ; i_rOrder(*it1) == i_rOrder(*it2) AND *it1 != '\0'; ++it1, ++it2 ) - {} - return int( i_rOrder(*it1) - i_rOrder(*it2) ); -} - -} // namespace csv - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/unittest/file_ut.cxx b/cosv/source/unittest/file_ut.cxx deleted file mode 100644 index 08c8f83a5107..000000000000 --- a/cosv/source/unittest/file_ut.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> -#include <cosv/file.hxx> - -// NOT FULLY DECLARED SERVICES -#include <ut.hxx> - -using csv::File; - - -/** @file - UnitTests for class File. -*/ - -FUT_DECL( File, Read ); -FUT_DECL( File, Write ); -FUT_DECL( File, Seek ); -FUT_DECL( File, SeekBack ); -FUT_DECL( File, SeekRelative ); - - -bool -classtest_File() -{ - csv::File aFile( "bigfile.txt", csv::CFM_RW, 0 ); - csv::File & rFile = aFile; - - rFile.Open(); - - bool ret = ftest_Read( rFile ); - ret = ftest_Write( rFile ) AND ret; - ret = ftest_SeekBack( rFile ) AND ret; - ret = ftest_SeekRelative( rFile ) AND ret; - - rFile.Close(); - - return ret; -} - - - -FUT_DECL( File, Read ) -{ - bool ret = true; - - rFile.SeekBack(0); - uintt nSourceSize = rFile.Position(); - rFile.Seek(0); - - char * pBuf = new char[nSourceSize+1]; - uintt nCount = rFile.Read(pBuf,nSourceSize); - - UT_CHECK( Read, nCount == nSourceSize ); - - return ret; -} - -FUT_DECL( File, Write ) -{ - bool ret = true; - - - - return ret; -} - -FUT_DECL( File, Seek ) -{ - bool ret = true; - - - - return ret; -} - -FUT_DECL( File, SeekBack ) -{ - bool ret = true; - - - - return ret; -} - -FUT_DECL( File, SeekRelative ) -{ - bool ret = true; - - - - return ret; -} - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/unittest/string_ut.cxx b/cosv/source/unittest/string_ut.cxx deleted file mode 100644 index f2d8d514dc79..000000000000 --- a/cosv/source/unittest/string_ut.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> - -// NOT FULLY DECLARED SERVICES -#include <ut.hxx> - -using csv::SimpleString; - - -/** @file - UnitTests for class String. -*/ - -inline bool -check_value( const String & a, const char * b ) -{ - return strcmp( a.c_str(), b ) == 0; -} - - -bool -classtest_String( csv::SimpleString & rSimpleString ) -{ - String x1; - UT_CHECK( String(), check_value(x1,"") ) - - const char * s2a = ""; - String x2a(s2a); - UT_CHECK( String(const char*), check_value(x2a,s2a) ) - - const char * s2b = "_zluoadninger prrg chii(/%$##@\\\"'''fh kl"; - String x2b(s2b); - UT_CHECK( String(const char*), check_value(x2b,s2b) ) - - - bool ret = ftest_Read( rSimpleString ); - ret &= ftest_Write( rSimpleString ) AND ret; - ret &= ftest_SeekBack( rSimpleString ) AND ret; - ret &= ftest_SeekRelative( rSimpleString ) AND ret; - - rSimpleString.Close(); - - return ret; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/unittest/ut.hxx b/cosv/source/unittest/ut.hxx deleted file mode 100644 index fcd324a71ad5..000000000000 --- a/cosv/source/unittest/ut.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef COSV_UNITTEST_UT_HXX -#define COSV_UNITTEST_UT_HXX - - -#define UT_CHECK( fname, cond ) \ - if ( NOT (cond) ) { std::cerr << "ftest_" << #fname << " " << #cond << endl; \ - ret = false; } - -#define CUT_DECL( nsp, cname ) \ - bool classtest_##cname() -#define FUT_DECL( cname, fname ) \ - bool ftest_##fname( cname & r##cname ) - -#define UT_RESULT( result ) \ - if (result ) std::cout << "All unit tests passed successfully." << std::endl; \ - else std::cout << "Errors in unit tests.\n" << std::endl - - - -CUT_DECL( csv, File ); -CUT_DECL( csv, String ); - -#endif - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cosv/source/unittest/ut_main.cxx b/cosv/source/unittest/ut_main.cxx deleted file mode 100644 index 016025e08509..000000000000 --- a/cosv/source/unittest/ut_main.cxx +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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> - -#include <cosv/file.hxx> -#include <cosv/simplestring.hxx> -#include "ut.hxx" - - - -int _cdecl -main(int argc, char * argv[]) -{ - bool ret = classtest_File(); - ret = classtest_SimpleString AND ret; - - UT_RESULT( ret ); - - return 0; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |