View Source Evision.FileStorage (Evision v0.2.9)

Summary

Types

t()

Type that represents an FileStorage struct.

Functions

Finishes writing nested structure (should pair startWriteStruct())

The constructors.

Returns the first element of the top-level mapping.

Returns the current format.

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

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:

write

Writes a comment.

Types

@type t() :: %Evision.FileStorage{ref: reference()}

Type that represents an FileStorage struct.

  • ref. reference()

    The underlying erlang resource variable.

Functions

Link to this function

endWriteStruct(named_args)

View Source
@spec endWriteStruct(Keyword.t()) :: any() | {:error, String.t()}
@spec endWriteStruct(t()) :: t() | {:error, String.t()}

Finishes writing nested structure (should pair startWriteStruct())

Positional Arguments
  • self: Evision.FileStorage.t()

Python prototype (for reference only):

endWriteStruct() -> None
@spec fileStorage() :: t() | {:error, String.t()}

The constructors.

Return
  • self: Evision.FileStorage.t()

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

Python prototype (for reference only):

FileStorage() -> <FileStorage object>
@spec fileStorage(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

fileStorage(filename, flags)

View Source
@spec fileStorage(binary(), integer()) :: t() | {:error, String.t()}

FileStorage

Positional Arguments
  • filename: String
  • flags: integer()
Keyword Arguments
Return
  • self: Evision.FileStorage.t()

Has overloading in C++

@copydoc open()

Python prototype (for reference only):

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

fileStorage(filename, flags, opts)

View Source
@spec fileStorage(binary(), integer(), [{:encoding, term()}] | nil) ::
  t() | {:error, String.t()}

FileStorage

Positional Arguments
  • filename: String
  • flags: integer()
Keyword Arguments
Return
  • self: Evision.FileStorage.t()

Has overloading in C++

@copydoc open()

Python prototype (for reference only):

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

getFirstTopLevelNode(named_args)

View Source
@spec getFirstTopLevelNode(Keyword.t()) :: any() | {:error, String.t()}
@spec getFirstTopLevelNode(t()) :: Evision.FileNode.t() | {:error, String.t()}

Returns the first element of the top-level mapping.

Positional Arguments
  • self: Evision.FileStorage.t()
Return
  • retval: Evision.FileNode.t()

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

Python prototype (for reference only):

getFirstTopLevelNode() -> retval
@spec getFormat(Keyword.t()) :: any() | {:error, String.t()}
@spec getFormat(t()) :: integer() | {:error, String.t()}

Returns the current format.

Positional Arguments
  • self: Evision.FileStorage.t()
Return
  • retval: integer()

@returns The current format, see FileStorage::Mode

Python prototype (for reference only):

getFormat() -> retval
@spec getNode(Keyword.t()) :: any() | {:error, String.t()}
@spec getNode(t(), binary()) :: Evision.FileNode.t() | {:error, String.t()}

getNode

Positional Arguments
  • self: Evision.FileStorage.t()
  • nodename: c_string
Return
  • retval: Evision.FileNode.t()

Has overloading in C++

Python prototype (for reference only):

getNode(nodename) -> retval
@spec isOpened(Keyword.t()) :: any() | {:error, String.t()}
@spec isOpened(t()) :: boolean() | {:error, String.t()}

Checks whether the file is opened.

Positional Arguments
  • self: Evision.FileStorage.t()
Return
  • retval: bool

@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 only):

isOpened() -> retval
@spec open(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

open(self, filename, flags)

View Source
@spec open(t(), binary(), integer()) :: boolean() | {:error, String.t()}

Opens a file.

Positional Arguments
  • self: Evision.FileStorage.t()

  • 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: integer().

    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.

Return
  • retval: bool

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

Python prototype (for reference only):

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

open(self, filename, flags, opts)

View Source
@spec open(t(), binary(), integer(), [{:encoding, term()}] | nil) ::
  boolean() | {:error, String.t()}

Opens a file.

Positional Arguments
  • self: Evision.FileStorage.t()

  • 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: integer().

    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.

Return
  • retval: bool

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

Python prototype (for reference only):

open(filename, flags[, encoding]) -> retval
@spec release(Keyword.t()) :: any() | {:error, String.t()}
@spec release(t()) :: t() | {:error, String.t()}

Closes the file and releases all the memory buffers.

Positional Arguments
  • self: Evision.FileStorage.t()

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

Python prototype (for reference only):

release() -> None
Link to this function

releaseAndGetString(named_args)

View Source
@spec releaseAndGetString(Keyword.t()) :: any() | {:error, String.t()}
@spec releaseAndGetString(t()) :: binary() | {:error, String.t()}

Closes the file and releases all the memory buffers.

Positional Arguments
  • self: Evision.FileStorage.t()
Return

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 only):

