recordio.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef __RECORDIO_H__
  19. #define __RECORDIO_H__
  20. #include <sys/types.h>
  21. #include <stdint.h> /* for int64_t */
  22. #ifdef WIN32
  23. #include "winconfig.h"
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. struct buffer {
  29. int32_t len;
  30. char *buff;
  31. };
  32. void deallocate_String(char **s);
  33. void deallocate_Buffer(struct buffer *b);
  34. void deallocate_vector(void *d);
  35. struct iarchive {
  36. int (*start_record)(struct iarchive *ia, const char *tag);
  37. int (*end_record)(struct iarchive *ia, const char *tag);
  38. int (*start_vector)(struct iarchive *ia, const char *tag, int32_t *count);
  39. int (*end_vector)(struct iarchive *ia, const char *tag);
  40. int (*deserialize_Bool)(struct iarchive *ia, const char *name, int32_t *);
  41. int (*deserialize_Int)(struct iarchive *ia, const char *name, int32_t *);
  42. int (*deserialize_Long)(struct iarchive *ia, const char *name, int64_t *);
  43. int (*deserialize_Buffer)(struct iarchive *ia, const char *name,
  44. struct buffer *);
  45. int (*deserialize_String)(struct iarchive *ia, const char *name, char **);
  46. void *priv;
  47. };
  48. struct oarchive {
  49. int (*start_record)(struct oarchive *oa, const char *tag);
  50. int (*end_record)(struct oarchive *oa, const char *tag);
  51. int (*start_vector)(struct oarchive *oa, const char *tag, const int32_t *count);
  52. int (*end_vector)(struct oarchive *oa, const char *tag);
  53. int (*serialize_Bool)(struct oarchive *oa, const char *name, const int32_t *);
  54. int (*serialize_Int)(struct oarchive *oa, const char *name, const int32_t *);
  55. int (*serialize_Long)(struct oarchive *oa, const char *name,
  56. const int64_t *);
  57. int (*serialize_Buffer)(struct oarchive *oa, const char *name,
  58. const struct buffer *);
  59. int (*serialize_String)(struct oarchive *oa, const char *name, char **);
  60. void *priv;
  61. };
  62. struct oarchive *create_buffer_oarchive(void);
  63. void close_buffer_oarchive(struct oarchive **oa, int free_buffer);
  64. struct iarchive *create_buffer_iarchive(char *buffer, int len);
  65. void close_buffer_iarchive(struct iarchive **ia);
  66. char *get_buffer(struct oarchive *);
  67. int get_buffer_len(struct oarchive *);
  68. int64_t zoo_htonll(int64_t v);
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #endif