jsonapi.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /** @file */
  2. // -------------------------------------------------------------------------
  3. // error codes for handle processing
  4. // defined in C++
  5. enum EJsonApiError
  6. {
  7. ETJSON_UNKNOWN, // invalid code
  8. ETJSON_OK, // all fine
  9. ETJSON_COMMSEND, // error during send
  10. ETJSON_COMMRECV, // error during receive
  11. ETJSON_PARSERERROR, // error during parsing
  12. ETJSON_PACKNOSTART, // error - cannot start packing (invalid state)
  13. ETJSON_TIMEOUT, // failed to send/ store handle due to timeout
  14. ETJSON_NOBUFFERS, // not enough buffers available
  15. ETJSON_FAILFILELOAD, // failed to load file
  16. ETJSON_FAILFILESAVE, // failed to save file
  17. ETJSON_NOTARRAY, // object is not array (ie. attempt to provide different or none object as array)
  18. };
  19. // -------------------------------------------------------------------------
  20. // JsonApi Handle is container encapsulating real JSON data being sent or recieved via. RESTful/ other service
  21. class JsonApiHandle
  22. {
  23. private void JsonApiHandle() {}
  24. private void ~JsonApiHandle() {}
  25. /**
  26. \brief Length of JSON
  27. */
  28. proto native int Size();
  29. /**
  30. \brief Return as string
  31. */
  32. proto native owned string AsString();
  33. /**
  34. \brief Invalidate handle and schedule removal
  35. */
  36. proto native void Invalidate();
  37. };
  38. // -------------------------------------------------------------------------
  39. // parent class for handling JsonApi Struct objects
  40. //
  41. //
  42. class JsonApi
  43. {
  44. private void JsonApi() {}
  45. private void ~JsonApi() {}
  46. /**
  47. \brief Override number of concurrent buffers used (depending project requirements, DEFAULT = 16, MIN = 4)
  48. */
  49. proto native void SetBuffers( int iBufferCount );
  50. /**
  51. \brief Actual number of total buffers active + free
  52. */
  53. proto native int BufferCount();
  54. /**
  55. \brief Maximum number of buffers used at once!
  56. */
  57. proto native int BufferMax();
  58. /**
  59. \brief List of all currently active handles
  60. */
  61. proto native void DebugList();
  62. };
  63. // -------------------------------------------------------------------------
  64. // JsonApi access methods
  65. proto native JsonApi CreateJsonApi();
  66. proto native void DestroyJsonApi();
  67. proto native JsonApi GetJsonApi();