206 lines
2.7 KiB
C
206 lines
2.7 KiB
C
|
|
/*
|
||
|
|
* This file is automaticaly generated, Please dont edit this file!
|
||
|
|
*/
|
||
|
|
#include <text.h>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
int text_operator_compare( text * this, text * b ) {
|
||
|
|
|
||
|
|
if( strcmp( this->value, b->value ) == 0 ) {
|
||
|
|
|
||
|
|
return 1;
|
||
|
|
|
||
|
|
} else {
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
text * text_operator_add( text * this, char * b ) {
|
||
|
|
|
||
|
|
text_append( this, b );
|
||
|
|
|
||
|
|
return this;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void text_constructor( text * this, char * value ) {
|
||
|
|
|
||
|
|
this->length = strlen( value );
|
||
|
|
|
||
|
|
if( this->length > this->capacity ) {
|
||
|
|
|
||
|
|
this->capacity = this->length * 2;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
this->value = malloc( sizeof( char ) * this->capacity );
|
||
|
|
|
||
|
|
strcpy( this->value, value );
|
||
|
|
}
|
||
|
|
|
||
|
|
char text_get( text * this, int index ) {
|
||
|
|
|
||
|
|
return this->value[ index ];
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void text_resize( text * this, int size ) {
|
||
|
|
|
||
|
|
this->value = realloc( this->value, size );
|
||
|
|
|
||
|
|
this->capacity = size;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
text * text_append( text * this, char * value ) {
|
||
|
|
|
||
|
|
int originalLength = this->length;
|
||
|
|
|
||
|
|
int newValueLength = strlen( value );
|
||
|
|
|
||
|
|
this->length += newValueLength;
|
||
|
|
|
||
|
|
if( this->length > this->capacity ) {
|
||
|
|
|
||
|
|
text_resize( this, this->length * 2 );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
memcpy( this->value + originalLength, value, newValueLength + 1 );
|
||
|
|
|
||
|
|
return this;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
text * text_appendBinary( text * this, char * value, int size ) {
|
||
|
|
|
||
|
|
int originalLength = this->length;
|
||
|
|
|
||
|
|
int newValueLength = size;
|
||
|
|
|
||
|
|
this->length += newValueLength;
|
||
|
|
|
||
|
|
if( this->length > this->capacity ) {
|
||
|
|
|
||
|
|
text_resize( this, this->length * 2 );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
memcpy( this->value + originalLength, value, newValueLength + 1 );
|
||
|
|
|
||
|
|
return this;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
text * text_appendObject( text * this, text * object ) {
|
||
|
|
|
||
|
|
int originalLength = this->length;
|
||
|
|
|
||
|
|
int newValueLength = object->length;
|
||
|
|
|
||
|
|
this->length += newValueLength;
|
||
|
|
|
||
|
|
if( this->length > this->capacity ) {
|
||
|
|
|
||
|
|
text_resize( this, this->length * 2 );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
memcpy(this->value + originalLength, object->value, newValueLength + 1);
|
||
|
|
|
||
|
|
return this;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
text * text_concatenate( text * this, char * value ) {
|
||
|
|
|
||
|
|
text * copy = text_newPointer( this->value );
|
||
|
|
|
||
|
|
strcat( copy->value, value );
|
||
|
|
|
||
|
|
return copy;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
char * text_toNative( text * this ) {
|
||
|
|
|
||
|
|
return this->value;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
char * text_whiteSpace( text * this, int whiteSpaceCount ) {
|
||
|
|
|
||
|
|
char * output = malloc( 400 );
|
||
|
|
|
||
|
|
for (int i = 0; i < whiteSpaceCount; ++i)
|
||
|
|
{
|
||
|
|
|
||
|
|
strcat( output, " " );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
return output;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void text_free( text * this ) {
|
||
|
|
|
||
|
|
free( this->value );
|
||
|
|
|
||
|
|
free( this );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
text text_new(char * value) {
|
||
|
|
|
||
|
|
text instance;
|
||
|
|
|
||
|
|
instance.usevalue = -1;
|
||
|
|
|
||
|
|
instance.capacity = 500;
|
||
|
|
|
||
|
|
text_constructor( &instance, value);
|
||
|
|
|
||
|
|
return instance;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
text * text_newPointer(char * value) {
|
||
|
|
|
||
|
|
struct text * pointer = malloc( sizeof ( struct text ) );
|
||
|
|
|
||
|
|
pointer->usevalue = -1;
|
||
|
|
|
||
|
|
pointer->capacity = 500;
|
||
|
|
|
||
|
|
text_constructor( pointer , value);
|
||
|
|
|
||
|
|
return pointer;
|
||
|
|
|
||
|
|
}
|
||
|
|
|