tetengo 1.8.1
A multipurpose library set
Loading...
Searching...
No Matches
reader.h File Reference

A reader. More...

#include <stdbool.h>
#include <stddef.h>
+ Include dependency graph for reader.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tetengo_json_location_tag
 A location. More...
 

Typedefs

typedef struct tetengo_json_location_tag tetengo_json_location_t
 A location.
 

Functions

size_t tetengo_json_reader_streamReaderDefaultBufferCapacity ()
 Returns the default buffer capacity of the stream reader.
 
tetengo_json_reader_t * tetengo_json_reader_createStreamReader (const char *file_path, size_t buffer_capacity)
 Creates a stream reader.
 
tetengo_json_reader_t * tetengo_json_reader_createCommentRemovingReader (tetengo_json_reader_t *p_base_reader, const char *single_line_begin)
 Creates a comment removing reader.
 
tetengo_json_reader_t * tetengo_json_reader_createLineCountingReader (tetengo_json_reader_t *p_base_reader)
 Creates a line counting reader.
 
void tetengo_json_reader_destroy (const tetengo_json_reader_t *p_reader)
 Destroys a reader.
 
bool tetengo_json_reader_getLocation (const tetengo_json_reader_t *p_line_counting_reader, tetengo_json_location_t *p_location)
 
bool tetengo_json_reader_hasNext (const tetengo_json_reader_t *p_reader)
 Returns true when the next character exists.
 
char tetengo_json_reader_peek (const tetengo_json_reader_t *p_reader)
 Returns the current character.
 
void tetengo_json_reader_next (tetengo_json_reader_t *p_reader)
 Moves to the next character.
 
const tetengo_json_reader_t * tetengo_json_reader_baseReader (const tetengo_json_reader_t *p_reader)
 Returns the base reader.
 

Detailed Description

A reader.

Copyright (C) 2019-2023 kaoru https://www.tetengo.org/

Function Documentation

◆ tetengo_json_reader_baseReader()

const tetengo_json_reader_t * tetengo_json_reader_baseReader ( const tetengo_json_reader_t *  p_reader)

Returns the base reader.

Parameters
p_readerA pointer to a reader.
Returns
A pointer to the base reader. Or NULL when p_reader is NULL or the reader does not have a base reader.

◆ tetengo_json_reader_createCommentRemovingReader()

tetengo_json_reader_t * tetengo_json_reader_createCommentRemovingReader ( tetengo_json_reader_t *  p_base_reader,
const char *  single_line_begin 
)

Creates a comment removing reader.

There is no need to destroy the base reader after calling this function.

Parameters
p_base_readerA pointer to a base reader.
single_line_beginA beginning of a single line comment.
Returns
A pointer to a reader. Or NULL when p_base_reader and/or single_line_begin are NULL.

◆ tetengo_json_reader_createLineCountingReader()

tetengo_json_reader_t * tetengo_json_reader_createLineCountingReader ( tetengo_json_reader_t *  p_base_reader)

Creates a line counting reader.

There is no need to destroy the base reader after calling this function.

Parameters
p_base_readerA pointer to a base reader.
Returns
A pointer to a reader. Or NULL when p_base_reader is NULL.

◆ tetengo_json_reader_createStreamReader()

tetengo_json_reader_t * tetengo_json_reader_createStreamReader ( const char *  file_path,
size_t  buffer_capacity 
)

Creates a stream reader.

Parameters
file_pathA file path.
buffer_capacityA buffer capacity.
Returns
A pointer to a reader. Or NULL when the file cannot be opened or buffer_capacity is 0.

◆ tetengo_json_reader_destroy()

void tetengo_json_reader_destroy ( const tetengo_json_reader_t *  p_reader)

Destroys a reader.

Parameters
p_readerA pointer to a reader.

◆ tetengo_json_reader_getLocation()

bool tetengo_json_reader_getLocation ( const tetengo_json_reader_t *  p_line_counting_reader,
tetengo_json_location_t p_location 
)

Returns the location.

Parameters
p_line_counting_readerA pointer to a line counting reader.
p_locationThe storage for a location.
Return values
trueWhen a location has been stored.
falseWhen p_line_counting_reader is NULL or not a line counting reader. And/or when p_location is NULL. And/or when current position is beyond the termination point.

◆ tetengo_json_reader_hasNext()

bool tetengo_json_reader_hasNext ( const tetengo_json_reader_t *  p_reader)

Returns true when the next character exists.

Parameters
p_readerA pointer to a reader.
Return values
trueWhen the next character exists.
falseOtherwise.

◆ tetengo_json_reader_next()

void tetengo_json_reader_next ( tetengo_json_reader_t *  p_reader)

Moves to the next character.

Parameters
p_readerA pointer to a reader.

◆ tetengo_json_reader_peek()

char tetengo_json_reader_peek ( const tetengo_json_reader_t *  p_reader)

Returns the current character.

Parameters
p_readerA pointer to a reader.
Returns
The current character. Or 0 when current position is beyond the termination point.

◆ tetengo_json_reader_streamReaderDefaultBufferCapacity()

size_t tetengo_json_reader_streamReaderDefaultBufferCapacity ( )

Returns the default buffer capacity of the stream reader.

Returns
The default buffer capacity.