INGOR
Loading...
Searching...
No Matches
ytNode.h
1/*
2 net/ytNode.{h,c} : Node in networks
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#ifndef __YTLIB_NODE_H
37#define __YTLIB_NODE_H
38
39#include "lang/ytObject.h"
40#include "util/ytKeyValues.h"
41
42typedef struct {
43 ytObject obj;
44 char * name;
45 ytKeyValues * prop;
46} ytNode;
47
48ytNode * ytNode_new();
49void ytNode_delete(ytNode * this);
50ytNode * ytNode_newName(const char * name);
51ytNode * ytNode_clone(const ytNode * this);
52void ytNode_dump(ytNode * this, FILE * fp);
53void ytNode_setName(ytNode * this, const char * name);
54const char * ytNode_getName(const ytNode * this);
55ytObject * ytNode_obj(ytNode * this);
56ytNode * ytNode_from(ytObject * obj);
57size_t ytNode_numProperties(const ytNode * this);
58void ytNode_addProperty(ytNode * this, const char * key, ytObject * value);
59void ytNode_setProperty(ytNode * this, const char * key, ytObject * value);
60void ytNode_setPropertyInt(ytNode * this, const char * key, int value);
61void ytNode_setPropertyDouble(ytNode * this, const char * key, double value);
62void ytNode_setPropertyString(ytNode * this, const char * key, const char * value);
63ytObject * ytNode_getProperty(const ytNode * this, const char * key);
64ytObject * ytNode_getPropertyAt(ytNode * this, size_t i);
65int ytNode_getPropertyInt(ytNode * this, const char * key, int defValue);
66const char * ytNode_getPropertyString(const ytNode * this, const char * key);
67ytStrArray * ytNode_getPropertyKeys(ytNode * this, ytStrArray * ar);
68const char * ytNode_getPropertyKey(const ytNode * this, size_t i);
69ytType ytNode_getPropertyType(const ytNode * this, size_t i );
70
71size_t ytNode_size(const ytNode * this);
72ytByte * ytNode_serialize(const ytNode * this, ytByte ** pptr);
73ytNode * ytNode_deserialize(ytByte ** const pptr);
74size_t ytNode_sizeI(const ytObject * obj);
75ytByte * ytNode_serializeI(const ytObject * obj, ytByte ** pptr);
76ytObject * ytNode_deserializeI(ytByte ** const pptr);
77
78#ifndef DOXY
79int ytNode_test(int argc, char * argv[]);
80#endif /* DOXY */
81
82#endif /* __YTLIB_NODE_H */
key-value pairs.
The basis class.
Expandable array.
ytType
Types supported by ytLib.
Definition ytType.h:41
Network node.
Definition ytNode.h:42