/*
   +----------------------------------------------------------------------+
   | Copyright © The PHP Group and Contributors.                          |
   +----------------------------------------------------------------------+
   | This source file is subject to the Modified BSD License that is      |
   | bundled with this package in the file LICENSE, and is available      |
   | through the World Wide Web at <https://www.php.net/license/>.        |
   |                                                                      |
   | SPDX-License-Identifier: BSD-3-Clause                                |
   +----------------------------------------------------------------------+
   | Authors: Bogdan Ungureanu <bogdanungureanu21@gmail.com>              |
   +----------------------------------------------------------------------+
*/

#ifndef LISTFORMATTER_CLASS_H
#define LISTFORMATTER_CLASS_H

#include <php.h>

#include "intl_common.h"
#include "intl_error.h"
#include "intl_data.h"

#ifdef __cplusplus
#include <unicode/listformatter.h>
using icu::ListFormatter;
#else
typedef void ListFormatter;
#endif

typedef struct {
    // error handling
    intl_error      error;

    // formatter handling
    ListFormatter*  ulistfmt;
} listformatter_data;

typedef struct {
    listformatter_data  lf_data;
    zend_object     zo;
} ListFormatter_object;

#define php_intl_listformatter_fetch_object(obj) ZEND_CONTAINER_OF(obj, ListFormatter_object, zo)
#define Z_INTL_LISTFORMATTER_P(zv) php_intl_listformatter_fetch_object(Z_OBJ_P(zv))

#define LISTFORMATTER_ERROR(lfo) (lfo)->lf_data.error
#define LISTFORMATTER_ERROR_P(lfo) &(LISTFORMATTER_ERROR(lfo))

#define LISTFORMATTER_OBJECT(lfo) (lfo)->lf_data.ulistfmt

#ifdef __cplusplus
extern "C" {
#endif
void listformatter_register_class( void );
extern zend_class_entry *ListFormatter_ce_ptr;
#ifdef __cplusplus
}
#endif

#define INTL_LISTFORMATTER_FALLBACK_TYPE_AND 0
#define INTL_LISTFORMATTER_FALLBACK_WIDTH_WIDE 0

#endif // LISTFORMATTER_CLASS_H 
