INGOR
ytObject.h
1/*
2 lang/ytObject.{h,c} : Object abstraction
3 Copyright (C) 2018, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
16 distribution.
17
18 * Neither the name of Kyoto University nor the names of its
19 contributors may be used to endorse or promote products derived
20 from this software without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 POSSIBILITY OF SUCH DAMAGE.
34*/
35
36#include "ytType.h"
37
38#ifndef __YTLIB_OBJECT_H
39#define __YTLIB_OBJECT_H
40
41
42#ifndef DOXY
43typedef struct ytObject_t {
44 ytType type;
45} ytObject;
46#endif
47ytType ytObject_type(const ytObject * this);
49void ytObject_delete(ytObject * this);
50void ytObject_deletev(void * this);
51ytObject * ytObject_clone(const ytObject * this);
52ytObject * ytObject_parse(ytType type, const char * str);
53void ytObject_print(const ytObject * this, FILE * fp);
54int ytObject_sprint(const ytObject * this, char * buff, size_t size);
55void ytObject_printBuff(const ytObject * this, char ** buff, size_t * size);
56ytObject * ytObject_copy(const ytObject * this);
57int ytObject_compare(const ytObject * a, const ytObject * b);
58void ytObject_dump(const ytObject * this, FILE * fp);
59size_t ytObject_size(const ytObject * this);
60ytByte * ytObject_serialize(const ytObject * this, ytByte ** ptr);
61ytObject * ytObject_deserialize(ytByte ** const ptr);
62#ifdef USE_MPI
63#include <mpi.h>
64void ytObject_MPI_Bcast(ytObject ** pObject, int root, MPI_Comm comm);
65#endif /* USE_MPI */
66#endif /* __YTLIB_OBJECT_H */
The basis class.
void ytObject_delete(ytObject *this)
Deletes the ytObject instance.
Definition: ytObject.c:63
ytObject * ytObject_parse(ytType type, const char *str)
Parses the string expression of the value as the given type.
Definition: ytObject.c:118
ytType ytObject_type(const ytObject *this)
Returns the type of this ytObject instance.
Definition: ytObject.c:86
size_t ytObject_size(const ytObject *this)
Returns the memory size required for making a deep copy of the object.
Definition: ytObject.c:207
ytObject * ytObject_clone(const ytObject *this)
Returns the copy of the given ytObject.
Definition: ytObject.c:96
ytObject * ytObject_new(ytType type)
Generates a default instance of the given type.
Definition: ytObject.c:51
ytByte * ytObject_serialize(const ytObject *this, ytByte **pptr)
Serializes the object in the memory.
Definition: ytObject.c:231
ytObject * ytObject_deserialize(ytByte **const pptr)
De-serializes the object serialized in the memory.
Definition: ytObject.c:257
void ytObject_printBuff(const ytObject *this, char **buff, size_t *size)
Prints the contents of the object in the specified buffer.
Definition: ytObject.c:169
void ytObject_print(const ytObject *this, FILE *fp)
Prints the string expression of the value.
Definition: ytObject.c:131
ytType
Types supported by ytLib.
Definition: ytType.h:41