You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# pragma once
# include <string>
enum class StreamError
{
STREAM_OK = 0 , // 成功
STREAM_INVALID_HANDLE = 1 , // handle 不存在
STREAM_WRITE_FAILED = 2 , // 写入失败(缓冲或解析错误)
STREAM_ALREADY_CLOSED = 3 , // 已关闭
STREAM_UNKNOWN_TYPE = 4 // Open 类型错误
} ;
/**
* @brief 数据流抽象类
*/
class INativeStream
{
public :
virtual void Write ( const void * data , size_t size ) = 0 ;
virtual void Complete ( ) = 0 ;
virtual ~ INativeStream ( ) { }
} ;
/**
* @brief 缓冲流:累积 Write 的数据, Complete 后可通过 GetContent 取完整内容
*/
class BufferStream : public INativeStream
{
public :
void Write ( const void * data , size_t size ) override ;
void Complete ( ) override ;
const std : : string & GetContent ( ) const { return m_buffer ; }
private :
std : : string m_buffer ;
} ;