Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.0 KiB

  1. /*===========================================================================
  2. xmlvect.h
  3. see parsifal.h for copyright info
  4. ===========================================================================*/
  5. #ifndef XMLVECTOR__H
  6. #define XMLVECTOR__H
  7. #include <stddef.h>
  8. #ifndef XMLAPI
  9. #define XMLAPI
  10. #endif
  11. #ifndef BYTE
  12. #define BYTE unsigned char
  13. #endif
  14. #ifndef COUNTBUFSIZE
  15. #define COUNTBUFSIZE(cBytes, blocksize) \
  16. ((!(cBytes)) ? (blocksize) : (!( (cBytes) % (blocksize) ) ? (int)(cBytes) : (int)( (((cBytes) / (blocksize)) + 1) * (blocksize) )) )
  17. #endif
  18. typedef struct tagXMLVECTOR
  19. {
  20. int length;
  21. int capacity;
  22. int capacityIncrement;
  23. int itemSize;
  24. BYTE *array;
  25. } XMLVECTOR, *LPXMLVECTOR;
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. LPXMLVECTOR XMLAPI XMLVector_Create(LPXMLVECTOR *vector, int initialCapacity, int itemSize);
  30. void XMLAPI *XMLVector_Replace(LPXMLVECTOR vector, int index, void *item);
  31. int XMLAPI XMLVector_Remove(LPXMLVECTOR vector, int index);
  32. void XMLAPI *XMLVector_Get(LPXMLVECTOR vector, int index);
  33. int XMLAPI XMLVector_Resize(LPXMLVECTOR vector, int newsize);
  34. void XMLAPI *XMLVector_Append(LPXMLVECTOR vector, void *item);
  35. void XMLAPI *XMLVector_InsertBefore(LPXMLVECTOR vector, int index, void *item);
  36. void XMLAPI XMLVector_Free(LPXMLVECTOR vector);
  37. #define _XMLVector_RemoveAll(v) (XMLVector_Resize((v), 0))
  38. #define _XMLVector_Get(v,index) \
  39. (((index) < 0 || (index) > ((v)->length - 1)) ? NULL : (((v)->array+((index)*(v)->itemSize))))
  40. #define _XMLVector_GetP(vect,i,ptype) (*((ptype##**)XMLVector_Get(((LPXMLVECTOR)vect), ((int)i))))
  41. /* e.g. _XMLVector_GetP(v, 0, FILE); expands to *((FILE**)XMLVector_Get(v, 0)) */
  42. #define _XMLVector_GetIterP(v, iterP) ( (iterP) = (void*)((LPXMLVECTOR)v)->array, \
  43. ((LPXMLVECTOR)v)->array + (((LPXMLVECTOR)v)->length*((LPXMLVECTOR)v)->itemSize) )
  44. /* GetIterP returns pointer to past the end of v->array, param 2 sets pointer to start */
  45. #ifdef __cplusplus
  46. }
  47. #endif /* __cplusplus */
  48. #endif /* XMLVECTOR__H */