cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
toolbox::io::base_file_format_t Class Referenceabstract

文件格式读写器的基类 / Base class for file format readers/writers More...

#include <base.hpp>

Inheritance diagram for toolbox::io::base_file_format_t:

Public Member Functions

virtual ~base_file_format_t ()=default
 
 base_file_format_t (const base_file_format_t &)=delete
 
base_file_format_toperator= (const base_file_format_t &)=delete
 
 base_file_format_t (base_file_format_t &&)=default
 
base_file_format_toperator= (base_file_format_t &&)=default
 
virtual auto can_read (const std::string &path) const -> bool=0
 检查是否可以读取指定路径的文件 / Check if file at given path can be read
 
virtual auto get_supported_extensions () const -> std::vector< std::string >=0
 获取支持的文件扩展名列表 / Get list of supported file extensions
 
virtual auto read (const std::string &path, std::unique_ptr< base_file_data_t > &data) -> bool=0
 读取文件内容到数据对象 / Read file contents into data object
 
virtual auto write (const std::string &path, const std::unique_ptr< base_file_data_t > &data, bool binary) const -> bool=0
 将数据写入文件 / Write data to file
 

Protected Member Functions

 base_file_format_t ()=default
 

Detailed Description

文件格式读写器的基类 / Base class for file format readers/writers

定义了文件格式处理的通用接口,包括读写和格式检测功能 / Defines common interface for file format handling, including read/write and format detection capabilities

// 实现一个简单的文本文件格式处理器 / Implement a simple text file format
handler class text_format_t : public base_file_format_t { public: bool
can_read(const std::string& path) const override { return
path.ends_with(".txt");
}
std::vector<std::string> get_supported_extensions() const override {
return {".txt"};
}
bool read(const std::string& path,
std::unique_ptr<base_file_data_t>& data) override {
// 读取实现 / Read implementation
return true;
}
bool write(const std::string& path,
const std::unique_ptr<base_file_data_t>& data) const override {
// 写入实现 / Write implementation
return true;
}
};
文件格式读写器的基类 / Base class for file format readers/writers
Definition base.hpp:85

Constructor & Destructor Documentation

◆ ~base_file_format_t()

virtual toolbox::io::base_file_format_t::~base_file_format_t ( )
virtualdefault

◆ base_file_format_t() [1/3]

toolbox::io::base_file_format_t::base_file_format_t ( const base_file_format_t )
delete

◆ base_file_format_t() [2/3]

toolbox::io::base_file_format_t::base_file_format_t ( base_file_format_t &&  )
default

◆ base_file_format_t() [3/3]

toolbox::io::base_file_format_t::base_file_format_t ( )
protecteddefault

Member Function Documentation

◆ can_read()

virtual auto toolbox::io::base_file_format_t::can_read ( const std::string &  path) const -> bool
pure virtual

检查是否可以读取指定路径的文件 / Check if file at given path can be read

Parameters
path要检查的文件路径 / Path to file to check
Returns
如果文件可以读取则返回true / Returns true if file can be read

Implemented in toolbox::io::kitti_format_t, and toolbox::io::pcd_format_t.

◆ get_supported_extensions()

virtual auto toolbox::io::base_file_format_t::get_supported_extensions ( ) const -> std::vector< std::string >
pure virtual

获取支持的文件扩展名列表 / Get list of supported file extensions

Returns
支持的扩展名字符串向量 / Vector of supported extension strings

Implemented in toolbox::io::kitti_format_t, and toolbox::io::pcd_format_t.

◆ operator=() [1/2]

base_file_format_t & toolbox::io::base_file_format_t::operator= ( base_file_format_t &&  )
default

◆ operator=() [2/2]

base_file_format_t & toolbox::io::base_file_format_t::operator= ( const base_file_format_t )
delete

◆ read()

virtual auto toolbox::io::base_file_format_t::read ( const std::string &  path,
std::unique_ptr< base_file_data_t > &  data 
) -> bool
pure virtual

读取文件内容到数据对象 / Read file contents into data object

Parameters
path要读取的文件路径 / Path to file to read
data用于存储读取数据的指针 / Pointer to store read data
Returns
读取成功返回true / Returns true if read successful

Implemented in toolbox::io::kitti_format_t, and toolbox::io::pcd_format_t.

◆ write()

virtual auto toolbox::io::base_file_format_t::write ( const std::string &  path,
const std::unique_ptr< base_file_data_t > &  data,
bool  binary 
) const -> bool
pure virtual

将数据写入文件 / Write data to file

Parameters
path要写入的文件路径 / Path to file to write
data要写入的数据 / Data to write
binary是否以二进制模式写入 / Whether to write in binary mode
Returns
写入成功返回true / Returns true if write successful

Implemented in toolbox::io::kitti_format_t, and toolbox::io::pcd_format_t.


The documentation for this class was generated from the following file: