Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
value.h91 linesDownload Raw Back to nodes
1/*-------------------------------------------------------------------------2 *3 * value.h4 *	  interface for value nodes5 *6 *7 * Copyright (c) 2003-2023, PostgreSQL Global Development Group8 *9 * src/include/nodes/value.h10 *11 *-------------------------------------------------------------------------12 */13 14#ifndef VALUE_H15#define VALUE_H16 17#include "nodes/nodes.h"18 19/*20 * The node types Integer, Float, String, and BitString are used to represent21 * literals in the lexer and are also used to pass constants around in the22 * parser.  One difference between these node types and, say, a plain int or23 * char * is that the nodes can be put into a List.24 *25 * (There used to be a Value node, which encompassed all these different node types.  Hence the name of this file.)26 */27 28typedef struct Integer29{30	pg_node_attr(special_read_write)31 32	NodeTag		type;33	int			ival;34} Integer;35 36/*37 * Float is internally represented as string.  Using T_Float as the node type38 * simply indicates that the contents of the string look like a valid numeric39 * literal.  The value might end up being converted to NUMERIC, so we can't40 * store it internally as a C double, since that could lose precision.  Since41 * these nodes are generally only used in the parsing process, not for runtime42 * data, it's better to use the more general representation.43 *44 * Note that an integer-looking string will get lexed as T_Float if the value45 * is too large to fit in an 'int'.46 */47typedef struct Float48{49	pg_node_attr(special_read_write)50 51	NodeTag		type;52	char	   *fval;53} Float;54 55typedef struct Boolean56{57	pg_node_attr(special_read_write)58 59	NodeTag		type;60	bool		boolval;61} Boolean;62 63typedef struct String64{65	pg_node_attr(special_read_write)66 67	NodeTag		type;68	char	   *sval;69} String;70 71typedef struct BitString72{73	pg_node_attr(special_read_write)74 75	NodeTag		type;76	char	   *bsval;77} BitString;78 79#define intVal(v)		(castNode(Integer, v)->ival)80#define floatVal(v)		atof(castNode(Float, v)->fval)81#define boolVal(v)		(castNode(Boolean, v)->boolval)82#define strVal(v)		(castNode(String, v)->sval)83 84extern Integer *makeInteger(int i);85extern Float *makeFloat(char *numericStr);86extern Boolean *makeBoolean(bool val);87extern String *makeString(char *str);88extern BitString *makeBitString(char *str);89 90#endif							/* VALUE_H */91 
codekingpro/portable-devtools · Team Ai