---
name: "CL_InputSource"
section: "3"
platform: "linux"
package: "clanlib0-common-dev"
version: "0.4.4-8"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/CL_InputSource"
---

# CL\_InputSource(3)

Interface to read data.

## NAME

CL\_InputSource - Interface to read data.

## 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.

## CLASS MEMBERS

- virtual **~CL\_InputSource**()

  - 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 int **read**(

  ```
  void *data,
  int size)
  ```

- virtual void **open**()

  - virtual void **close**()

  - virtual CL\_InputSource \***clone**()

  - **enum SeekEnum**(

  ```
   seek_set,	seek_cur,	seek_end	)
  ```

- virtual int **tell**()

  - virtual void **seek**(

  ```
  int pos,
  SeekEnum seek_type)
  ```

- virtual int **size**()

  - virtual std::string **read\_string**()

  - virtual void **push\_position**()

  - virtual void **pop\_position**()

  ## MEMBERS WITH DESCRIPTIONS

- virtual **~CL\_InputSource**()

  ```
  Description:
  ```

- virtual void **set\_system\_mode**()

  ```
  Description:
  ```

  Changes input data endianess to the local systems mode.

- virtual void **set\_big\_endian\_mode**()

  ```
  Description:
  ```

  Changes input data endianess to big endian mode.

- virtual void **set\_little\_endian\_mode**()

  ```
  Description:
  ```

  Changes input data endianess to little endian mode. This is the default setting.

- virtual int **read\_int32**()

  ```
  Description:
  ```

  Reads a signed 32 bit integer from input source.

  ```
  Return value:
  ```

  The integer read.

- virtual unsigned int **read\_uint32**()

  ```
  Description:
  ```

  Reads a unsigned 32 bit integer from input source.

  ```
  Return value:
  ```

  The unsigned integer read.

- virtual short **read\_short16**()

  ```
  Description:
  ```

  Reads a signed 16 bit integer (short) from input source.

  ```
  Return value:
  ```

  The short read.

- virtual unsigned short **read\_ushort16**()

  ```
  Description:
  ```

  Reads a unsigned 16 bit integer (short) from input source.

  ```
  Return value:
  ```

  The unsigned short read.

- virtual char **read\_char8**()

  ```
  Description:
  ```

  Reads a signed 8 bit integer (char) from input source.

  ```
  Return value:
  ```

  The char read.

- virtual unsigned char **read\_uchar8**()

  ```
  Description:
  ```

  Reads a unsigned 8 bit integer (char) from input source.

  ```
  Return value:
  ```

  The unsigned char read.

- virtual float **read\_float32**()

  ```
  Description:
  ```

  Reads an ieee format floating point from input source.

  ```
  Return value:
  ```

  The float read.

- virtual int **read**(

  ```
  void *data,
  int size)
  ```

  ```
  Parameters:
  data - Points to an array where the read data is stored.
  size - Number of bytes to read.
  ```

  ```
  Description:
  ```

  Reads larger amounts of data (no endian and 64 bit conversion).

  ```
  Return value:
  ```

  Num bytes actually read.

- virtual void **open**()

  ```
  Description:
  ```

  Opens the input source. By default, it is open.

- virtual void **close**()

  ```
  Description:
  ```

  Closes the input source.

- virtual CL\_InputSource \***clone**()

  ```
  Description:
  ```

  Make a copy of the current InputSource, standing at the same position.

  ```
  Return value:
  ```

  The clone of the input source.

- **enum SeekEnum**(

  ```
   seek_set,	seek_cur,	seek_end	)
  ```

  ```
  Description:
  ```

- virtual int **tell**()

  ```
  Description:
  ```

  Returns current position in input source.

  ```
  Return value:
  ```

  Current position in input source.

- virtual void **seek**(

  ```
  int pos,
  SeekEnum seek_type)
  ```

  ```
  Parameters:
  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.
  ```

  ```
  Description:
  ```

  Seeks to the specified position in the input source.

- virtual int **size**()

  ```
  Description:
  ```

  Returns the size of the input source

  ```
  Return value:
  ```

  Size of the input source.

- virtual std::string **read\_string**()

  ```
  Description:
  ```

  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.

  ```
  Return value:
  ```

  The string read.

- virtual void **push\_position**()

  ```
  Description:
  ```

  Pushes the current input source position. The position can be restored again with pop\_position.

- virtual void **pop\_position**()

  ```
  Description:
  ```

  Pops a previous pushed input source position (returns to the position).

## SEE ALSO

- **CL\_InputSourceProvider**

  Interface to open input sources with.

All ClanLib API classes can be found in **clanlib (3)**.

## AUTHORS

Originally written by Magnus Norddahl \<*mbn@dark.x.dtu.dk*\> and Martin Starch \<*starch@dark.x.dtu.dk*\>. ClanLib is now developed by the ClanLib Development team as an Open Source project.

The ClanLib man pages was created using the Perceps documentation system (another excellent piece of Open Source software, available at **http://somewhere.in.the.world.org**).

See **clanlib (3)** to find out how to get a full list of contributors and details on how to submit bug reports, comments etc.
