Base classes

class cppstream.Stream

Base class that all stream objects inherit from. This class is not meant to be used directly. C++ equivalent: std::basic_ios<char>

property linesep: str

The line separator for this stream. Defaults to os.linesep. C++ equivalent: none

property stream: IO

The raw file object for this stream. C++ equivalent: std::basic_ios<char>::rdbuf()

class cppstream.FileStream(path: Optional[Union[pathlib.Path, str, bytes]] = None, mode: Optional[str] = None)

Bases: cppstream.base.Stream

Base class that all stream objects that write to files inherit from. This class is not meant to be used directly. C++ equivalent: std::basic_fstream<char>

Parameters
  • path (Optional[PathLike]) – The path to the file to open.

  • mode (Optional[str]) – The mode to open the file in, defaults to default_mode.

close() None

Close the connected file object, after flushing it. Sets is_open to False. C++ equivalent: std::basic_fstream<char>::close()

property default_mode: str

The default mode to open the file in when opening it. C++ equivalent: none

property is_open: bool

True if the file is open, False otherwise. C++ equivalent: std::basic_fstream<char>::is_open()

open(path: pathlib.Path | str | bytes, mode: Optional[str] = None) None

Open the stream from path for reading or writing. C++ equivalent: std::basic_fstream<char>::open