← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2280: Fix multiple build warnings in Streams.h

 

------------------------------------------------------------
revno: 2280
fixes bug(s): https://launchpad.net/bugs/666175
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-10-31 17:54:47 -0500
message:
  Fix multiple build warnings in Streams.h
added:
  dcpp/Streams.cpp
modified:
  dcpp/Streams.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== added file 'dcpp/Streams.cpp'
--- dcpp/Streams.cpp	1970-01-01 00:00:00 +0000
+++ dcpp/Streams.cpp	2010-10-31 22:54:47 +0000
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "stdinc.h"
+#include "DCPlusPlus.h"
+#include "Streams.h"
+
+template<bool managed>
+size_t dcpp::LimitedOutputStream<managed>::write(const void* buf, size_t len) throw(Exception) {
+	if(maxBytes < len) {
+		throw FileException(_("More bytes written than requested"));
+	}
+	maxBytes -= len;
+	return s->write(buf, len);
+}
+

=== modified file 'dcpp/Streams.h'
--- dcpp/Streams.h	2010-02-11 21:44:13 +0000
+++ dcpp/Streams.h	2010-10-31 22:54:47 +0000
@@ -108,13 +108,13 @@
 template<bool managed>
 class LimitedInputStream : public InputStream {
 public:
-	LimitedInputStream(InputStream* is, int64_t aMaxBytes) : s(is), maxBytes(aMaxBytes) {
+	LimitedInputStream(InputStream* is, uint64_t aMaxBytes) : s(is), maxBytes(aMaxBytes) {
 	}
 	virtual ~LimitedInputStream() throw() { if(managed) delete s; }
 
 	size_t read(void* buf, size_t& len) throw(FileException) {
 		dcassert(maxBytes >= 0);
-		len = (size_t)min(maxBytes, (int64_t)len);
+		len = (size_t)min(maxBytes, (uint64_t)len);
 		if(len == 0)
 			return 0;
 		size_t x = s->read(buf, len);
@@ -124,24 +124,18 @@
 
 private:
 	InputStream* s;
-	int64_t maxBytes;
+	uint64_t maxBytes;
 };
 
 /** Limits the number of bytes that are requested to be written (not the number actually written!) */
 template<bool managed>
 class LimitedOutputStream : public OutputStream {
 public:
-	LimitedOutputStream(OutputStream* os, int64_t aMaxBytes) : s(os), maxBytes(aMaxBytes) {
+	LimitedOutputStream(OutputStream* os, uint64_t aMaxBytes) : s(os), maxBytes(aMaxBytes) {
 	}
 	virtual ~LimitedOutputStream() throw() { if(managed) delete s; }
 
-	virtual size_t write(const void* buf, size_t len) throw(Exception) {
-		if(maxBytes < len) {
-			throw FileException(_("More bytes written than requested"));
-		}
-		maxBytes -= len;
-		return s->write(buf, len);
-	}
+	virtual size_t write(const void* buf, size_t len) throw(Exception);
 
 	virtual size_t flush() throw(Exception) {
 		return s->flush();
@@ -150,7 +144,7 @@
 	virtual bool eof() { return maxBytes == 0; }
 private:
 	OutputStream* s;
-	int64_t maxBytes;
+	uint64_t maxBytes;
 };
 
 template<bool managed>