Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
sese::io::FileStream类 参考final

文件流类 更多...

#include <FileStream.h>

类 sese::io::FileStream 继承关系图:
sese::io::Stream sese::io::Closeable sese::io::PeekableStream sese::io::InputStream sese::io::OutputStream

Public 类型

using Ptr = std::shared_ptr<FileStream>
 
- Public 类型 继承自 sese::io::Stream
typedef std::shared_ptr< StreamPtr
 
- Public 类型 继承自 sese::io::InputStream
typedef std::shared_ptr< InputStreamPtr
 
- Public 类型 继承自 sese::io::OutputStream
typedef std::shared_ptr< OutputStreamPtr
 
- Public 类型 继承自 sese::io::PeekableStream
typedef std::shared_ptr< PeekableStreamPtr
 

Public 成员函数

 ~FileStream () override=default
 
int64_t read (void *buffer, size_t length) override
 
int64_t write (const void *buffer, size_t length) override
 
void close () override
 
int64_t peek (void *buffer, size_t length) override
 
int64_t trunc (size_t length) override
 
bool eof () const
 
int64_t getSeek () const
 
int32_t setSeek (int64_t offset, int32_t whence) const
 
int32_t setSeek (int64_t offset, Seek type) const
 
int32_t flush () const
 
int32_t getFd () const
 
- Public 成员函数 继承自 sese::io::InputStream
virtual ~InputStream () noexcept=default
 
- Public 成员函数 继承自 sese::io::OutputStream
virtual ~OutputStream () noexcept=default
 
int64_t write (const std::string_view &buffer)
 
int64_t write (const text::StringView &buffer)
 
template<typename T >
int64_t write (std::vector< T > &buffer)
 
template<typename T , size_t N>
int64_t write (std::array< T, N > &buffer)
 
- Public 成员函数 继承自 sese::io::Closeable
virtual ~Closeable ()=default
 
- Public 成员函数 继承自 sese::io::PeekableStream
virtual ~PeekableStream ()=default
 

静态 Public 成员函数

static FileStream::Ptr create (const std::string &file_path, const char *mode) noexcept
 
static FileStream::Ptr createWithPath (const system::Path &path, const char *mode) noexcept
 
static Result< FileStream::PtrcreateEx (const std::string &file_path, const char *mode) noexcept
 

静态 Public 属性

static constexpr auto B_READ = "rb"
 
static constexpr auto B_WRITE_TRUNC = "wb"
 
static constexpr auto B_WRITE_APPEND = "ab"
 
static constexpr auto B_TRUNC = "wb+"
 
static constexpr auto B_APPEND = "ab+"
 
static constexpr auto T_READ = "rt"
 
static constexpr auto T_WRITE_TRUNC = "wt"
 
static constexpr auto T_WRITE_APPEND = "at"
 
static constexpr auto T_TRUNC = "wt+"
 
static constexpr auto T_APPEND = "at+"
 

Private 成员函数

 FileStream () noexcept=default
 

Private 属性

FILE * file = nullptr
 

详细描述

文件流类

成员类型定义说明

◆ Ptr

using sese::io::FileStream::Ptr = std::shared_ptr<FileStream>

构造及析构函数说明

◆ ~FileStream()

sese::io::FileStream::~FileStream ( )
overridedefault

◆ FileStream()

sese::io::FileStream::FileStream ( )
privatedefaultnoexcept

成员函数说明

◆ close()

void FileStream::close ( )
overridevirtual

实现了 sese::io::Closeable.

引用了 file.

◆ create()

FileStream::Ptr FileStream::create ( const std::string & file_path,
const char * mode )
staticnoexcept

◆ createEx()

sese::Result< FileStream::Ptr > FileStream::createEx ( const std::string & file_path,
const char * mode )
staticnoexcept

◆ createWithPath()

FileStream::Ptr FileStream::createWithPath ( const system::Path & path,
const char * mode )
staticnoexcept

以 UNIX-LIKE 风格打开一个文件

参数
pathUNIX-LIKE 路径
mode打开模式
返回值
nullptr打开失败

引用了 create().

◆ eof()

bool FileStream::eof ( ) const
nodiscard

此函数用于判断是否已经读取到文件末尾

警告
这首先需要先触发一次读取失败才能获取有效值
返回
结果s

引用了 file.

◆ flush()

int32_t FileStream::flush ( ) const
nodiscard

引用了 file.

◆ getFd()

int32_t FileStream::getFd ( ) const
nodiscard

引用了 file.

◆ getSeek()

int64_t FileStream::getSeek ( ) const
nodiscard

引用了 file.

◆ peek()

int64_t FileStream::peek ( void * buffer,
size_t length )
overridevirtual

仅读取内容,不步进

参数
buffer缓存
length缓存大小
返回
实际读取大小

实现了 sese::io::PeekableStream.

引用了 sese::io::CUR, read() , 以及 setSeek().

◆ read()

int64_t FileStream::read ( void * buffer,
size_t length )
overridevirtual

实现了 sese::io::InputStream.

引用了 file.

被这些函数引用 peek().

◆ setSeek() [1/2]

int32_t FileStream::setSeek ( int64_t offset,
int32_t whence ) const
nodiscard

引用了 file.

被这些函数引用 peek() , 以及 trunc().

◆ setSeek() [2/2]

int32_t FileStream::setSeek ( int64_t offset,
Seek type ) const
nodiscard

引用了 file.

◆ trunc()

int64_t FileStream::trunc ( size_t length)
overridevirtual

仅步进,不读取内容

参数
length步进大小
返回
实际步进大小

实现了 sese::io::PeekableStream.

引用了 sese::io::CUR, file , 以及 setSeek().

◆ write()

int64_t FileStream::write ( const void * buffer,
size_t length )
overridevirtual

实现了 sese::io::OutputStream.

引用了 file.

类成员变量说明

◆ B_APPEND

auto sese::io::FileStream::B_APPEND = "ab+"
staticconstexpr

◆ B_READ

◆ B_TRUNC

auto sese::io::FileStream::B_TRUNC = "wb+"
staticconstexpr

◆ B_WRITE_APPEND

auto sese::io::FileStream::B_WRITE_APPEND = "ab"
staticconstexpr

◆ B_WRITE_TRUNC

auto sese::io::FileStream::B_WRITE_TRUNC = "wb"
staticconstexpr

◆ file

FILE* sese::io::FileStream::file = nullptr
private

被这些函数引用 close(), eof(), flush(), getFd(), getSeek(), read(), setSeek(), setSeek(), trunc() , 以及 write().

◆ T_APPEND

auto sese::io::FileStream::T_APPEND = "at+"
staticconstexpr

◆ T_READ

auto sese::io::FileStream::T_READ = "rt"
staticconstexpr

◆ T_TRUNC

auto sese::io::FileStream::T_TRUNC = "wt+"
staticconstexpr

◆ T_WRITE_APPEND

auto sese::io::FileStream::T_WRITE_APPEND = "at"
staticconstexpr

◆ T_WRITE_TRUNC

auto sese::io::FileStream::T_WRITE_TRUNC = "wt"
staticconstexpr

该类的文档由以下文件生成: