libgeda

s_textbuffer.c File Reference

#include <config.h>
#include <stdio.h>
#include <glib.h>
#include "libgeda_priv.h"
Include dependency graph for s_textbuffer.c:

Go to the source code of this file.

Data Structures

struct  _TextBuffer

Defines

#define TEXT_BUFFER_LINE_SIZE   1024

Functions

TextBuffers_textbuffer_new (const gchar *data, const gint size)
 Create a new managed text buffer.
TextBuffers_textbuffer_free (TextBuffer *tb)
 Clean up a managed text buffer.
const gchar * s_textbuffer_next (TextBuffer *tb, const gssize count)
 Fetch a number of characters from a text buffer.
const gchar * s_textbuffer_next_line (TextBuffer *tb)
 Fetch the next line from a text buffer.

Define Documentation

#define TEXT_BUFFER_LINE_SIZE   1024

Definition at line 47 of file s_textbuffer.c.


Function Documentation

TextBuffer* s_textbuffer_new ( const gchar *  data,
const gint  size 
)
Function description
Allocates and initialises a new TextBuffer to manage the given data buffer.

If the size argument is negative, assumes that data is null-terminated.

Parameters:
dataThe address of the buffer to be managed.
sizeThe length of the buffer.
Return values:
Pointerto a new TextBuffer struct.

Definition at line 62 of file s_textbuffer.c.

TextBuffer* s_textbuffer_free ( TextBuffer tb)
Function description
Cleans up all of the resources associated with a given TextBuffer.

Should be called thus:

  tb = s_textbuffer_free (tb);

Definition at line 97 of file s_textbuffer.c.

const gchar* s_textbuffer_next ( TextBuffer tb,
const gssize  count 
)
Function description
Get some number of characters from a TextBuffer, starting at the current position. If the end of the buffer has been reached (and thus no more characters remain) returns null. If count is -1, obtains all characters up to and including the next newline.

A newline is detected as '
', or '' together with its immediately following '
', or '', in that order. All newlines are collapsed into a single '
'.

The returned character array should be considered highly volatile, and is only valid until the next call to s_textbuffer_next() or s_textbuffer_next_line().

Parameters:
tbTextBuffer to read from.
countMaximum number of characters to read.
Return values:
Characterarray, or NULL if no characters left.

Definition at line 128 of file s_textbuffer.c.

const gchar* s_textbuffer_next_line ( TextBuffer tb)
Function description
Get the next line of characters from a TextBuffer, starting from the current position. If the end of the buffer has been reached (and thus no more characters remain) returns null.

The returned character array should be considered highly volatile, and is only valid until the next call to s_textbuffer_next() or s_textbuffer_next_line().

Parameters:
tbTextBuffer to read from.
Return values:
Characterarray, or NULL if no characters left.

Definition at line 193 of file s_textbuffer.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines