Files
c-prime/source/configuration.c

180 lines
2.9 KiB
C
Raw Permalink Normal View History

2025-11-17 10:28:09 +01:00
// #include "sqlite.h"
int getPropertyIndexOfClassIndex( int propertyCount, char ** propertyNames ) {
int propertyIdOfIndex = -1;
for ( int i = 0; i < propertyCount; ++i )
{
char * propertyName = propertyNames[i];
//printf("propertyName: %s\n", propertyName);
if( strcmp( propertyName, "id" ) == 0 ) {
propertyIdOfIndex = i;
break;
}
}
return propertyIdOfIndex;
}
/*
void getArrayByClassIndex( int items, void * * voidArray, int * structByteSize, int classIndex ) {
struct user * array;
switch( classIndex ) {
case 8:
array = ( struct user * ) malloc( sizeof( struct user ) * 1000 );
voidArray = ( void ** ) array;
*structByteSize = sizeof( struct user );
break;
default:
array = ( struct user * ) malloc( sizeof( struct user ) * 1000 );
voidArray = ( void ** ) array;
*structByteSize = sizeof( struct user );
}
}*/
char * getClassName( int classIndex ) {
return __ClassNames[ classIndex ];
}
int getClassIndexByClassName( char * className ) {
for (int i = 0; i < TOTAL_CLASS_COUNT; ++i)
{
char * currentClassName = __ClassNames[ i ];
if( strcmp( className, currentClassName ) == 0 ) {
//printf("find classname: %s\n", className);
return i;
}
}
return -1;
}
int getPropertyCountByClassIndex( int classIndex ) {
return __ClassPropertyCount[ classIndex ];
}
char * * getPropertiesByClassIndex( int classIndex ) {
return __ClassPropertyNames[ classIndex ];
}
int * getPropertyOffsetsByClassIndex( int classIndex ) {
return __ClassPropertyOffsets[ classIndex ];
}
int getPropertyOffsetByPropertyIndex( int * propertyOffsets, int propertyIndex ) {
return propertyOffsets[ propertyIndex ];
}
int * getPropertyDatatypeIndexesByClassIndex( int classIndex ) {
return __ClassPropertyDatatypeIndices[ classIndex ];
}
int getPropertyDatatypeIndex( int * propertyDatatypeIndices, int propertyIndex ) {
return propertyDatatypeIndices[ propertyIndex ];
}
int getPropertyIndexByPropertyName( int classID, char * propertyName ) {
int propertyCount = getPropertyCountByClassIndex( classID );
char * * propertyNames = getPropertiesByClassIndex( classID );
for (int i = 0; i < propertyCount; ++i)
{
char * propertyNameCompare = propertyNames[i];
if( strcmp( propertyName, propertyNameCompare ) == 0 ) {
return i;
}
}
return -1;
}
int getMethodCountByClassIndex( int classIndex ) {
return __ClassMethodCount[ classIndex ];
}
char * * getMethodNamesByClassIndex( int classIndex ) {
return __ClassMethodNames[ classIndex ];
}
int getMethodIndexByPropertyName( int classID, char * propertyName ) {
int methodCount = getMethodCountByClassIndex( classID );
char * * methodNames = getMethodNamesByClassIndex( classID );
for (int i = 0; i < methodCount; ++i)
{
char * propertyNameCompare = methodNames[i];
if( strcmp( propertyName, propertyNameCompare ) == 0 ) {
return i;
}
}
return -1;
}