qemu/include/qapi/qmp/qnum.h
<<
>>
Prefs
   1/*
   2 * QNum Module
   3 *
   4 * Copyright (C) 2009 Red Hat Inc.
   5 *
   6 * Authors:
   7 *  Luiz Capitulino <lcapitulino@redhat.com>
   8 *  Anthony Liguori <aliguori@us.ibm.com>
   9 *  Marc-André Lureau <marcandre.lureau@redhat.com>
  10 *
  11 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  12 * See the COPYING.LIB file in the top-level directory.
  13 */
  14
  15#ifndef QNUM_H
  16#define QNUM_H
  17
  18#include "qapi/qmp/qobject.h"
  19
  20typedef enum {
  21    QNUM_I64,
  22    QNUM_U64,
  23    QNUM_DOUBLE
  24} QNumKind;
  25
  26typedef struct QNum {
  27    QObject base;
  28    QNumKind kind;
  29    union {
  30        int64_t i64;
  31        uint64_t u64;
  32        double dbl;
  33    } u;
  34} QNum;
  35
  36QNum *qnum_from_int(int64_t value);
  37QNum *qnum_from_uint(uint64_t value);
  38QNum *qnum_from_double(double value);
  39
  40bool qnum_get_try_int(const QNum *qn, int64_t *val);
  41int64_t qnum_get_int(const QNum *qn);
  42
  43bool qnum_get_try_uint(const QNum *qn, uint64_t *val);
  44uint64_t qnum_get_uint(const QNum *qn);
  45
  46double qnum_get_double(QNum *qn);
  47
  48char *qnum_to_string(QNum *qn);
  49
  50QNum *qobject_to_qnum(const QObject *obj);
  51void qnum_destroy_obj(QObject *obj);
  52
  53#endif /* QNUM_H */
  54