Entire Class Index | Main Class Index | Cross Index | Global Index

# Class CL_InputSource

Interface to read data.
Contained in: global
Derived from: none
Derived by: CL_InputSource_File CL_InputSource_Memory CL_InputSource_NetPacket CL_InputSource_NetStream CL_InputSource_Socket CL_InputSource_Socket CL_InputSource_Zipped
Group: Core (I/O Data)

#include <ClanLib/core.h>

### public function member index:

### Construction:

`` | `CL_InputSource` | `()`;
``virtual`` | `~CL_InputSource` | `()`;

### Attributes:

``virtual` `int`` | `tell` | `() `const``;
``virtual` `int`` | `size` | `() `const``;
``virtual` `bool`` | `is_little_endian` | `()`;

### Operations:

``virtual` `void`` | `set_system_mode` | `()`;
``virtual` `void`` | `set_big_endian_mode` | `()`;
``virtual` `void`` | `set_little_endian_mode` | `()`;
``virtual` `int`` | `read_int32` | `()`;
``virtual` `unsigned` `int`` | `read_uint32` | `()`;
``virtual` `short`` | `read_short16` | `()`;
``virtual` `unsigned` `short`` | `read_ushort16` | `()`;
``virtual` `char`` | `read_char8` | `()`;
``virtual` `unsigned` `char`` | `read_uchar8` | `()`;
``virtual` `float`` | `read_float32` | `()`;
``virtual` `bool`` | `read_bool8` | `()`;
``virtual` `int`` | `read` | `(`void`* `data`, `int` `size`)`;
``virtual` `void`` | `open` | `()`;
``virtual` `void`` | `close` | `()`;
``virtual` `CL_InputSource`*` | `clone` | `() `const``;
``virtual` `std::string`` | `read_string` | `()`;
``virtual` `void`` | `seek` | `(`int` `pos`, `SeekEnum` `seek_type`)`;
``virtual` `void`` | `push_position` | `()`;
``virtual` `void`` | `pop_position` | `()`;

## Description:

CL_InputSource is used to read data from different types of input sources.
In most cases, this is regular files and ClanLib zlib compressed datafiles.
To access some system specific input source types, such as datafiles and regular ones, use the static create functions in the CL_InputSourceProvider class.
CL_InputSourceProvider - Interface to open input sources with.

## Function Member Descriptions:

CL_InputSource::CL_InputSource - Input Source Constructor
`` `CL_InputSource` `()`;

CL_InputSource::clone - Make a copy of the current inputsource, standing at the same position.
``virtual` `CL_InputSource`*` `clone` `() `const``;

> Returns - The copy of the input source.

CL_InputSource::close - Closes the input source.
``virtual` `void`` `close` `()`;

CL_InputSource::is_little_endian - Returns true if the input source is in little endian mode.
``virtual` `bool`` `is_little_endian` `()`;

CL_InputSource::open - Opens the input source. By default, it is open.
``virtual` `void`` `open` `()`;

CL_InputSource::pop_position - Pops a previous pushed input source position (returns to the position).
``virtual` `void`` `pop_position` `()`;

CL_InputSource::push_position - Pushes the current input source position.
The position can be restored again with pop_position.
``virtual` `void`` `push_position` `()`;

CL_InputSource::read - Reads larger amounts of data (no endian and 64 bit conversion).
``virtual` `int`` `read` `(`void`* `data`, `int` `size`)`;

> data - Points to an array where the read data is stored.
> size - Number of bytes to read.
> Returns - Num bytes actually read.

CL_InputSource::read_bool8 - Reads a bool from input source.
``virtual` `bool`` `read_bool8` `()`;

> Returns - The bool read.

CL_InputSource::read_char8 - Reads a signed 8 bit integer (char) from input source.
``virtual` `char`` `read_char8` `()`;

> Returns - The char read.

CL_InputSource::read_float32 - Reads an ieee format floating point from input source.
``virtual` `float`` `read_float32` `()`;

> Returns - The float read.

CL_InputSource::read_int32 - Reads a signed 32 bit integer from input source.
``virtual` `int`` `read_int32` `()`;

> Returns - The integer read.

CL_InputSource::read_short16 - Reads a signed 16 bit integer (short) from input source.
``virtual` `short`` `read_short16` `()`;

> Returns - The short read.

CL_InputSource::read_string - Reads a string from the input source.
The binary format expected in the input source is first an uint32 telling the length of the string, and then the string itself.
``virtual` `std::string`` `read_string` `()`;

> Returns - The string read.

CL_InputSource::read_uchar8 - Reads an unsigned 8 bit integer (char) from input source.
``virtual` `unsigned` `char`` `read_uchar8` `()`;

> Returns - The unsigned char read.

CL_InputSource::read_uint32 - Reads an unsigned 32 bit integer from input source.
``virtual` `unsigned` `int`` `read_uint32` `()`;

> Returns - The unsigned integer read.

CL_InputSource::read_ushort16 - Reads an unsigned 16 bit integer (short) from input source.
``virtual` `unsigned` `short`` `read_ushort16` `()`;

> Returns - The unsigned short read.

CL_InputSource::seek - Seeks to the specified position in the input source.
``virtual` `void`` `seek` `(`int` `pos`, `SeekEnum` `seek_type`)`;

> pos - Position relative to 'seek_type'.
> seek_type - Defines what the 'pos' is relative to. Can be either seek_set, seek_cur og seek_end.

CL_InputSource::set_big_endian_mode - Changes input data endianess to big endian mode.
``virtual` `void`` `set_big_endian_mode` `()`;

CL_InputSource::set_little_endian_mode - Changes input data endianess to little endian mode. This is the default setting.
``virtual` `void`` `set_little_endian_mode` `()`;

CL_InputSource::set_system_mode - Changes input data endianess to the local systems mode.
``virtual` `void`` `set_system_mode` `()`;

CL_InputSource::size - Returns the size of the input source
``virtual` `int`` `size` `() `const``;

> Returns - Size of the input source.

CL_InputSource::tell - Returns current position in input source.
``virtual` `int`` `tell` `() `const``;

> Returns - Current position in input source.

CL_InputSource::~CL_InputSource - Input Source Destructor
``virtual`` `~CL_InputSource` `()`;

## Variable Member Descriptions: