Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, April 19, 2024

File: [Platon] / libco / libco / co_type.c (download)

Revision 1.3, Sun Mar 9 10:32:17 2003 UTC (21 years, 1 month ago) by yenar


Changes since 1.2: +6 -0 lines

fix documentation (doxygen) headers (co_conv.h, co_debug.c, co_gettext.h, co_gettext.c, co_module.h, co_type.c)

/***{{{*******************************************************************
 * This file is part of libco - object library for C                     *
 * Copyright (c) 2002                                                    *
 *     Peter Rockai (yenar) <yenar@host.sk>                              *
 *                                                                       *
 * This library is free software; you can redistribute it and/or         *
 * modify it under the terms of the GNU Lesser General Public            *
 * License as published by the Free Software Foundation; either          *
 * version 2 of the License, or (at your option) any later version.      *
 *                                                                       *
 * This library is distributed in the hope that it will be useful,       *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 * Lesser General Public License for more details.                       *
 *                                                                       *
 * You should have received a copy of the GNU Lesser General Public      *
 * License along with this library; if not, write to the Free Software   *
 * Foundation, Inc., 59 Temple Place, Suite 330,                         *
 * Boston, MA 02111-1307  USA                                            *
 *******************************************************************}}}***/
/* {{{ file description */
/**
 * @file co_type.c
 * @brief Basic operations over type-agnostic variables.
 **/
/* }}} */

#include "co_object.h"
#include "co_type.h"
#include "co_conv.h"
#include "co_string.h"
#include "co_util.h"

#include "co_type.cometa"

/* {{{ */
co_v co_v_copy (co_type t, co_v s)
{
    co_v d;
    switch (t) {
        case co_t_char_p:
            d . _char_p = strdup_in (s . _char_p);
            break;
        case co_t_double_p:
            if ((d . _double_p = s . _double_p)) {
                d . _double_p = new (double);
                * d . _double_p = * s . _double_p;
                cox_pop (d . _double_p);
            }
            break;
        case co_t_co:
            d . _co = 0;
            if (s . _co)
                d . _co = M (s . _co, dup) . _co;
            if (d . _co == s . _co)
                d . _co = 0;
            else
                cox_pop (d . _co);
            break;
        default:
            d = s;
    }
    return d;
}
/* }}} */
/* {{{ */
char *co_v_format (co_type t, co_v s)
{
    char *rv;
    switch (t) {
        case co_t_char_p:
            rv = strdup_in (s . _char_p); break;
        case co_t_double_p:
            rv = saprintf ("%lf", *s . _double_p); break;
        case co_t_int:
            rv = saprintf ("%d", s . _int); break;
        case co_t_co:
            rv = strdup2 (s . _co ? M (s . _co, format) . _char_p : 0);
            cox_pop (rv);
            break;
        default:
            rv = 0; break;
    }
    CO_DEBUG (2, "return: %s", rv);
    return rv;
}
/* }}} */
#if 0
/* {{{ */
co_v co_v_extract (co_type t, const char *s)
{
    co_v rv;
    switch (t) {
        case co_t_char_p:
            rv . char_p = strdup_in (s); break;
        case co_t_i:
            rv . i = atoi_in (s); break;
        case co_t_f_p:
            rv . double_p = new_p (double);
        default:
            return 0;
    }
}
/* }}} */
#endif

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top