| NORSYS SOFTWARE © 2007 | NETICA API | C VERSION 3.25

stream_ns* NewMemoryStream_ns ( | const char* name, environ_ns* env, const char* access )

Returns a Norsys stream for reading and writing to buffers in memory, in the same format reading/writing is done to disk files.

name is a symbolic name for identifying the stream (e.g., in error messages), and providing information on the expected format of the buffer, in the same way that a file extension can be used to indicate the format of disk files.

The stream can be used for input or output. Use SetStreamContents_ns to have Netica read from a text buffer that you supply. Use GetStreamContents_ns to retrieve a buffer that Netica has written to.

name is not necessarily the name of a file on the OS filesystem. If the end of name consists of a dot and then a few characters, it will be interpreted like a filetype extension, which can be useful to Netica in deciding the data format of the stream. For example, writing a net to a memory stream with a ".dnet" or ".dne" extension will result in a text file Netica format ("DNET format"), whereas using a ".neta" extension would result in a binary Netica file.

Netica will make a copy of filename; it won't modify or free the passed string.

Pass NULL for access; it is only for future expansion.

When done with the stream_ns produced, call DeleteStream_ns.

Version:

Versions 2.26 and later have this function.

See also:

SetStreamContents_ns |  | Sets memory buffer
GetStreamContents_ns |  | Retrieves memory buffer
SetStreamPassword_ns |  | Prepare the stream to do encryption or decryption
DeleteStream_ns |  | Releases all resources (e.g., memory) used by this stream

Example:

    long length;
    stream_ns* strm = NewMemoryStream_ns ("myBuf.dne", env, NULL);
    WriteNet_bn (net, strm);     // write a net into the memory buffer
    const char* buf = GetStreamContents_ns (strm, length);
    // ... [examine and use the buffer contents] ...
    DeleteStream_ns (strm);

Example 2:

    stream_ns* strm = NewMemoryStream_ns ("myBuf.cas", env, NULL);
    const char* casedata = "A B C \n yes no 1 \n yes yes 3 \n no no 1";
    SetStreamContents_ns (strm, casedata, strlen (casedata), true);
    ReviseCPTsByCaseFile_bn (strm, nodes, 0, 1.0);
    DeleteStream_ns (strm);