The qDecoder Project

qObstack.c File Reference

qDecoder implementation of GNU obstack More...


Functions

Q_OBSTACKqObstackInit (void)
 Under-development.
bool qObstackGrow (Q_OBSTACK *obstack, const void *object, size_t size)
 Under-development.
bool qObstackGrowStr (Q_OBSTACK *obstack, const char *str)
 Under-development.
bool qObstackGrowStrf (Q_OBSTACK *obstack, const char *format,...)
 Under-development.
void * qObstackFinish (Q_OBSTACK *obstack)
 Under-development.
void * qObstackGetFinal (Q_OBSTACK *obstack)
 Under-development.
int qObstackGetSize (Q_OBSTACK *obstack)
 Under-development.
int qObstackGetNum (Q_OBSTACK *obstack)
 Under-development.
bool qObstackFree (Q_OBSTACK *obstack)
 Under-development.


Detailed Description

qDecoder implementation of GNU obstack

Note:
This API can be disabled(excluded in the library) with compile option -DDISABLE_OBSTACK.
   [Code sample - String]
   Q_OBSTACK *obstack;

   char *final;
   char *tmp = "CDE";

   // get new obstack
   obstack = qObstackInit();

   // stack
   qObstackGrowStr(obstack, "AB");              // no need to supply size
   qObstackGrowStrf(obstack, "%s", tmp);        // for formatted string
   qObstackGrow(obstack, "FGH", 3);     // same effects as above but this can
                                        // be used for object or binary

   // final
   final = (char *)qObstackFinish(obstack);


   // print out
   printf("Final string = %s\n", final);
   printf("Total Size = %d, Number of Objects = %d\n", qObstackGetSize(obstack), qObstackGetNum(obstack));

   qObstackFree(obstack);

   [Result]
   Final string = ABCDEFGH
   Total Size = 8, Number of Objects = 3

   [Code sample - Object]
   struct sampleobj {
        int     num;
        char    str[10];
   };

   Q_OBSTACK *obstack;
   int i;

   // sample object
   struct sampleobj obj;
   struct sampleobj *final;

   // get new obstack
   obstack = qObstackInit();

   // stack
   for(i = 0; i < 3; i++) {
        // filling object with sample data
        obj.num  = i;
        sprintf(obj.str, "hello%d", i);

        // stack
        qObstackGrow(obstack, (void *)&obj, sizeof(struct sampleobj));
   }

   // final
   final = (struct sampleobj *)qObstackFinish(obstack);

   // print out
   qContentType("text/plain");
   for(i = 0; i < qObstackGetNum(obstack); i++) {
        printf("Object%d final = %d, %s\n", i+1, final[i].num, final[i].str);
   }
   printf("Total Size = %d, Number of Objects = %d\n", qObstackGetSize(obstack), qObstackGetNum(obstack));

   qObstackFree(obstack);

   [Result]
   Object1 final = 0, hello0
   Object2 final = 1, hello1
   Object3 final = 2, hello2
   Total Size = 48, Number of Objects = 3

Function Documentation

Q_OBSTACK* qObstackInit ( void   ) 

Under-development.

Since:
not released yet

bool qObstackGrow ( Q_OBSTACK obstack,
const void *  object,
size_t  size 
)

Under-development.

Since:
not released yet

bool qObstackGrowStr ( Q_OBSTACK obstack,
const char *  str 
)

Under-development.

Since:
not released yet

bool qObstackGrowStrf ( Q_OBSTACK obstack,
const char *  format,
  ... 
)

Under-development.

Since:
not released yet

void* qObstackFinish ( Q_OBSTACK obstack  ) 

Under-development.

Since:
not released yet

void* qObstackGetFinal ( Q_OBSTACK obstack  ) 

Under-development.

Since:
not released yet

int qObstackGetSize ( Q_OBSTACK obstack  ) 

Under-development.

Since:
not released yet

int qObstackGetNum ( Q_OBSTACK obstack  ) 

Under-development.

Since:
not released yet

bool qObstackFree ( Q_OBSTACK obstack  ) 

Under-development.

Since:
not released yet


[Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference]