CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
I/O Streams

Binary input/output streams and formatted text output More...

Collaboration diagram for I/O Streams:

Classes

class  ByteSink
 Byte encoding sink. More...
 
class  ByteSource
 Byte decoding sink. More...
 
class  CaptureSink
 Capture output in memory. More...
 
class  Crc32Sink
 CRC-32 checksum generator. More...
 
class  Format
 Generate formatted text. More...
 
class  HashSink
 Generic hashsum computing sink. More...
 
class  IoMonitor
 Wait for I/O events. More...
 
class  IoStream
 Base class for all system I/O streams. More...
 
class  LineBuffer
 Line output buffer. More...
 
class  LineSource
 Line input buffer. More...
 
class  MemoryStream
 Read from and write to an underlying memory buffer. More...
 
class  NullStream
 Read zeros and discard writes. More...
 
class  ReplaySource
 Feed data from an in-memory buffer. More...
 
class  Stream
 Abstract data stream. More...
 
class  StreamMultiplexer
 Parallel output to several data sinks. More...
 
class  StreamTap
 Bi-directional traffic redirection and duplication. More...
 
class  TransferLimiter
 Limit the maximum number of bytes transferred. More...
 
class  TransferMeter
 Transfer measuring stream More...
 

Macros

#define CC_DEBUG    cc::ferr("%%\n") << cc::String{__FILE__}.fileName() << ":" << __LINE__ << ": "
 Generate a debug message on the standard error output stream.
 
#define CC_INSPECT(expression)    CC_DEBUG << CC_XSTR(expression) << " = " << (expression)
 Generate a debug message for expression.
 

Enumerations

enum class  FileAccess : int {
  None = 0 , Read = R_OK , Write = W_OK , Execute = X_OK ,
  Exists = F_OK
}
 File access testing flags More...
 
enum class  FileOpen : int {
  None = 0 , ReadOnly = O_RDONLY , WriteOnly = O_WRONLY , ReadWrite = O_RDWR ,
  Append = O_APPEND , Create = O_CREAT , Truncate = O_TRUNC , Virgin = O_EXCL ,
  Sync = O_SYNC , Temporary = 1 << (sizeof(int) * 8 - 2) , Overwrite = FileOpen::Create|FileOpen::WriteOnly|FileOpen::Truncate
}
 File open flags More...
 
enum class  FileMode : mode_t {
  None = 0 , SetUserId = S_ISUID , SetGroupId = S_ISGID , StickyBit = S_ISVTX ,
  UserRead = S_IRUSR , UserWrite = S_IWUSR , UserExec = S_IXUSR , GroupRead = S_IRGRP ,
  GroupWrite = S_IWGRP , GroupExec = S_IXGRP , OtherRead = S_IROTH , OtherWrite = S_IWOTH ,
  OtherExec = S_IXOTH , AnyExec = UserExec|GroupExec|OtherExec , Default = UserRead|UserWrite|GroupRead|OtherRead , DirDefault = UserExec|UserRead|UserWrite|GroupExec|GroupRead|OtherExec|OtherRead
}
 File permission flags More...
 
enum class  Seek : int { Begin = SEEK_SET , Current = SEEK_CUR , End = SEEK_END }
 Seek method. More...
 
enum class  FileType : int {
  Undefined = 0 , Regular = S_IFREG , Directory = S_IFDIR , CharDevice = S_IFCHR ,
  BlockDevice = S_IFBLK , Fifo = S_IFIFO , Symlink = S_IFLNK , Socket = S_IFSOCK
}
 File type More...
 
enum class  IoShutdown : int { Read = 1 , Write = 2 , Full = 4 }
 Shutdown mode for full-duplex communication channels. More...
 
enum class  IoEvent : short {
  None = 0 , ReadyRead = 1 , ReadyWrite = 2 , ReadyAccept = ReadyRead ,
  ReadyReadOrWrite = ReadyRead|ReadyWrite , Established = ReadyRead|ReadyWrite
}
 I/O event type. More...
 

Functions

std::uint32_t crc32 (const void *buffer, long size)
 Generate CRC-32 checksum.
 
std::uint32_t crc32 (const char *buffer)
 Generate CRC-32 checksum.
 
std::uint32_t crc32 (const Bytes &buffer)
 Generate CRC-32 checksum.
 

Detailed Description

Binary input/output streams and formatted text output

Macro Definition Documentation

◆ CC_DEBUG

#define CC_DEBUG    cc::ferr("%%\n") << cc::String{__FILE__}.fileName() << ":" << __LINE__ << ": "

Generate a debug message on the standard error output stream.

Examples:

CC_DEBUG; // outputs the current source code position
CC_DEBUG << x << ", " << y; // outputs x and y
#define CC_DEBUG
Generate a debug message on the standard error output stream.
Definition DEBUG:20

◆ CC_INSPECT

#define CC_INSPECT ( expression)     CC_DEBUG << CC_XSTR(expression) << " = " << (expression)

Generate a debug message for expression.

Example:

CC_INSPECT(1 + 2); // outputs "<file>:<line>: 1 + 2 = 3"
#define CC_INSPECT(expression)
Generate a debug message for expression.
Definition DEBUG:31

Enumeration Type Documentation

◆ FileAccess

enum class FileAccess : int
strong

File access testing flags

Enumerator
None 

Test for no permissions.

Read 

Test for read permission.

Write 

Test for write permission.

Execute 

Test for execution permission.

Exists 

Test if a file (of any type) exists.

◆ FileOpen

enum class FileOpen : int
strong

File open flags

Enumerator
None 

Empty mode.

ReadOnly 

Open for reading, only.

WriteOnly 

Open for writing, only.

ReadWrite 

Open for reading and writing.

Append 

Append any write to the end of file.

Create 

Create file if not exists.

Truncate 

Truncate file to size zero.

Virgin 

Fail to open if file exists already.

Sync 

Write data and meta-data synchronously.

Temporary 

Automatically unlink the file when done.

Overwrite 

Convenience shorthand for.

@ WriteOnly
Open for writing, only.
@ Create
Create file if not exists.
@ Truncate
Truncate file to size zero.

◆ FileMode

enum class FileMode : mode_t
strong

File permission flags

Enumerator
None 

Empty mode.

SetUserId 

Set effective user to file owner on execution

SetGroupId 

Set effective group to file owner on execution

StickyBit 

Allow to read and write, but not delete files when applied to a directory.

UserRead 

Readable by owner.

UserWrite 

Writable by owner.

UserExec 

Executable by owner.

GroupRead 

Readable by group members.

GroupWrite 

Writable by group members.

GroupExec 

Executable by group members.

OtherRead 

Readable by others.

OtherWrite 

Writable by others.

OtherExec 

Executable by others.

AnyExec 

Executable by anyone.

Default 

Default permissions mask for regular files.

DirDefault 

Default permissions mask for directories.

◆ Seek

enum class Seek : int
strong

Seek method.

Enumerator
Begin 

Seek from the beginning of the file.

Current 

Seek relative to the current file offset.

End 

Seek relative to the end of file.

◆ FileType

enum class FileType : int
strong

File type

Enumerator
Undefined 

Missing file.

Regular 

Regular file.

Directory 

Directory.

CharDevice 

Character device.

BlockDevice 

Block device.

Fifo 

Named pipe.

Symlink 

Symbolic link.

Socket 

Named local socket.

◆ IoShutdown

enum class IoShutdown : int
strong

Shutdown mode for full-duplex communication channels.

See also
IoStream::shutdown()
Enumerator
Read 

Partially shutdown the communication channel for reading.

Write 

Partially shutdown the communication channel for writing.

Full 

Fully shutdown the communication channel.

◆ IoEvent

enum class IoEvent : short
strong

I/O event type.

Enumerator
None 

Undefined.

ReadyRead 

Ready for reading.

ReadyWrite 

Ready for writing.

ReadyAccept 

Ready for accepting a connection (on a listening socket)

ReadyReadOrWrite 

Ready for reading and writing.

Established 

Wait until the stream is established.

Function Documentation

◆ crc32() [1/3]

std::uint32_t crc32 ( const void * buffer,
long size )

Generate CRC-32 checksum.

Parameters
bufferInput buffer
sizeNumber of bytes

◆ crc32() [2/3]

std::uint32_t crc32 ( const char * buffer)

Generate CRC-32 checksum.

Parameters
bufferInput C-string

◆ crc32() [3/3]

std::uint32_t crc32 ( const Bytes & buffer)

Generate CRC-32 checksum.

Parameters
bufferInput buffer