Newer
Older
libkc / modules / include / kc_iterator.h
/**
 * @file   kc_iterator.h
 * @brief  KC Iterator モジュール
 * @copyright  2003 - 2023  Nomura Kei
 * @depends
 * kc.h
 */
#ifndef KC_ITERATOR_H
#define KC_ITERATOR_H

#include <kc.h>

#ifdef __cplusplus
extern "C"
{
    namespace kc
    {
        using namespace std;
#endif

        /**
         * Iterator オブジェクト
         */
        typedef struct KcIterator_
        {
            /**
             * 次の要素の有無を取得します。
             *
             * @param ite Iterator オブジェクト
             * @return true/false (次の要素がある/次の要素がない)
             */
            bool (*hasNext)(struct KcIterator_ *ite);

            /**
             * 次の要素を取得します。
             *
             * @param ite Iterator オブジェクト
             * @param size 取得したオブジェクトのサイズ格納用
             * @return 次のオブジェクト
             */
            const void *(*next)(struct KcIterator_ *ite, size_t *size);

            /** 内部情報 */
            void *_info;

        } KcIterator;

        void KcIterator_delete(KcIterator *ite);

#ifdef __cplusplus
    } // namespace kc
} // extern "C"
#endif
#endif // KC_ITERATOR_H