123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- #include <stddef.h>
- #include "json.h"
- #include "json_object_private.h"
- #include "json_object_iterator.h"
- static const void* kObjectEndIterValue = NULL;
- struct json_object_iterator
- json_object_iter_begin(struct json_object* obj)
- {
- struct json_object_iterator iter;
- struct lh_table* pTable;
-
-
- pTable = json_object_get_object(obj);
- JASSERT(NULL != pTable);
-
-
- iter.opaque_ = pTable->head;
- return iter;
- }
- struct json_object_iterator
- json_object_iter_end(const struct json_object* obj)
- {
- struct json_object_iterator iter;
- JASSERT(NULL != obj);
- JASSERT(json_object_is_type(obj, json_type_object));
- iter.opaque_ = kObjectEndIterValue;
- return iter;
- }
- void
- json_object_iter_next(struct json_object_iterator* iter)
- {
- JASSERT(NULL != iter);
- JASSERT(kObjectEndIterValue != iter->opaque_);
- iter->opaque_ = ((const struct lh_entry *)iter->opaque_)->next;
- }
- const char*
- json_object_iter_peek_name(const struct json_object_iterator* iter)
- {
- JASSERT(NULL != iter);
- JASSERT(kObjectEndIterValue != iter->opaque_);
- return (const char*)(((const struct lh_entry *)iter->opaque_)->k);
- }
- struct json_object*
- json_object_iter_peek_value(const struct json_object_iterator* iter)
- {
- JASSERT(NULL != iter);
- JASSERT(kObjectEndIterValue != iter->opaque_);
- return (struct json_object*)lh_entry_v((const struct lh_entry *)iter->opaque_);
- }
- json_bool
- json_object_iter_equal(const struct json_object_iterator* iter1,
- const struct json_object_iterator* iter2)
- {
- JASSERT(NULL != iter1);
- JASSERT(NULL != iter2);
- return (iter1->opaque_ == iter2->opaque_);
- }
- struct json_object_iterator
- json_object_iter_init_default(void)
- {
- struct json_object_iterator iter;
-
- iter.opaque_ = NULL;
- return iter;
- }
|