releaseAndGetString() -> retval
@spec root(Keyword.t()) :: any() | {:error, String.t()}
@spec root(t()) :: Evision.FileNode.t() | {:error, String.t()}

Returns the top-level mapping

Positional Arguments
  • self: Evision.FileStorage.t()
Keyword Arguments
  • streamidx: integer().

    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.

Return
  • retval: Evision.FileNode.t()

@returns The top-level mapping.

Python prototype (for reference only):

root([, streamidx]) -> retval
@spec root(t(), [{:streamidx, term()}] | nil) ::
  Evision.FileNode.t() | {:error, String.t()}

Returns the top-level mapping

Positional Arguments
  • self: Evision.FileStorage.t()
Keyword Arguments
  • streamidx: integer().

    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.

Return
  • retval: Evision.FileNode.t()

@returns The top-level mapping.

Python prototype (for reference only):

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

startWriteStruct(named_args)

View Source
@spec startWriteStruct(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

startWriteStruct(self, name, flags)

View Source
@spec startWriteStruct(t(), binary(), integer()) :: t() | {:error, String.t()}

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

Positional Arguments
  • self: Evision.FileStorage.t()

  • name: String.

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

  • flags: integer().

    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 only):

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

startWriteStruct(self, name, flags, opts)

View Source
@spec startWriteStruct(t(), binary(), integer(), [{:typeName, term()}] | nil) ::
  t() | {:error, String.t()}

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

Positional Arguments
  • self: Evision.FileStorage.t()

  • name: String.

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

  • flags: integer().

    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 only):

startWriteStruct(name, flags[, typeName]) -> None
@spec write(Keyword.t()) :: any() | {:error, String.t()}
@spec write(t(), binary(), [binary()]) :: t() | {:error, String.t()}
@spec write(t(), binary(), Evision.Mat.maybe_mat_in()) :: t() | {:error, String.t()}
@spec write(t(), binary(), binary()) :: t() | {:error, String.t()}
@spec write(t(), binary(), number()) :: t() | {:error, String.t()}
@spec write(t(), binary(), integer()) :: t() | {:error, String.t()}

Variant 1:

write

Positional Arguments
  • self: Evision.FileStorage.t()
  • name: String
  • val: [String]

Python prototype (for reference only):

write(name, val) -> None

Variant 2:

write

Positional Arguments

Python prototype (for reference only):

write(name, val) -> None

Variant 3:

write

Positional Arguments

Python prototype (for reference only):

write(name, val) -> None

Variant 4:

write

Positional Arguments
  • self: Evision.FileStorage.t()
  • name: String
  • val: double

Python prototype (for reference only):

write(name, val) -> None

Variant 5:

Simplified writing API to use with bindings.

Positional Arguments
  • self: Evision.FileStorage.t()

  • name: String.

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

  • val: integer().

    Value of the written object.

Python prototype (for reference only):

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

writeComment(named_args)

View Source
@spec writeComment(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

writeComment(self, comment)

View Source
@spec writeComment(t(), binary()) :: t() | {:error, String.t()}

Writes a comment.

Positional Arguments
  • self: Evision.FileStorage.t()

  • 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 only):

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

writeComment(self, comment, opts)

View Source
@spec writeComment(t(), binary(), [{:append, term()}] | nil) ::
  t() | {:error, String.t()}

Writes a comment.

Positional Arguments
  • self: Evision.FileStorage.t()

  • 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 only):

writeComment(comment[, append]) -> None