From 76718abdb2138623102398a10f3228e576dd0ae8 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 10 Feb 2010 01:27:27 +0000 Subject: Added abandoned KDE3 version of kdiff3 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdiff3@1088041 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- diff_ext_for_kdiff3/diffextstring.h | 157 ++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 diff_ext_for_kdiff3/diffextstring.h (limited to 'diff_ext_for_kdiff3/diffextstring.h') diff --git a/diff_ext_for_kdiff3/diffextstring.h b/diff_ext_for_kdiff3/diffextstring.h new file mode 100644 index 0000000..132512e --- /dev/null +++ b/diff_ext_for_kdiff3/diffextstring.h @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2003, Sergey Zorin. All rights reserved. + * + * This software is distributable under the BSD license. See the terms of the + * BSD license in the LICENSE file provided with this software. + * + */ + +#ifndef __string_h__ +#define __string_h__ + +#include +#include + +#include +#include + +class STRING; +inline STRING operator+( const STRING& s1, const STRING& s2); + +class STRING { + public: + static const int begin = 0; + static const int end = -1; + + public: + STRING(const STRING& s) { + _str = new TCHAR[s.length()+1]; + lstrcpy(_str, s); + } + + STRING(const TCHAR* str = TEXT("")) { + _str = new TCHAR[lstrlen(str)+1]; + lstrcpy(_str, str); + } + + ~STRING() { + delete[] _str; + } + + void resize( size_t newLength ) + { + size_t oldLength = length(); + if ( newLength < oldLength ) { + _str[newLength] = 0; // Just truncate the string + } else if( newLength>oldLength) { + TCHAR* p = new TCHAR[ newLength + 1 ]; + lstrcpy(p, _str); + for( size_t i=oldLength; i