View Source Evision.FileStorage (Evision v0.2.9)
Summary
Functions
Finishes writing nested structure (should pair startWriteStruct())
The constructors.
FileStorage
FileStorage
Returns the first element of the top-level mapping.
Returns the current format.
getNode
Checks whether the file is opened.
Opens a file.
Opens a file.
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.
Writes a comment.
Types
@type t() :: %Evision.FileStorage{ref: reference()}
Type that represents an FileStorage
struct.
ref.
reference()
The underlying erlang resource variable.
Functions
@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
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>
FileStorage
Positional Arguments
- filename:
String
- flags:
integer()
Keyword Arguments
- encoding:
String
.
Return
- self:
Evision.FileStorage.t()
Has overloading in C++
@copydoc open()
Python prototype (for reference only):
FileStorage(filename, flags[, encoding]) -> <FileStorage object>
FileStorage
Positional Arguments
- filename:
String
- flags:
integer()
Keyword Arguments
- encoding:
String
.
Return
- self:
Evision.FileStorage.t()
Has overloading in C++
@copydoc open()
Python prototype (for reference only):
FileStorage(filename, flags[, encoding]) -> <FileStorage object>
@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(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
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 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
@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
- retval:
String
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
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 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(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
- self:
Evision.FileStorage.t()
- name:
String
- val:
Evision.Mat
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
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
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