aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jaulibs/dblmenge.cpp22
-rw-r--r--src/jaulibs/hashlist.h44
-rw-r--r--src/jaulibs/hashstr.cpp42
-rw-r--r--src/jaulibs/hashstr.h2
-rw-r--r--src/jaulibs/jauio.cpp31
-rw-r--r--src/jaulibs/jauio.h11
-rw-r--r--src/jaulibs/liste.h8
-rw-r--r--src/jaulibs/menge.h3
-rw-r--r--src/jaulibs/sortlist.h4
-rw-r--r--src/jaulibs/sortstr.cpp10
-rw-r--r--src/jaulibs/strclass.cpp107
-rw-r--r--src/jaulibs/strclass.h7
12 files changed, 148 insertions, 143 deletions
diff --git a/src/jaulibs/dblmenge.cpp b/src/jaulibs/dblmenge.cpp
index 03b99fc..f790d90 100644
--- a/src/jaulibs/dblmenge.cpp
+++ b/src/jaulibs/dblmenge.cpp
@@ -17,23 +17,19 @@
*
*/
-# include "menge.h"
+#include "menge.h"
-static double maschEps()
-{
- double x = 1.0, res;
- do res = x;
- while (1.0 + (x /= 2) > 1.0);
- return res;
-}
+#include <cmath>
+#include <limits>
-const double eps = maschEps();
-
-int Menge<double>::istElement(const double& x)
+template<> int Menge<double>::istElement(const double& x)
{
- for (int i = 0; i < card(); i++)
- if (fabs((*this)[i] - x) < eps*fabs(x))
+
+ for (int i = 0; i < card(); i++) {
+ if( ::fabs( (*this)[i] - x ) < std::numeric_limits<double>::epsilon() * ::fabs(x) ) {
return i;
+ }
+ }
return -1;
}
diff --git a/src/jaulibs/hashlist.h b/src/jaulibs/hashlist.h
index b4aa497..bc0a357 100644
--- a/src/jaulibs/hashlist.h
+++ b/src/jaulibs/hashlist.h
@@ -97,7 +97,7 @@
int fuegeEin( const Tmp& );
int loesche( int i );
int findeElement( const Tmp& ) const ;
- virtual int HashFunktion(const Tmp &a) const = NULL;
+ virtual int HashFunktion(const Tmp &a) const = nullptr;
virtual void Ausgabe (ostream&);
private:
@@ -122,18 +122,18 @@
Size=m.Size;
int i;
- assert(HashArray==NULL);
+ assert(HashArray==nullptr);
assert(HEAP_CHECK()>=1);
if(Size>0)
{
- if( ( HashArray=new SortListe<Tmp>*[Size] ) == NULL )
+ if( ( HashArray=new SortListe<Tmp>*[Size] ) == nullptr )
{
fprintf(stderr, "<HashListe> ERROR : Es wurde versucht ein HashArray\n");
fprintf(stderr, "<HashListe> mit der Groesse %d zu eroeffnen.\n", Size);
INT_ERR(__LINE__);
}
- if( ( AnzahlElemente=new int[Size] ) == NULL )
+ if( ( AnzahlElemente=new int[Size] ) == nullptr )
{
fprintf(stderr, "<HashListe> ERROR : Es wurde versucht ein int-Array\n");
fprintf(stderr, "<HashListe> fuer internen Gebrauch mit der Groesse %d zu eroeffnen.\n", Size);
@@ -143,11 +143,11 @@
// Initialisierung .. Copy
for( i=0; i<Size; i++ )
{
- if(m.HashArray[i]!=NULL)
+ if(m.HashArray[i]!=nullptr)
{
HashArray[i]=new SortListe<Tmp>(*m.HashArray[i]);
- if(HashArray[i]==NULL) INT_ERR(__LINE__);
- } else HashArray[i]=NULL;
+ if(HashArray[i]==nullptr) INT_ERR(__LINE__);
+ } else HashArray[i]=nullptr;
AnzahlElemente[i]=m.AnzahlElemente[i];
}
assert(HEAP_CHECK()>=1);
@@ -164,34 +164,34 @@
for(int i=0; i<Size; i++ )
{
assert(HEAP_CHECK()>=1);
- if(HashArray[i]!=NULL)
+ if(HashArray[i]!=nullptr)
delete HashArray[i];
}
assert(HEAP_CHECK()>=1);
delete[] HashArray;
- HashArray=NULL;
+ HashArray=nullptr;
delete[] AnzahlElemente;
- AnzahlElemente=NULL;
+ AnzahlElemente=nullptr;
assert(HEAP_CHECK()>=1);
}
}
template<class Tmp> HashListe<Tmp>::HashListe( int size )
- : Size(size), anzahl(0), HashArray(NULL), AnzahlElemente(NULL)
+ : Size(size), anzahl(0), HashArray(nullptr), AnzahlElemente(nullptr)
{
- assert(HashArray==NULL);
+ assert(HashArray==nullptr);
assert(HEAP_CHECK()>=1);
if(size>0)
{
- if( ( HashArray= new SortListe<Tmp>*[Size] ) == NULL )
+ if( ( HashArray= new SortListe<Tmp>*[Size] ) == nullptr )
{
fprintf(stderr, "<HashListe> ERROR : Es wurde versucht ein HashArray\n");
fprintf(stderr, "<HashListe> mit der Groesse %d zu eroeffnen.\n", Size);
INT_ERR(__LINE__);
}
- assert( HashArray!=NULL );
+ assert( HashArray!=nullptr );
assert(HEAP_CHECK()>=1);
- if( ( AnzahlElemente=new int[Size] ) == NULL )
+ if( ( AnzahlElemente=new int[Size] ) == nullptr )
{
fprintf(stderr, "<HashListe> ERROR : Es wurde versucht ein int-Array\n");
fprintf(stderr, "<HashListe> fuer internen Gebrauch mit der Groesse %d zu eroeffnen.\n", Size);
@@ -201,7 +201,7 @@
// initialisierung
for ( int i=0; i<Size; i++ )
{
- HashArray[i]=NULL;
+ HashArray[i]=nullptr;
AnzahlElemente[i]=0;
}
assert(HEAP_CHECK()>=1);
@@ -209,7 +209,7 @@
}
template<class Tmp> HashListe<Tmp>::HashListe( const HashListe<Tmp> &m )
- : HashArray(NULL), AnzahlElemente(NULL), anzahl(0), Size(0)
+ : HashArray(nullptr), AnzahlElemente(nullptr), anzahl(0), Size(0)
{ Copy(m); }
template<class Tmp> HashListe<Tmp>& HashListe<Tmp>::operator=(const HashListe<Tmp> &m)
@@ -233,7 +233,7 @@
INT_ERR(__LINE__);
}
assert(HEAP_CHECK()>=1);
- assert(HashArray[HPos]!=NULL);
+ assert(HashArray[HPos]!=nullptr);
return (*HashArray[HPos])[SPos];
}
@@ -245,11 +245,11 @@
assert (HPos>=0);
assert (HPos<Size);
assert(HEAP_CHECK()>=1);
- if(HashArray[HPos]==NULL)
+ if(HashArray[HPos]==nullptr)
{
// SortListe<Tmp> Erzeugen
HashArray[HPos]=new SortListe<Tmp>();
- if( HashArray[HPos] == NULL ) INT_ERR(__LINE__);
+ if( HashArray[HPos] == nullptr ) INT_ERR(__LINE__);
}
int SPos=HashArray[HPos]->fuegeEin(a);
assert(HEAP_CHECK()>=1);
@@ -270,7 +270,7 @@
INT_ERR(__LINE__);
}
assert(HEAP_CHECK()>=1);
- assert(HashArray[HPos]!=NULL);
+ assert(HashArray[HPos]!=nullptr);
if(SPos>=HashArray[HPos]->laenge()) INT_ERR(__LINE__);
HashArray[HPos]->loesche(SPos);
assert(HEAP_CHECK()>=1);
@@ -286,7 +286,7 @@
int HPos=abs(HashFunktion(x)%Size);
assert (HPos>=0);
assert (HPos>=0);
- if(HashArray[HPos]!=NULL)
+ if(HashArray[HPos]!=nullptr)
{
int SPos=HashArray[HPos]->findeElement(x);
if(SPos>=0) return HoleLinearerIndex(HPos, SPos);
diff --git a/src/jaulibs/hashstr.cpp b/src/jaulibs/hashstr.cpp
index 6d97188..ebd3879 100644
--- a/src/jaulibs/hashstr.cpp
+++ b/src/jaulibs/hashstr.cpp
@@ -33,18 +33,18 @@ void HashStrClassListe::Copy(const HashStrClassListe &m)
Size=m.Size;
int i;
- assert(HashArray==NULL);
+ assert(HashArray==nullptr);
assert(HEAP_CHECK()>=1);
if(Size>0)
{
- if( ( HashArray=new SortListe<StrClass>*[Size] ) == NULL )
+ if( ( HashArray=new SortListe<StrClass>*[Size] ) == nullptr )
{
fprintf(stderr, "<HashStrClassListe> ERROR : Es wurde versucht ein HashArray\n");
fprintf(stderr, "<HashStrClassListe> mit der Groesse %d zu eroeffnen.\n", Size);
INT_ERR(__LINE__);
}
- if( ( AnzahlElemente=new int[Size] ) == NULL )
+ if( ( AnzahlElemente=new int[Size] ) == nullptr )
{
fprintf(stderr, "<HashStrClassListe> ERROR : Es wurde versucht ein int-Array\n");
fprintf(stderr, "<HashStrClassListe> fuer internen Gebrauch mit der Groesse %d zu eroeffnen.\n", Size);
@@ -54,11 +54,11 @@ void HashStrClassListe::Copy(const HashStrClassListe &m)
// Initialisierung .. Copy
for( i=0; i<Size; i++ )
{
- if(m.HashArray[i]!=NULL)
+ if(m.HashArray[i]!=nullptr)
{
HashArray[i]=new SortListe<StrClass>(*m.HashArray[i]);
- if(HashArray[i]==NULL) INT_ERR(__LINE__);
- } else HashArray[i]=NULL;
+ if(HashArray[i]==nullptr) INT_ERR(__LINE__);
+ } else HashArray[i]=nullptr;
AnzahlElemente[i]=m.AnzahlElemente[i];
}
assert(HEAP_CHECK()>=1);
@@ -75,34 +75,34 @@ void HashStrClassListe::Dest()
for(int i=0; i<Size; i++ )
{
assert(HEAP_CHECK()>=1);
- if(HashArray[i]!=NULL)
+ if(HashArray[i]!=nullptr)
delete HashArray[i];
}
assert(HEAP_CHECK()>=1);
delete[] HashArray;
- HashArray=NULL;
+ HashArray=nullptr;
delete[] AnzahlElemente;
- AnzahlElemente=NULL;
+ AnzahlElemente=nullptr;
assert(HEAP_CHECK()>=1);
}
}
HashStrClassListe::HashStrClassListe( int size )
-: Size(size), anzahl(0), HashArray(NULL), AnzahlElemente(NULL)
+: HashArray(nullptr), AnzahlElemente(nullptr), Size(size), anzahl(0)
{
- assert(HashArray==NULL);
+ assert(HashArray==nullptr);
assert(HEAP_CHECK()>=1);
if(size>0)
{
- if( ( HashArray= new SortListe<StrClass>*[Size] ) == NULL )
+ if( ( HashArray= new SortListe<StrClass>*[Size] ) == nullptr )
{
fprintf(stderr, "<HashStrClassListe> ERROR : Es wurde versucht ein HashArray\n");
fprintf(stderr, "<HashStrClassListe> mit der Groesse %d zu eroeffnen.\n", Size);
INT_ERR(__LINE__);
}
- assert( HashArray!=NULL );
+ assert( HashArray!=nullptr );
assert(HEAP_CHECK()>=1);
- if( ( AnzahlElemente=new int[Size] ) == NULL )
+ if( ( AnzahlElemente=new int[Size] ) == nullptr )
{
fprintf(stderr, "<HashStrClassListe> ERROR : Es wurde versucht ein int-Array\n");
fprintf(stderr, "<HashStrClassListe> fuer internen Gebrauch mit der Groesse %d zu eroeffnen.\n", Size);
@@ -112,7 +112,7 @@ HashStrClassListe::HashStrClassListe( int size )
// initialisierung
for ( int i=0; i<Size; i++ )
{
- HashArray[i]=NULL;
+ HashArray[i]=nullptr;
AnzahlElemente[i]=0;
}
assert(HEAP_CHECK()>=1);
@@ -120,7 +120,7 @@ HashStrClassListe::HashStrClassListe( int size )
}
HashStrClassListe::HashStrClassListe( const HashStrClassListe &m )
-: HashArray(NULL), AnzahlElemente(NULL), anzahl(0), Size(0)
+: HashArray(nullptr), AnzahlElemente(nullptr), Size(0), anzahl(0)
{ Copy(m); }
HashStrClassListe& HashStrClassListe::operator=(const HashStrClassListe &m)
@@ -144,7 +144,7 @@ StrClass& HashStrClassListe::operator[](int i) const
INT_ERR(__LINE__);
}
assert(HEAP_CHECK()>=1);
- assert(HashArray[HPos]!=NULL);
+ assert(HashArray[HPos]!=nullptr);
return HashArray[HPos]->operator[](SPos);
}
@@ -156,11 +156,11 @@ int HashStrClassListe::fuegeEin(const StrClass& a)
assert (HPos>=0);
assert (HPos<Size);
assert(HEAP_CHECK()>=1);
- if(HashArray[HPos]==NULL)
+ if(HashArray[HPos]==nullptr)
{
// SortListe<StrClass> Erzeugen
HashArray[HPos]=new SortListe<StrClass>();
- if( HashArray[HPos] == NULL ) INT_ERR(__LINE__);
+ if( HashArray[HPos] == nullptr ) INT_ERR(__LINE__);
}
int SPos=HashArray[HPos]->fuegeEin(a);
assert(HEAP_CHECK()>=1);
@@ -181,7 +181,7 @@ int HashStrClassListe::loesche(int i)
INT_ERR(__LINE__);
}
assert(HEAP_CHECK()>=1);
- assert(HashArray[HPos]!=NULL);
+ assert(HashArray[HPos]!=nullptr);
if(SPos>=HashArray[HPos]->laenge()) INT_ERR(__LINE__);
HashArray[HPos]->loesche(SPos);
assert(HEAP_CHECK()>=1);
@@ -197,7 +197,7 @@ int HashStrClassListe::findeElement(const StrClass& x) const
int HPos=abs(HashFunktion(x)%Size);
assert (HPos>=0);
assert (HPos>=0);
- if(HashArray[HPos]!=NULL)
+ if(HashArray[HPos]!=nullptr)
{
int SPos=HashArray[HPos]->findeElement(x);
if(SPos>=0) return HoleLinearerIndex(HPos, SPos);
diff --git a/src/jaulibs/hashstr.h b/src/jaulibs/hashstr.h
index 063d231..a26da23 100644
--- a/src/jaulibs/hashstr.h
+++ b/src/jaulibs/hashstr.h
@@ -92,7 +92,7 @@
int fuegeEin( const StrClass& );
int loesche( int i );
int findeElement( const StrClass& ) const ;
- virtual int HashFunktion(const StrClass &a) const = NULL;
+ virtual int HashFunktion(const StrClass &a) const = 0;
private:
void AktualisiereAnzahlElementePlus(int HPos);
diff --git a/src/jaulibs/jauio.cpp b/src/jaulibs/jauio.cpp
index 3bea5c9..79e00bf 100644
--- a/src/jaulibs/jauio.cpp
+++ b/src/jaulibs/jauio.cpp
@@ -8,7 +8,7 @@
* 33615 Bielefeld
* 0521/139228
* Erstellungsdatum: 05.05.1994
- * �nderungsdatum : 28.07.1994
+ * �nderungsdatum : 28.07.1994
*
*
* $Log: jauio.cc $
@@ -26,7 +26,14 @@
*
*/
-# include "jauio.h"
+#include "jauio.h"
+
+#include <cstring>
+#include <cstdio>
+
+#include "interror.h"
+#include "assert.h"
+
/*DOCST------------------------------------------------------------------------------
@@ -50,9 +57,9 @@
- Returncode
------------
OK : SpeicherAdresse.
- Der Speicher muss sp�ter mittels free wieder freigegeben werden.
+ Der Speicher muss sp�ter mittels free wieder freigegeben werden.
- FAlSE : NULL
+ FAlSE : nullptr
- Historie
----------
@@ -60,18 +67,18 @@
2019-12-17 Sven Gothel: Introduce reusable buffer passing etc
------------------------------------------------------------------------------DOCEND*/
-char *GetFileInBuffer(const char *fName, const char *buffer, const size_t buffer_len, size_t *nbytes)
+char *GetFileInBuffer(const char *fName, char *buffer, const size_t buffer_len, size_t *nbytes)
{
- FILE *fTmp=NULL;
+ FILE *fTmp=nullptr;
size_t i, ReadBytes;
char *res;
- if(buffer_len==0 || NULL == buffer) {
+ if(buffer_len==0 || nullptr == buffer) {
fprintf(stderr, "Illegal Arguments\n");
INT_ERR(__LINE__);
}
- if( (fTmp=fopen(fName,"rt")) == NULL )
+ if( (fTmp=fopen(fName,"rt")) == nullptr )
{
INT_ERR(__LINE__);
}
@@ -87,15 +94,13 @@ char *GetFileInBuffer(const char *fName, const char *buffer, const size_t buffer
if(feof(fTmp)==0)
{
*nbytes=0;
- res=NULL;
+ res=nullptr;
} else {
*nbytes=i+1;
- Buffer[i]=0;
- res=malloc(i+1);
+ buffer[i]=0;
+ res=static_cast<char*>( malloc(i+1) );
memcpy(res, buffer, i+1);
}
-
-
fclose(fTmp);
return res;
diff --git a/src/jaulibs/jauio.h b/src/jaulibs/jauio.h
index 2d97981..bba75e9 100644
--- a/src/jaulibs/jauio.h
+++ b/src/jaulibs/jauio.h
@@ -6,7 +6,7 @@
* 33615 Bielefeld
* 0521/139228
* Erstellungsdatum: 05.05.1994
- * �nderungsdatum : 28.07.1994
+ * �nderungsdatum : 28.07.1994
*
*
* 2019-12-17 Sven Gothel: Introduce reusable buffer passing etc
@@ -26,14 +26,11 @@
*/
#ifndef _JAUIO_H
- # define _JAUIO_H
+#define _JAUIO_H
- # include <stdlib.h>
- # include <stdio.h>
- # include "interror.h"
- # include "assert.h"
+#include <cstdlib>
- char *GetFileInBuffer(const char *fName, const char *buffer, const size_t buffer_len, size_t *nbytes);
+char *GetFileInBuffer(const char *fName, char *buffer, const size_t buffer_len, size_t *nbytes);
#endif
diff --git a/src/jaulibs/liste.h b/src/jaulibs/liste.h
index 506b526..dc72b94 100644
--- a/src/jaulibs/liste.h
+++ b/src/jaulibs/liste.h
@@ -378,8 +378,8 @@
}
else anfang();
assert ( aktInd >= 0 );
- assert ( ( laenge()==0 && aktInd==0 && aktZgr==NULL && start==NULL ) ||
- ( laenge()>0 && aktZgr!=NULL && start!=NULL )
+ assert ( ( laenge()==0 && aktInd==0 && aktZgr==nullptr && start==nullptr ) ||
+ ( laenge()>0 && aktZgr!=nullptr && start!=nullptr )
) ;
#ifdef __LISTE_PARANOIA__
ParanoiaCheck();
@@ -449,12 +449,12 @@
while ( pi )
{
i++;
- if(pi->vorg!=NULL)
+ if(pi->vorg!=nullptr)
{
if(pi->vorg->nachf!=pi)
INT_ERR(__LINE__);
}
- if(pi->nachf!=NULL)
+ if(pi->nachf!=nullptr)
{
if(pi->nachf->vorg!=pi)
INT_ERR(__LINE__);
diff --git a/src/jaulibs/menge.h b/src/jaulibs/menge.h
index c2a35bf..9fbf008 100644
--- a/src/jaulibs/menge.h
+++ b/src/jaulibs/menge.h
@@ -40,6 +40,9 @@
int loesche(const T&);
void inhalt() const;
Menge operator*(Menge&) const;
+ const T& operator[](int i) const { return l[i]; }
+ T& operator[](int i) { return l[i]; }
+
private:
Liste<T> l;
};
diff --git a/src/jaulibs/sortlist.h b/src/jaulibs/sortlist.h
index 3edbd07..dceddf4 100644
--- a/src/jaulibs/sortlist.h
+++ b/src/jaulibs/sortlist.h
@@ -44,8 +44,8 @@
public:
enum typ { UP, DOWN };
SortListe(typ Type=UP) : Liste<Tmp>(), Type(Type) { }
- SortListe(const SortListe& m) : Type(m.Type), Liste<Tmp>(m) {}
- virtual ~SortListe() { }
+ SortListe(const SortListe& m) : Liste<Tmp>(m), Type(m.Type) {}
+ virtual ~SortListe() { }
SortListe& operator=(const SortListe &m)
{
diff --git a/src/jaulibs/sortstr.cpp b/src/jaulibs/sortstr.cpp
index 9946ac6..1ed3b57 100644
--- a/src/jaulibs/sortstr.cpp
+++ b/src/jaulibs/sortstr.cpp
@@ -33,6 +33,8 @@
# include "sortlist.h"
# include "strclass.h"
+#include <cstring>
+
/*------------------------------------------------------------------------------
Variante fuer StrClass der Methode findeIndex der template
@@ -88,7 +90,7 @@
else *o == x => i=o, done
------------------------------------------------------------------------------*/
-int SortListe<StrClass>::findeIndex(const StrClass &x, int &u, int &o) const
+template<> int SortListe<StrClass>::findeIndex(const StrClass &x, int &u, int &o) const
{
int i=0;
int done=0;
@@ -98,8 +100,8 @@ int SortListe<StrClass>::findeIndex(const StrClass &x, int &u, int &o) const
if ( (*this).laenge() == 0 ) return -1;
//Anfangsgrenzen austesten
- result_o=strcmp( (*this)[o].GetStrPtr(), x.GetStrPtr() );
- result_u=strcmp( (*this)[u].GetStrPtr(), x.GetStrPtr() );
+ result_o=strcmp( (*this)[o].getStrPtr(), x.getStrPtr() );
+ result_u=strcmp( (*this)[u].getStrPtr(), x.getStrPtr() );
if(Type==UP)
{
if( u == o && result_o < 0 ) o++;
@@ -119,7 +121,7 @@ int SortListe<StrClass>::findeIndex(const StrClass &x, int &u, int &o) const
while ( !done && o-u>1)
{
i=(u+o)/2;
- result=strcmp( (*this)[i].GetStrPtr(), x.GetStrPtr() );
+ result=strcmp( (*this)[i].getStrPtr(), x.getStrPtr() );
if ( result < 0 )
{
if ( Type==UP ) u=i;
diff --git a/src/jaulibs/strclass.cpp b/src/jaulibs/strclass.cpp
index 6e1a4e1..fd97000 100644
--- a/src/jaulibs/strclass.cpp
+++ b/src/jaulibs/strclass.cpp
@@ -29,7 +29,12 @@
/*************************************************************************/
#include "strclass.h"
+
#include <climits>
+#include <cstdio>
+#include <cstring>
+
+#include "interror.h"
std::ostream& operator<< (std::ostream& OS, StrClass& str)
{
@@ -41,45 +46,45 @@ std::ostream& operator<< (std::ostream& OS, StrClass& str)
return OS;
}
-void StrClass::copy(const char *m)
+void StrClass::copy(const char *o)
{
- if(m!=nullptr)
+ if(o!=nullptr)
{
// FIXME: consider using strnlen(..) using maxlen!
{
- const size_t _length = strlen(m);
+ const size_t _length = strlen(o);
if( _length > INT_MAX ) {
INT_ERR(__LINE__);
}
m_length = (int) _length;
}
- if ( ( StrPtr=new char[length+1] ) == nullptr )
+ if ( ( StrPtr=new char[m_length+1] ) == nullptr )
{
fprintf(stderr,"Insufficient memory\n");
INT_ERR(__LINE__);
}
- strncpy(StrPtr, m, length+1);
- // StrPtr[length] = 0; // explicit EOS in case using strnlen(..) using maxlen
+ strncpy(StrPtr, o, m_length+1);
+ // StrPtr[m_length] = 0; // explicit EOS in case using strnlen(..) using maxlen
} else {
StrPtr=nullptr;
m_length=0;
}
}
-void StrClass::copy(const StrClass &m)
+void StrClass::copy(const StrClass &o)
{
- if( 0 < m.length() )
+ if( 0 < o.length() )
{
- length = m.length();
- if ( ( StrPtr=new char[length+1] ) == nullptr )
+ m_length = o.length();
+ if ( ( StrPtr=new char[m_length+1] ) == nullptr )
{
fprintf(stderr,"Insufficient memory\n");
INT_ERR(__LINE__);
}
- strncpy(StrPtr, m, length+1);
+ strncpy(StrPtr, o, m_length+1);
} else {
StrPtr=nullptr;
- length=0;
+ m_length=0;
}
}
@@ -90,13 +95,13 @@ void StrClass::dest()
delete[] StrPtr;
StrPtr=nullptr;
}
- length = 0;
+ m_length = 0;
}
-void StrClass::strcat(const StrClass &m)
+void StrClass::strcat(const StrClass &o)
{
char *buffer;
- const int bufferLen = length() + m.length() + 1;
+ const int bufferLen = length() + o.length() + 1;
if( 1 == bufferLen ) {
return;
}
@@ -109,109 +114,109 @@ void StrClass::strcat(const StrClass &m)
buffer[0]=0;
}
- if( 0 < m.length() ) {
- strncpy(buffer+length(), m.StrPtr, m.length()+1);
+ if( 0 < o.length() ) {
+ strncpy(buffer+length(), o.StrPtr, o.length()+1);
}
if( nullptr != StrPtr ) {
delete[] StrPtr;
}
StrPtr=buffer;
- length=bufferLen;
+ m_length=bufferLen;
}
-StrClass& StrClass::operator=(const StrClass &m)
+StrClass& StrClass::operator=(const StrClass &o)
{
- if(this != &m)
+ if(this != &o)
{
if( nullptr != StrPtr ) {
delete[] StrPtr;
}
- copy(m);
+ copy(o);
}
return *this;
}
-StrClass& StrClass::operator=(const char *StrPtr)
+StrClass& StrClass::operator=(const char *o)
{
- if(this->StrPtr != StrPtr)
+ if(this->StrPtr != o)
{
- if( nullptr != StrPtr ) {
- delete[] StrPtr;
+ if( nullptr != o ) {
+ delete[] o;
}
- copy(StrPtr);
+ copy(o);
}
return *this;
}
-int StrClass::operator==(const StrClass &m) const
+int StrClass::operator==(const StrClass &o) const
{
- if(this == &m || this->StrPtr == m.StrPtr ) {
+ if(this == &o || this->StrPtr == o.StrPtr ) {
return 1;
}
if ( 0 == length() )
{
- return 0 == m.length();
+ return 0 == o.length();
}
- if ( 0 == m.length() ) {
+ if ( 0 == o.length() ) {
return 0;
}
- if ( strcmp(StrPtr, m.StrPtr) == 0 ) {
+ if ( strcmp(StrPtr, o.StrPtr) == 0 ) {
return 1;
}
return 0;
}
-int StrClass::operator>=(const StrClass &m) const
+int StrClass::operator>=(const StrClass &o) const
{
if ( 0 == length() )
{
- return 0 == m.length();
+ return 0 == o.length();
}
- if ( 0 == m.length() ) {
+ if ( 0 == o.length() ) {
return 1;
}
- int b=strcmp(StrPtr, m.StrPtr);
+ int b=strcmp(StrPtr, o.StrPtr);
if ( b == 0 || b>0 ) {
return 1;
}
return 0;
}
-int StrClass::operator<=(const StrClass &m) const
+int StrClass::operator<=(const StrClass &o) const
{
if ( 0 == length() ) return 1;
- if ( 0 == m.length() ) return 0;
+ if ( 0 == o.length() ) return 0;
- int b=strcmp(StrPtr, m.StrPtr);
+ int b=strcmp(StrPtr, o.StrPtr);
if ( b == 0 || b<0 ) {
return 1;
}
return 0;
}
-int StrClass::operator>(const StrClass &m) const
+int StrClass::operator>(const StrClass &o) const
{
if ( 0 == length() ) return 0;
- if ( 0 == m.length() ) return 1;
+ if ( 0 == o.length() ) return 1;
- if ( strcmp(StrPtr, m.StrPtr) > 0 ) {
+ if ( strcmp(StrPtr, o.StrPtr) > 0 ) {
return 1;
}
return 0;
}
-int StrClass::operator<(const StrClass &m) const
+int StrClass::operator<(const StrClass &o) const
{
if ( 0 == length() ) return 1;
- if ( 0 == m.length() ) return 0;
+ if ( 0 == o.length() ) return 0;
- if ( strcmp(StrPtr, m.StrPtr) < 0 ) {
+ if ( strcmp(StrPtr, o.StrPtr) < 0 ) {
return 1;
}
return 0;
@@ -248,15 +253,15 @@ int StrClass::delSubStr(const StrClass &SubStr, int StartIndex)
if( 0 <= i ) {
const int l = length();
const int l2 = SubStr.length();
- length=l-l2;
- char *newstr = new char[length+1];
+ m_length=l-l2;
+ char *newstr = new char[m_length+1];
if( !newstr ) {
INT_ERR(__LINE__);
}
if( 0 < i ) {
strncpy(newstr, StrPtr, i); // w/o EOS
}
- strncpy(newstr+i, StrPtr+i+l2, length+1-i);
+ strncpy(newstr+i, StrPtr+i+l2, m_length+1-i);
delete[] StrPtr;
StrPtr=newstr;
}
@@ -271,8 +276,8 @@ bool StrClass::insertSubStr(const StrClass &SubStr, int Index)
if( l < Index ) return false;
if( 0 == l2 ) return true;
- length = l+l2;
- char *newstr=new char[length+1];
+ m_length = l+l2;
+ char *newstr=new char[m_length+1];
if(!newstr) {
INT_ERR(__LINE__);
}
@@ -281,9 +286,9 @@ bool StrClass::insertSubStr(const StrClass &SubStr, int Index)
}
newstr[Index]=0;
- strcat(newstr, SubStr.StrPtr);
+ ::strcat(newstr, SubStr.StrPtr);
- if(Index<l) strcat(newstr, &(StrPtr[Index]));
+ if(Index<l) ::strcat(newstr, &(StrPtr[Index]));
delete[] StrPtr;
StrPtr=newstr;
diff --git a/src/jaulibs/strclass.h b/src/jaulibs/strclass.h
index f0fa0de..7f8dfed 100644
--- a/src/jaulibs/strclass.h
+++ b/src/jaulibs/strclass.h
@@ -31,9 +31,6 @@
# define _STRCLASS_H
# include <iostream>
- # include <cstdio>
- # include <cstring>
- # include "interror.h"
class StrClass {
@@ -60,8 +57,8 @@
// operator char *(void) { return StrPtr; }
char & operator[](int i) { return StrPtr[i]; }
char operator[](int i) const { return StrPtr[i]; }
- int length(void) const { return length; }
- operator unsigned int() { return (unsigned int)length; }
+ int length(void) const { return m_length; }
+ operator unsigned int() { return (unsigned int)m_length; }
// rather old, but still a member-function because of compatibility ... :
char *getStrPtr(void) { return StrPtr; }