View Source Evision.FileStorage (Evision v0.1.8)

Link to this section Summary

cv

Finishes writing nested structure (should pair startWriteStruct())

The constructors.

Positional Arguments
Keyword Arguments

Has overloading in C++

Positional Arguments
Keyword Arguments

Has overloading in C++

Returns the first element of the top-level mapping.

Returns the current format.

Positional Arguments
  • nodename: c_string

Has overloading in C++

Checks whether the file is opened.

Closes the file and releases all the memory buffers.

Closes the file and releases all the memory buffers.

Returns the top-level mapping

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

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

Variant 1:

Positional Arguments

Python prototype (for reference):

Writes a comment.

Link to this section cv

Finishes writing nested structure (should pair startWriteStruct())

Python prototype (for reference):

endWriteStruct() -> None

The constructors.

The full constructor opens the file. Alternatively you can use the default constructor and then call FileStorage::open.

Python prototype (for reference):

FileStorage() -> <FileStorage object>
Link to this function

fileStorage(filename, flags)

View Source
Positional Arguments
Keyword Arguments

Has overloading in C++

@copydoc open()

Python prototype (for reference):

FileStorage(filename, flags[, encoding]) -> <FileStorage object>
Link to this function

fileStorage(filename, flags, opts)

View Source
Positional Arguments
Keyword Arguments

Has overloading in C++

@copydoc open()

Python prototype (for reference):

FileStorage(filename, flags[, encoding]) -> <FileStorage object>
Link to this function

getFirstTopLevelNode(self)

View Source

Returns the first element of the top-level mapping.

@returns The first element of the top-level mapping.

Python prototype (for reference):

getFirstTopLevelNode() -> retval

Returns the current format.

@returns The current format, see FileStorage::Mode

Python prototype (for reference):

getFormat() -> retval
Positional Arguments
  • nodename: c_string

Has overloading in C++

Python prototype (for reference):

getNode(nodename) -> retval

Checks whether the file is opened.

@returns true if the object is associated with the current file and false otherwise. It is a good practice to call this method after you tried to open a file.

Python prototype (for reference):

isOpened() -> retval
Link to this function

open(self, filename, flags)

View Source

Opens a file.

Positional Arguments
  • filename: String.

    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: int.

    Mode of operation. One of FileStorage::Mode

Keyword Arguments
  • encoding: String.

    Encoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it.

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

Python prototype (for reference):

open(filename, flags[, encoding]) -> retval
Link to this function

open(self, filename, flags, opts)

View Source

Opens a file.

Positional Arguments
  • filename: String.

    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: int.

    Mode of operation. One of FileStorage::Mode

Keyword Arguments
  • encoding: String.

    Encoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it.

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

Python prototype (for reference):

open(filename, flags[, encoding]) -> retval

Closes the file and releases all the memory buffers.

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

Python prototype (for reference):

release() -> None
Link to this function

releaseAndGetString(self)

View Source

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

Python prototype (for reference):

releaseAndGetString() -> retval

Returns the top-level mapping

Keyword Arguments
  • streamidx: int.

    Zero-based index of the stream. In most cases there is only one stream in the file. However, YAML supports multiple streams and so there can be several.

@returns The top-level mapping.

Python prototype (for reference):

root([, streamidx]) -> retval
Link to this function

startWriteStruct(self, name, flags)

View Source

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

Positional Arguments
  • name: String.

    name of the structure. When writing to sequences (a.k.a. "arrays"), pass an empty string.

  • flags: int.

    type of the structure (FileNode::MAP or FileNode::SEQ (both with optional FileNode::FLOW)).

Keyword Arguments
  • typeName: String.

    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.

Python prototype (for reference):

startWriteStruct(name, flags[, typeName]) -> None
Link to this function

startWriteStruct(self, name, flags, opts)

View Source

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

Positional Arguments
  • name: String.

    name of the structure. When writing to sequences (a.k.a. "arrays"), pass an empty string.

  • flags: int.

    type of the structure (FileNode::MAP or FileNode::SEQ (both with optional FileNode::FLOW)).

Keyword Arguments
  • typeName: String.

    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.

Python prototype (for reference):

startWriteStruct(name, flags[, typeName]) -> None

Variant 1:

Positional Arguments

Python prototype (for reference):

write(name, val) -> None

Variant 2:

Positional Arguments

Python prototype (for reference):

write(name, val) -> None

Variant 3:

Positional Arguments

Python prototype (for reference):

write(name, val) -> None

Variant 4:

Positional Arguments

Python prototype (for reference):

write(name, val) -> None

Variant 5:

Simplified writing API to use with bindings.

Positional Arguments
  • name: String.

    Name of the written object. When writing to sequences (a.k.a. "arrays"), pass an empty string.

  • val: int.

    Value of the written object.

Python prototype (for reference):

write(name, val) -> None
Link to this function

writeComment(self, comment)

View Source

Writes a comment.

Positional Arguments
  • comment: String.

    The written comment, single-line or multi-line

Keyword Arguments
  • append: bool.

    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.

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

Python prototype (for reference):

writeComment(comment[, append]) -> None
Link to this function

writeComment(self, comment, opts)

View Source

Writes a comment.

Positional Arguments
  • comment: String.

    The written comment, single-line or multi-line

Keyword Arguments
  • append: bool.

    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.

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

Python prototype (for reference):

writeComment(comment[, append]) -> None

Link to this section Functions

Raising version of endWriteStruct/1.

Raising version of fileStorage/0.

Link to this function

fileStorage!(filename, flags)

View Source

Raising version of fileStorage/2.

Link to this function

fileStorage!(filename, flags, opts)

View Source

Raising version of fileStorage/3.

Link to this function

getFirstTopLevelNode!(self)

View Source

Raising version of getFirstTopLevelNode/1.

Raising version of getFormat/1.

Link to this function

getNode!(self, nodename)

View Source

Raising version of getNode/2.

Raising version of isOpened/1.

Link to this function

open!(self, filename, flags)

View Source

Raising version of open/3.

Link to this function

open!(self, filename, flags, opts)

View Source

Raising version of open/4.

Raising version of release/1.

Link to this function

releaseAndGetString!(self)

View Source

Raising version of releaseAndGetString/1.

Raising version of root/1.

Link to this function

startWriteStruct!(self, name, flags)

View Source

Raising version of startWriteStruct/3.

Link to this function

startWriteStruct!(self, name, flags, opts)

View Source

Raising version of startWriteStruct/4.

Raising version of write/3.

Link to this function

writeComment!(self, comment)

View Source

Raising version of writeComment/2.

Link to this function

writeComment!(self, comment, opts)

View Source

Raising version of writeComment/3.