#include "list.h"
#include "tuple.h"
#include "segment.h"
Go to the source code of this file.
Classes | |
struct | _IOElement |
A single IOElement provides the information necessary to output a single sub-segment. More... | |
struct | _IOVec |
The structure necessary to output an entire view's sub-segments. More... | |
struct | _view |
The View structure. More... | |
Typedefs | |
typedef _view | View |
typedef _IOElement | IOElement |
A single IOElement. Used in each IOVec. | |
typedef _IOVec | IOVec |
The structure necessary to output an entire view's sub-segments. | |
Enumerations | |
enum | segtype { owned, borrowed } |
Functions | |
void | view_Init (void *(*view_allocate)(size_t), void(*view_deallocate)(void *)) |
Initialize the view memory allocation routines. The defaults are the system malloc and free. If those are acceptable, use of this function is not necessary. | |
View * | view_CreateBorrowed (char *input, unsigned int length) |
Create a new View object from a piece of data. The resulting View contains a "borrowed" reference to the data. | |
View * | view_CreateOwned (char *input, unsigned int length) |
Create a new View object from a piece of data. The resulting View "owns" the data it references. | |
void | view_Delete (View *view) |
Delete a view. | |
unsigned int | view_DeleteFront (View *view, unsigned int N) |
Delete the first N characters (bytes) of a view. | |
unsigned int | view_AppendData (View *view, char *input, unsigned int length) |
Append a new string of data to an existing view. | |
View * | view_Copy (const View *view) |
Copy a view. | |
View * | view_CopyFront (const View *view, unsigned int N) |
Copy the first N characters (bytes) of a view. | |
View * | view_ViewCat (View *v1, const View *v2) |
Concatenate two views together. Same semantics as strcat(), the first view in the argument list is modified and returned. | |
View * | view_Cut (View *v1, unsigned int cutIndex) |
Cut a view into two pieces. | |
unsigned int | view_ViewDelete (View *vParent, const View *vChild) |
Delete instances of Child in Parent. | |
unsigned int | view_GetChar (const View *view, unsigned int pos, char *retval) |
Get a byte from a view. | |
char * | view_CopyChunk (View *view, unsigned int begin, unsigned int end) |
Copy a chunk (piece) of a view. | |
unsigned int | view_DeleteChunk (View *view, unsigned int begin, unsigned int end) |
delete a chunk from a view. | |
unsigned int | view_Length (const View *view) |
size_t | view_Strcspn (View *view, const char *charset, size_t s2Len) |
Span the complement of a view. Mimic the BSD C-Library strscpn functionality. | |
int | view_Strspn (View *view, const char *charset, size_t s2Len) |
Span the initial part of a view. Mimic the BSD C-Library strscpn functionality. | |
int | view_Strstr (View *view, const char *str2, size_t s2Len) |
Locate a substring within a View. | |
void | view_Print (View *view) |
Print out a view in readable form. | |
void | view_DebugPrint (View *view) |
Print out debugging information for a view. | |
IOVec * | view_IOVec (View *view) |
Get the IOVector of a View. | |
void | iovec_Delete (IOVec *iovec) |
Deleting a IOVec is a two step process, So here is a helper function to make life easier. |
|
I do this to avoid having to use "struct" everywhere. |
|
Used to identify the type of data pointers with the segments. They are either all owned (we can delete them), or they are borrowed (someone else will delete the data). |
|
Deleting a IOVec is a two step process, So here is a helper function to make life easier.
|
|
Append a new string of data to an existing view.
|
|
Copy a view.
|
|
Copy a chunk (piece) of a view.
|
|
Copy the first N characters (bytes) of a view.
|
|
Create a new View object from a piece of data. The resulting View contains a "borrowed" reference to the data.
|
|
Create a new View object from a piece of data. The resulting View "owns" the data it references.
2: This version of view_Create() owns the resulting data reference. Thus, it does not matter where the data came from (heap or stack) or when it is modified as view_CreateOwned MAKES A COPY of the data. |
|
Cut a view into two pieces.
|
|
Print out debugging information for a view.
|
|
Delete a view.
|
|
delete a chunk from a view.
|
|
Delete the first N characters (bytes) of a view.
|
|
Get a byte from a view.
|
|
Initialize the view memory allocation routines. The defaults are the system malloc and free. If those are acceptable, use of this function is not necessary.
|
|
Get the IOVector of a View.
iovec = view_IOVec(v1); for (i = 0; i < iovec->vecLength; i++) { printNChars(iovec->vec[i].ptr, iovec->vec[i].length); } void printNChars(char *foo, unsigned int len) { int i = 0; for (i = 0; i < len; i++) { putc(foo[i], stdout); } } |
|
|
|
Print out a view in readable form.
|
|
Span the complement of a view. Mimic the BSD C-Library strscpn functionality. The view_Strcspn() function spans the initial part of the view as as long as the characters from the view do not occur in the string charset (it spans the complement of charset). Since neither the view nor the charset is null-terminated, a third argument, s2Len must be supplied.
|
|
Span the initial part of a view. Mimic the BSD C-Library strscpn functionality. The view_Strspn() function spans the initial part of the view as as long as the characters from the view occur in the string charset (it spans the charset). Since neither the view nor the charset is null-terminated, a third argument, s2Len must be supplied.
|
|
Locate a substring within a View.
|
|
Concatenate two views together. Same semantics as strcat(), the first view in the argument list is modified and returned.
|
|
Delete instances of Child in Parent.
|