Skip to content

Commit 431798c

Browse files
committed
code quality
1 parent e0487cd commit 431798c

3 files changed

Lines changed: 46 additions & 44 deletions

File tree

include/ticcutils/bz2stream.h

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ extern "C" {
127127
/// buffer at all costs.
128128
class bz2outbuf : public std::streambuf {
129129
private:
130-
bz2outbuf( const bz2outbuf& ); // no copies please
131-
bz2outbuf& operator=( const bz2outbuf& ); // no copies please
130+
bz2outbuf( const bz2outbuf& ) = delete; // no copies please
131+
bz2outbuf& operator=( const bz2outbuf& ) = delete; // no copies please
132132
protected:
133133
std::streambuf* dest;
134134
std::vector<char> buffer;
@@ -305,12 +305,12 @@ class bz2outbuf : public std::streambuf {
305305
/// std::exception derived exception. All exceptions but
306306
/// std::bad_alloc include descriptions of what went bad. Thus
307307
/// using the what() member makes sense.
308-
bz2outbuf(std::streambuf* _dest, unsigned int block_size_100K = 9,
309-
unsigned int verbosity = 0, unsigned int work_factor = 0,
310-
bzalloc_ptr bzalloc = NULL, bzfree_ptr bzfree = NULL,
311-
void* opaque = NULL, size_t stream_buffer_size = 2048,
312-
size_t out_buffer_size = 2048)
313-
: dest(_dest)
308+
explicit bz2outbuf(std::streambuf* _dest, unsigned int block_size_100K = 9,
309+
unsigned int verbosity = 0, unsigned int work_factor = 0,
310+
bzalloc_ptr bzalloc = NULL, bzfree_ptr bzfree = NULL,
311+
void* opaque = NULL, size_t stream_buffer_size = 2048,
312+
size_t out_buffer_size = 2048)
313+
: dest(_dest)
314314
{
315315
// check the parameters
316316
if (block_size_100K > 9)
@@ -386,19 +386,19 @@ class bz2outbuf : public std::streambuf {
386386
/// stream buffer you want.
387387
class bz2ostream : public std::ostream {
388388
protected:
389-
bz2outbuf buf;
389+
bz2outbuf buf;
390390
public:
391-
/// \brief Creates a new bz2ostream object. See
392-
/// bz2outbuf::bz2outbuf for an explanation of the parameters.
393-
bz2ostream(std::streambuf* dest, unsigned int block_size_100K = 9,
394-
unsigned int verbosity = 0, unsigned int work_factor = 0,
395-
bzalloc_ptr bzalloc = NULL, bzfree_ptr bzfree = NULL,
396-
void* opaque = NULL, size_t buffer_size = 1024,
397-
size_t out_buffer_size = 1024)
398-
: std::ostream(&buf),
399-
buf(dest, block_size_100K, verbosity, work_factor, bzalloc, bzfree,
400-
opaque, buffer_size, out_buffer_size)
401-
{}
391+
/// \brief Creates a new bz2ostream object. See
392+
/// bz2outbuf::bz2outbuf for an explanation of the parameters.
393+
explicit bz2ostream(std::streambuf* dest, unsigned int block_size_100K = 9,
394+
unsigned int verbosity = 0, unsigned int work_factor = 0,
395+
bzalloc_ptr bzalloc = NULL, bzfree_ptr bzfree = NULL,
396+
void* opaque = NULL, size_t buffer_size = 1024,
397+
size_t out_buffer_size = 1024)
398+
: std::ostream(&buf),
399+
buf(dest, block_size_100K, verbosity, work_factor, bzalloc, bzfree,
400+
opaque, buffer_size, out_buffer_size)
401+
{}
402402
};
403403

404404
/// \brief A stream buffer reading from another stream buffer and
@@ -408,8 +408,8 @@ class bz2ostream : public std::ostream {
408408
/// constructor.
409409
class bz2inbuf : public std::streambuf {
410410
private:
411-
bz2inbuf( const bz2inbuf& ); // no copies please
412-
bz2inbuf& operator=( const bz2inbuf& ); // no copies please
411+
bz2inbuf( const bz2inbuf& ) = delete; // no copies please
412+
bz2inbuf& operator=( const bz2inbuf& ) = delete; // no copies please
413413
protected:
414414
std::streambuf* source;
415415
std::vector<char> buffer;
@@ -531,12 +531,12 @@ class bz2inbuf : public std::streambuf {
531531
///
532532
/// For future compatibility, expect this constructor to throw any
533533
/// std::exception derived exception.
534-
bz2inbuf(std::streambuf* _source, unsigned int verbosity = 0,
535-
bool small_but_slow = false, bzalloc_ptr bzalloc = NULL,
536-
bzfree_ptr bzfree = NULL, void* opaque = NULL,
537-
size_t stream_buffer_size = 1024, size_t in_buffer_size = 1024,
538-
size_t max_putback_size = 64)
539-
: source(_source)
534+
explicit bz2inbuf(std::streambuf* _source, unsigned int verbosity = 0,
535+
bool small_but_slow = false, bzalloc_ptr bzalloc = NULL,
536+
bzfree_ptr bzfree = NULL, void* opaque = NULL,
537+
size_t stream_buffer_size = 1024, size_t in_buffer_size = 1024,
538+
size_t max_putback_size = 64)
539+
: source(_source)
540540
{
541541
// check the parameters
542542
if (verbosity > 4)
@@ -606,15 +606,15 @@ class bz2istream : public std::istream {
606606
/// buffer to read data from.
607607
///
608608
/// See bz2inbuf::bz2inbuf for an explanation of the parameters.
609-
bz2istream(std::streambuf* source, unsigned int verbosity = 0,
610-
bool small_but_slow = false, bzalloc_ptr bzalloc = NULL,
611-
bzfree_ptr bzfree = NULL, void* opaque = NULL,
612-
size_t buffer_size = 1024, size_t in_buffer_size = 1024,
613-
size_t max_putback_size = 64)
614-
: std::istream(&buf),
615-
buf(source, verbosity, small_but_slow, bzalloc, bzfree, opaque,
616-
buffer_size, in_buffer_size, max_putback_size)
617-
{}
609+
explicit bz2istream(std::streambuf* source, unsigned int verbosity = 0,
610+
bool small_but_slow = false, bzalloc_ptr bzalloc = NULL,
611+
bzfree_ptr bzfree = NULL, void* opaque = NULL,
612+
size_t buffer_size = 1024, size_t in_buffer_size = 1024,
613+
size_t max_putback_size = 64)
614+
: std::istream(&buf),
615+
buf(source, verbosity, small_but_slow, bzalloc, bzfree, opaque,
616+
buffer_size, in_buffer_size, max_putback_size)
617+
{}
618618
};
619619

620620
#endif // !BZ2STREAM_BZ2STREAM_HPP

include/ticcutils/gzstream.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ namespace GZSTREAM_NAMESPACE {
8080
gzstreambase() { init(&buf); }
8181
gzstreambase( const std::string&, int );
8282
~gzstreambase();
83-
void open( const std::string&, int );
83+
virtual void open( const std::string&, int );
8484
void close();
85-
gzstreambuf* rdbuf() { return &buf; }
85+
virtual gzstreambuf* rdbuf() { return &buf; }
8686
};
8787

8888
/// \brief A stream class to support .gz files
@@ -95,8 +95,9 @@ namespace GZSTREAM_NAMESPACE {
9595
igzstream() : std::istream( &buf) {}
9696
explicit igzstream( const std::string& name, int open_mode = std::ios::in )
9797
: gzstreambase( name, open_mode ), std::istream( &buf ) {}
98-
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
99-
void open( const std::string& name, int open_mode = std::ios::in ) {
98+
gzstreambuf* rdbuf() override { return gzstreambase::rdbuf(); }
99+
void open( const std::string& name,
100+
int open_mode = std::ios::in ) override {
100101
gzstreambase::open( name, open_mode);
101102
}
102103
};
@@ -111,8 +112,9 @@ namespace GZSTREAM_NAMESPACE {
111112
ogzstream() : std::ostream( &buf) {}
112113
explicit ogzstream( const std::string& name, int mode = std::ios::out )
113114
: gzstreambase( name, mode ), std::ostream( &buf ) {}
114-
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
115-
void open( const std::string& name, int open_mode = std::ios::out ) {
115+
gzstreambuf* rdbuf() override { return gzstreambase::rdbuf(); }
116+
void open( const std::string& name,
117+
int open_mode = std::ios::out ) override {
116118
gzstreambase::open( name, open_mode );
117119
}
118120
};

src/UniHash.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace Hash {
9595
*/
9696
static TiCC::UnicodeNormalizer nfc_norm;
9797
UnicodeString val = nfc_norm.normalize( value );
98-
UniInfo *info = _tree.Retrieve( val );
98+
const UniInfo *info = _tree.Retrieve( val );
9999
if ( info ){
100100
return info->index();
101101
}

0 commit comments

Comments
 (0)