opencv::prelude

Trait FileStorageTrait

source
pub trait FileStorageTrait: FileStorageTraitConst {
Show 18 methods // Required method fn as_raw_mut_FileStorage(&mut self) -> *mut c_void; // Provided methods fn set_state(&mut self, val: i32) { ... } fn set_elname(&mut self, val: &str) { ... } fn open( &mut self, filename: &str, flags: i32, encoding: &str, ) -> Result<bool> { ... } fn open_def(&mut self, filename: &str, flags: i32) -> Result<bool> { ... } fn release(&mut self) -> Result<()> { ... } fn release_and_get_string(&mut self) -> Result<String> { ... } fn write_i32(&mut self, name: &str, val: i32) -> Result<()> { ... } fn write_f64(&mut self, name: &str, val: f64) -> Result<()> { ... } fn write_str(&mut self, name: &str, val: &str) -> Result<()> { ... } fn write_mat(&mut self, name: &str, val: &impl MatTraitConst) -> Result<()> { ... } fn write_str_vec(&mut self, name: &str, val: &Vector<String>) -> Result<()> { ... } fn write_raw(&mut self, fmt: &str, vec: &mut [u8]) -> Result<()> { ... } fn write_comment(&mut self, comment: &str, append: bool) -> Result<()> { ... } fn write_comment_def(&mut self, comment: &str) -> Result<()> { ... } fn start_write_struct( &mut self, name: &str, flags: i32, type_name: &str, ) -> Result<()> { ... } fn start_write_struct_def(&mut self, name: &str, flags: i32) -> Result<()> { ... } fn end_write_struct(&mut self) -> Result<()> { ... }
}
Expand description

Mutable methods for core::FileStorage

Required Methods§

Provided Methods§

source

fn set_state(&mut self, val: i32)

source

fn set_elname(&mut self, val: &str)

source

fn open(&mut self, filename: &str, flags: i32, encoding: &str) -> Result<bool>

Opens a file.

See description of parameters in FileStorage::FileStorage. The method calls FileStorage::release before opening the file.

