1
0

intarray.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <precomp.h>
  2. #include "intarray.h"
  3. enum { MAX_ARRAY=8 };
  4. int IntArray::read(const wchar_t *name, int *x1, int *x2, int *x3, int *x4, int *x5, int *x6, int *x7, int *x8) {
  5. PtrList<int> list;
  6. if (x1) { list.addItem(x1); }
  7. if (x2) { list.addItem(x2); }
  8. if (x3) { list.addItem(x3); }
  9. if (x4) { list.addItem(x4); }
  10. if (x5) { list.addItem(x5); }
  11. if (x6) { list.addItem(x6); }
  12. if (x7) { list.addItem(x7); }
  13. if (x8) { list.addItem(x8); }
  14. ASSERT(list.getNumItems() >= 1);
  15. int array[MAX_ARRAY]; // gcc rules, msvc drools
  16. for (int i = 0; i < list.getNumItems(); i++) {
  17. if (list[i]) array[i] = *list[i];
  18. }
  19. if (!WASABI_API_CONFIG->getIntArrayPrivate(name, array, list.getNumItems())) return 0;
  20. for (int j = 0; j < list.getNumItems(); j++) {
  21. if (list[j]) *list[j] = array[j];
  22. }
  23. return 1;
  24. }
  25. void IntArray::write(const wchar_t *name, int x1) {
  26. int array[] = { x1 };
  27. WASABI_API_CONFIG->setIntArrayPrivate(name, array, sizeof(array)/sizeof(int));
  28. }
  29. void IntArray::write(const wchar_t *name, int x1, int x2) {
  30. int array[] = { x1, x2 };
  31. WASABI_API_CONFIG->setIntArrayPrivate(name, array, sizeof(array)/sizeof(int));
  32. }
  33. void IntArray::write(const wchar_t *name, int x1, int x2, int x3) {
  34. int array[] = { x1, x2, x3 };
  35. WASABI_API_CONFIG->setIntArrayPrivate(name, array, sizeof(array)/sizeof(int));
  36. }
  37. void IntArray::write(const wchar_t *name, int x1, int x2, int x3, int x4) {
  38. int array[] = { x1, x2, x3, x4 };
  39. WASABI_API_CONFIG->setIntArrayPrivate(name, array, sizeof(array)/sizeof(int));
  40. }