Files
c-prime/application/target/char.c

157 lines
2.0 KiB
C
Raw Normal View History

2025-11-17 10:28:09 +01:00
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <char.h>
int char_operator_compare( char * this, char * b ) {
return char_compare( this, b );
}
void char_operator_add( char * this, char * b ) {
strcat( this, b );
}
char * char_operator_plus( char * this, char * b ) {
return char_concatenate( this, b );
}
int char_compare( char * this, char * b ) {
return strcmp( this, b ) == 0;
}
char * char_concatenate( char * this, char * b ) {
int lengthA = strlen( this );
int lengthB = strlen( b );
char * pointer = this;
char * copy = ( char * ) malloc( ( lengthA + lengthB + 1 ) * sizeof( char ) );
int idx = 0;
while ( * pointer != '\0' ){
copy[idx++] = *pointer++;
}
pointer = &b[0];
while ( * pointer != '\0' ){
copy[idx++] = *pointer++;
}
copy[ idx++ ] = '\0';
return &copy[0];
}
char * char_clone( char * this ) {
char * newCopy = malloc( sizeof( char ) * strlen( this ) );
strcpy( newCopy, this );
return newCopy;
}
char * char_copy( char * this ) {
char * newCopy = malloc( sizeof( char ) * strlen( this ) );
strcpy( newCopy, this );
return newCopy;
}
struct array * char_split( char * this, char * needle ) {
char * haystack = char_clone( this );
struct array * keys = array_newPointer();
int count = 0;
char * tmp = haystack;
char * token = strtok( haystack, needle );
int i = 0;
while ( token ) {
array_add( keys, token );
token = (char *) strtok( NULL, needle );
}
return keys;
}
char * char_removeWhitespaceLeft( char * this ) {
char * s = this;
while(isspace(*s)) s++;
return s;
}
char * char_removeWhitespaceRight( char * this ) {
char * s = this;
char* back = s + strlen(s);
while( isspace( *--back ) );
*( back + 1 ) = '\0';
return s;
}
char * char_removeWhitespace( char * this ) {
return char_removeWhitespaceRight(char_removeWhitespaceLeft( this ) );
}