inputstream.h
来自「一个语言识别引擎」· C头文件 代码 · 共 60 行
H
60 行
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
/*
* Copyright (C) 2006 Paul Fitzpatrick
* CopyPolicy: Released under the terms of the GNU GPL v2.0.
*
*/
#ifndef _YARP2_INPUTSTREAM_
#define _YARP2_INPUTSTREAM_
#include <yarp/Bytes.h>
namespace yarp {
class InputStream;
}
/**
* Simple specification of the minimum functions needed from input streams.
* The streams could be TCP, UDP, MCAST, ...
*/
class yarp::InputStream {
public:
InputStream() {
}
virtual ~InputStream() { }
virtual void check() {}
virtual int read() { // throws
unsigned char result;
int ct = read(Bytes((char*)&result,1));
if (ct<1) {
return -1;
}
return result;
}
virtual int read(const Bytes& b, int offset, int len) { // throws
return read(Bytes(b.get()+offset,len));
}
virtual int read(const Bytes& b) = 0;
virtual void close() = 0;
virtual void interrupt() {
}
// These should be called at the beginning and end of logical packets.
// Streams are encouraged to handle errors and atomicity at the level of
// logical packets
//virtual void beginPacket() = 0;
//virtual void endPacket() = 0;
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?