summaryrefslogtreecommitdiff
path: root/src/include/iodevice.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/iodevice.h')
-rw-r--r--src/include/iodevice.h54
1 files changed, 21 insertions, 33 deletions
diff --git a/src/include/iodevice.h b/src/include/iodevice.h
index 070ac3f..73dd2ab 100644
--- a/src/include/iodevice.h
+++ b/src/include/iodevice.h
@@ -7,12 +7,13 @@
#ifndef iodevice_h_included
#define iodevice_h_included
-#include "convert.h" // BincStream
-//#include <iostream>
+#include "convert.h" // BincStream
+// #include <iostream>
#include <string>
-#include <unistd.h> // ::write
-const char CMS_END_OF_LINE[4] = { 0x0d, '\n', 0x00, 0x00 };
+#include <unistd.h> // ::write
+
+const char CMS_END_OF_LINE[4] = {0x0d, '\n', 0x00, 0x00};
namespace Binc {
/*!
@@ -45,13 +46,10 @@ namespace Binc {
/*!
Errors from when an operation returned false.
*/
- enum Error {
- Unknown,
- Timeout
- };
+ enum Error { Unknown, Timeout };
/*!
- Constructs an invalid IODevice.
+ Constructs an invalid IODevice.
Instances of IODevice perform no operations, and all boolean
functions always return false. This constructor is only useful
@@ -132,13 +130,8 @@ namespace Binc {
*/
unsigned int getTimeout(void) const;
- enum LogLevel {
- ErrorLevel,
- InfoLevel,
- WarningLevel,
- DebugLevel
- };
-
+ enum LogLevel { ErrorLevel, InfoLevel, WarningLevel, DebugLevel };
+
/*!
Sets the output level for the following write operations on this
device.
@@ -210,13 +203,13 @@ namespace Binc {
\sa setMaxOutputBufferSize()
*/
- template <class T> IODevice &operator << (const T &source);
+ template<class T> IODevice &operator<<(const T &source);
/*!
Writes data to the device. This function specializes on standard
ostream derivates, such as std::endl.
*/
- IODevice &operator << (std::ostream &(*source)(std::ostream &));
+ IODevice &operator<<(std::ostream &(*source)(std::ostream &));
/*!
Returns true if data can be read from the device; otherwise
@@ -227,7 +220,7 @@ namespace Binc {
/*!
Reads data from the device, and stores this in a string. Returns
true on success; otherwise returns false.
-
+
\param dest The incoming data is stored in this string.
\param max No more than this number of bytes is read from the
device.
@@ -286,7 +279,7 @@ namespace Binc {
return values are "client" and "log".
*/
virtual std::string service(void) const;
-
+
protected:
/*!
Waits until data can be written to the device. If the timeout is
@@ -308,13 +301,9 @@ namespace Binc {
virtual bool waitForRead(void) const;
/*!
- Types of results from a write.
+ Types of results from a write.
*/
- enum WriteResult {
- WriteWait = 0,
- WriteDone = 1 << 0,
- WriteError = 1 << 1
- };
+ enum WriteResult { WriteWait = 0, WriteDone = 1 << 0, WriteError = 1 << 1 };
/*!
Writes as much data as possible to the device. If some but not
@@ -327,7 +316,7 @@ namespace Binc {
/*!
Reads data from the device, and stores it in the input buffer.
Returns true on success; otherwise returns false.
-
+
This method will fail if there is no more data available, if a
timeout occurred or if an error with the device prevents more
data from being read.
@@ -359,20 +348,19 @@ namespace Binc {
};
//----------------------------------------------------------------------
- template <class T> IODevice &IODevice::operator << (const T &source)
+ template<class T> IODevice &IODevice::operator<<(const T &source)
{
if ((flags & IsEnabled) && outputLevel <= outputLevelLimit) {
outputBuffer << source;
- if (dumpfd) {
- BincStream ss;
+ if (dumpfd) {
+ BincStream ss;
ss << source;
- ::write(dumpfd, ss.str().c_str(), ss.getSize());
+ ::write(dumpfd, ss.str().c_str(), ss.getSize());
}
if (flags & HasInputLimit)
- if (outputBuffer.getSize() > maxOutputBufferSize)
- flush();
+ if (outputBuffer.getSize() > maxOutputBufferSize) flush();
}
return *this;