§Parameters
  • filename: Name of the file to open or the text string to read the data from. Extension of the file (.xml, .yml/.yaml or .json) determines its format (XML, YAML or JSON respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify the output file format (e.g. mydata.xml, .yml etc.). A file name can also contain parameters. You can use this format, “*?base64” (e.g. “file.json?base64” (case sensitive)), as an alternative to FileStorage::BASE64 flag.
  • flags: Mode of operation. One of FileStorage::Mode
  • encoding: Encoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it.
§C++ default parameters
  • encoding: String()
source

fn open_def(&mut self, filename: &str, flags: i32) -> Result<bool>

Opens a file.

See description of parameters in FileStorage::FileStorage. The method calls FileStorage::release before opening the file.

§Parameters
  • filename: Name of the file to open or the text string to read the data from. Extension of the file (.xml, .yml/.yaml or .json) determines its format (XML, YAML or JSON respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify the output file format (e.g. mydata.xml, .yml etc.). A file name can also contain parameters. You can use this format, “*?base64” (e.g. “file.json?base64” (case sensitive)), as an alternative to FileStorage::BASE64 flag.
  • flags: Mode of operation. One of FileStorage::Mode
  • encoding: Encoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it.
§Note

This alternative version of FileStorageTrait::open function uses the following default values for its arguments:

  • encoding: String()
source

fn release(&mut self) -> Result<()>

Closes the file and releases all the memory buffers.

Call this method after all I/O operations with the storage are finished.

source

fn release_and_get_string(&mut self) -> Result<String>

Closes the file and releases all the memory buffers.

Call this method after all I/O operations with the storage are finished. If the storage was opened for writing data and FileStorage::WRITE was specified

source

fn write_i32(&mut self, name: &str, val: i32) -> Result<()>

Simplified writing API to use with bindings.

§Parameters
  • name: Name of the written object. When writing to sequences (a.k.a. “arrays”), pass an empty string.
  • val: Value of the written object.
source

fn write_f64(&mut self, name: &str, val: f64) -> Result<()>

Simplified writing API to use with bindings.

§Parameters
  • name: Name of the written object. When writing to sequences (a.k.a. “arrays”), pass an empty string.
  • val: Value of the written object.
§Overloaded parameters
source

fn write_str(&mut self, name: &str, val: &str) -> Result<()>

Simplified writing API to use with bindings.

§Parameters
  • name: Name of the written object. When writing to sequences (a.k.a. “arrays”), pass an empty string.
  • val: Value of the written object.
§Overloaded parameters
source

fn write_mat(&mut self, name: &str, val: &impl MatTraitConst) -> Result<()>

Simplified writing API to use with bindings.

§Parameters
  • name: Name of the written object. When writing to sequences (a.k.a. “arrays”), pass an empty string.
  • val: Value of the written object.
§Overloaded parameters
source

fn write_str_vec(&mut self, name: &str, val: &Vector<String>) -> Result<()>

Simplified writing API to use with bindings.

§Parameters
  • name: Name of the written object. When writing to sequences (a.k.a. “arrays”), pass an empty string.
  • val: Value of the written object.
§Overloaded parameters
source

fn write_raw(&mut self, fmt: &str, vec: &mut [u8]) -> Result<()>

Writes multiple numbers.

Writes one or more numbers of the specified format to the currently written structure. Usually it is more convenient to use operator << instead of this method.

§Parameters
  • fmt: Specification of each array element, see [format_spec] “format specification”
  • vec: Pointer to the written array.
  • len: Number of the uchar elements to write.
source

fn write_comment(&mut self, comment: &str, append: bool) -> Result<()>

Writes a comment.

The function writes a comment into file storage. The comments are skipped when the storage is read.

§Parameters
  • comment: The written comment, single-line or multi-line
  • append: If true, the function tries to put the comment at the end of current line. Else if the comment is multi-line, or if it does not fit at the end of the current line, the comment starts a new line.
§C++ default parameters
  • append: false
source

fn write_comment_def(&mut self, comment: &str) -> Result<()>

Writes a comment.

The function writes a comment into file storage. The comments are skipped when the storage is read.

§Parameters
  • comment: The written comment, single-line or multi-line
  • append: If true, the function tries to put the comment at the end of current line. Else if the comment is multi-line, or if it does not fit at the end of the current line, the comment starts a new line.
§Note

This alternative version of FileStorageTrait::write_comment function uses the following default values for its arguments:

  • append: false
source

fn start_write_struct( &mut self, name: &str, flags: i32, type_name: &str, ) -> Result<()>

Starts to write a nested structure (sequence or a mapping).

§Parameters
  • name: name of the structure. When writing to sequences (a.k.a. “arrays”), pass an empty string.
  • flags: type of the structure (FileNode::MAP or FileNode::SEQ (both with optional FileNode::FLOW)).
  • typeName: optional name of the type you store. The effect of setting this depends on the storage format. I.e. if the format has a specification for storing type information, this parameter is used.
§C++ default parameters
  • type_name: String()
source

fn start_write_struct_def(&mut self, name: &str, flags: i32) -> Result<()>

Starts to write a nested structure (sequence or a mapping).

§Parameters
  • name: name of the structure. When writing to sequences (a.k.a. “arrays”), pass an empty string.
  • flags: type of the structure (FileNode::MAP or FileNode::SEQ (both with optional FileNode::FLOW)).
  • typeName: optional name of the type you store. The effect of setting this depends on the storage format. I.e. if the format has a specification for storing type information, this parameter is used.
§Note

This alternative version of FileStorageTrait::start_write_struct function uses the following default values for its arguments:

  • type_name: String()
source

fn end_write_struct(&mut self) -> Result<()>

Finishes writing nested structure (should pair startWriteStruct())

Object Safety§

This trait is not object safe.

Implementors§