O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
string_input_stream.h File Reference

Create input streams from strings. More...

#include "o2s/input_stream.h"
#include "o2s/string.h"
#include <stddef.h>

Go to the source code of this file.

Macros

#define string_literal_input_stream(Value)
 Create an input stream with the content of a C string.
#define StringInputStream
 Use the RAII idiom with a string input stream.

Functions

istream_t string_input_stream (const string_t *value)
 Create an input stream with the content of a string.
istream_t cstring_input_stream (const char *value, size_t length)
 Create an input stream with the content of a C string.

Detailed Description

Create input streams from strings.

Author
Antoine GAGNIERE

Definition in file string_input_stream.h.

Macro Definition Documentation

◆ string_literal_input_stream

#define string_literal_input_stream ( Value)

Create an input stream with the content of a C string.

Note
strlen() of a literal can be computed at compile time.

Definition at line 30 of file string_input_stream.h.

◆ StringInputStream

#define StringInputStream

Use the RAII idiom with a string input stream.

In a situation where one wants to declare an istream variable on the stack in the local scope, this "typedef" can be used for the file to be closed automatically when the variable goes out of scope.

It means this "typedef" can only be used like this :

{
StringInputStream file = string_input_string(...);
...
} // <- The stream will be closed at that point
#define StringInputStream
Use the RAII idiom with a string input stream.

Definition at line 49 of file string_input_stream.h.