/// <summary> /// Finds an object by name and decodes it. /// </summary> /// <typeparam name="TElement">The type of the object.</typeparam> /// <param name="map">The parent map. If it is <b>null</b>, the function searches a top-level node.</param> /// <param name="name">The node name.</param> /// <returns>The reference to the decoded object.</returns> public TElement Read <TElement>(FileNode map, string name) where TElement : CVHandle { return(Read <TElement>(GetFileNode(map, name))); }
/// <summary> /// Writes a file node from another file storage. /// </summary> /// <param name="newNodeName"> /// New name of the file node in the destination file storage. To keep the existing name, use the /// <see cref="FileNode.Name"/> property. /// </param> /// <param name="node">The written node.</param> /// <param name="embed"> /// If the written node is a collection and this parameter is <b>true</b>, no extra level of hierarchy /// is created. Instead, all the elements of node are written into the currently written structure. /// Of course, map elements can only be embedded into another map, and sequence elements can only be /// embedded into another sequence. /// </param> public void WriteFileNode(string newNodeName, FileNode node, bool embed) { NativeMethods.cvWriteFileNode(this, newNodeName, node, embed ? 1 : 0); }
/// <summary> /// Finds a file node and returns its text string value. /// </summary> /// <param name="map">The parent map. If it is <b>null</b>, the function searches a top-level node.</param> /// <param name="name">The node name.</param> /// <param name="defaultValue">The value that is returned if the file node is not found.</param> /// <returns>A text string that is represented by the file node.</returns> public string ReadString(FileNode map, string name, string defaultValue = null) { return(ReadString(GetFileNode(map, name), defaultValue)); }
/// <summary> /// Finds a file node and returns its floating-point value. /// </summary> /// <param name="map">The parent map. If it is <b>null</b>, the function searches a top-level node.</param> /// <param name="name">The node name.</param> /// <param name="defaultValue">The value that is returned if the file node is not found.</param> /// <returns>A floating-point value that is represented by the file node.</returns> public double ReadReal(FileNode map, string name, double defaultValue = 0) { return(ReadReal(GetFileNode(map, name), defaultValue)); }
/// <summary> /// Finds a file node and returns its integer value. /// </summary> /// <param name="map">The parent map. If it is <b>null</b>, the function searches a top-level node.</param> /// <param name="name">The node name.</param> /// <param name="defaultValue">The value that is returned if the file node is not found.</param> /// <returns>An integer that is represented by the file node.</returns> public int ReadInt(FileNode map, string name, int defaultValue = 0) { return(ReadInt(GetFileNode(map, name), defaultValue)); }
/// <summary> /// Finds a node in a map or file storage. /// </summary> /// <param name="map">The parent map. If it is <b>null</b>, the function searches a top-level node.</param> /// <param name="name">The file node name.</param> /// <returns>The found node or <b>null</b> in case of failure.</returns> public FileNode GetFileNode(FileNode map, string name) { var node = NativeMethods.cvGetFileNodeByName(this, map, name); return(node.IsInvalid ? null : node); }
/// <summary> /// Finds a node in a map or file storage. /// </summary> /// <param name="map">The parent map. If it is <b>null</b>, the function searches a top-level node.</param> /// <param name="key">Unique pointer to the node name, retrieved with <see cref="GetHashedKey"/>.</param> /// <param name="createMissing">A value indicating whether an absent node should be added to the map.</param> /// <returns>The found or newly created node; <b>null</b> in case of failure.</returns> public FileNode GetFileNode(FileNode map, StringHashNode key, bool createMissing = false) { var node = NativeMethods.cvGetFileNode(this, map ?? FileNode.Null, key ?? StringHashNode.Null, createMissing ? 1 : 0); return(node.IsInvalid ? null : node); }