aboutsummaryrefslogtreecommitdiff
path: root/src/streams.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-10-28 16:57:24 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2016-11-07 13:49:11 -0800
commitfad9b66504f176ed3624515f3bf4d428cf687607 (patch)
treedbeedee85746dc16488f3ff5a4ab76bbcd083be0 /src/streams.h
parentc2c5d42f36f4440aaddc4a64974a52fdb07af08b (diff)
downloadbitcoin-fad9b66504f176ed3624515f3bf4d428cf687607.tar.xz
Make nType and nVersion private and sometimes const
Make the various stream implementations' nType and nVersion private and const (except in CDataStream where we really need a setter).
Diffstat (limited to 'src/streams.h')
-rw-r--r--src/streams.h34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/streams.h b/src/streams.h
index 582443ab4f..12a36a4a70 100644
--- a/src/streams.h
+++ b/src/streams.h
@@ -26,10 +26,11 @@ template<typename Stream>
class OverrideStream
{
Stream* stream;
-public:
+
const int nType;
const int nVersion;
+public:
OverrideStream(Stream* stream_, int nType_, int nVersion_) : stream(stream_), nType(nType_), nVersion(nVersion_) {}
template<typename T>
@@ -66,9 +67,10 @@ protected:
typedef CSerializeData vector_type;
vector_type vch;
unsigned int nReadPos;
-public:
+
int nType;
int nVersion;
+public:
typedef vector_type::allocator_type allocator_type;
typedef vector_type::size_type size_type;
@@ -251,9 +253,9 @@ public:
int in_avail() { return size(); }
void SetType(int n) { nType = n; }
- int GetType() { return nType; }
+ int GetType() const { return nType; }
void SetVersion(int n) { nVersion = n; }
- int GetVersion() { return nVersion; }
+ int GetVersion() const { return nVersion; }
void read(char* pch, size_t nSize)
{
@@ -380,17 +382,15 @@ private:
CAutoFile(const CAutoFile&);
CAutoFile& operator=(const CAutoFile&);
- int nType;
- int nVersion;
-
+ const int nType;
+ const int nVersion;
+
FILE* file;
public:
- CAutoFile(FILE* filenew, int nTypeIn, int nVersionIn)
+ CAutoFile(FILE* filenew, int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn)
{
file = filenew;
- nType = nTypeIn;
- nVersion = nVersionIn;
}
~CAutoFile()
@@ -425,10 +425,8 @@ public:
//
// Stream subset
//
- void SetType(int n) { nType = n; }
- int GetType() { return nType; }
- void SetVersion(int n) { nVersion = n; }
- int GetVersion() { return nVersion; }
+ int GetType() const { return nType; }
+ int GetVersion() const { return nVersion; }
void read(char* pch, size_t nSize)
{
@@ -500,8 +498,8 @@ private:
CBufferedFile(const CBufferedFile&);
CBufferedFile& operator=(const CBufferedFile&);
- int nType;
- int nVersion;
+ const int nType;
+ const int nVersion;
FILE *src; // source file
uint64_t nSrcPos; // how many bytes have been read from source
@@ -531,11 +529,9 @@ protected:
public:
CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn) :
- nSrcPos(0), nReadPos(0), nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0)
+ nType(nTypeIn), nVersion(nVersionIn), nSrcPos(0), nReadPos(0), nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0)
{
src = fileIn;
- nType = nTypeIn;
- nVersion = nVersionIn;
}
~CBufferedFile()