Ion C
C library for Ion
ion_symbol_table.h File Reference
#include "ion_types.h"
#include "ion_platform_config.h"

Go to the source code of this file.

Data Structures

struct  _ion_symbol_import_location
 
struct  _ion_symbol
 

Macros

#define ION_SYMBOL_IMPORT_LOCATION_IS_NULL(symbol)   ION_STRING_IS_NULL(&(symbol)->import_location.name)
 
#define ION_SYMBOL_IS_NULL(symbol)   (symbol == NULL || (ION_STRING_IS_NULL(&(symbol)->value) && ION_SYMBOL_IMPORT_LOCATION_IS_NULL(symbol) && (symbol)->sid == UNKNOWN_SID))
 
#define ION_SYMBOL_INIT(symbol)   ION_STRING_INIT(&(symbol)->value); ION_STRING_INIT(&(symbol)->import_location.name); (symbol)->sid = UNKNOWN_SID
 
#define UNKNOWN_SID   -1 /* symbol id's presume not only is this unknown, but sid's must be positive */
 
#define ION_SYS_SYMBOL_SHARED_SYMBOL_TABLE   "$ion_shared_symbol_table"
 
#define ION_SYS_STRLEN_SHARED_SYMBOL_TABLE   24 /* "$ion_shared_symbol_table" */
 
#define ION_SYS_SYMBOL_ION   "$ion"
 
#define ION_SYS_SYMBOL_IVM   "$ion_1_0" /* ion type marker */
 
#define ION_SYS_SYMBOL_ION_SYMBOL_TABLE   "$ion_symbol_table"
 
#define ION_SYS_SYMBOL_NAME   "name"
 
#define ION_SYS_SYMBOL_VERSION   "version"
 
#define ION_SYS_SYMBOL_IMPORTS   "imports"
 
#define ION_SYS_SYMBOL_SYMBOLS   "symbols"
 
#define ION_SYS_SYMBOL_MAX_ID   "max_id"
 
#define ION_SYS_SYMBOL_MAX_ID_UNDEFINED   -1
 
#define ION_SYS_SID_ION   1 /* "$ion" */
 
#define ION_SYS_SID_IVM   2 /* "$ion_1_0" aka ion type marker */
 
#define ION_SYS_SID_SYMBOL_TABLE   3 /* "$ion_symbol_table" */
 
#define ION_SYS_SID_NAME   4 /* "name" */
 
#define ION_SYS_SID_VERSION   5 /* "version" */
 
#define ION_SYS_SID_IMPORTS   6 /* "imports" */
 
#define ION_SYS_SID_SYMBOLS   7 /* "symbols" */
 
#define ION_SYS_SID_MAX_ID   8 /* "max_id" */
 
#define ION_SYS_SID_SHARED_SYMBOL_TABLE   9 /* "$ion_shared_symbol_table" */
 
#define ION_SYS_STRLEN_ION   4 /* "$ion" */
 
#define ION_SYS_STRLEN_IVM   8 /* "$ion_1_0" */
 
#define ION_SYS_STRLEN_SYMBOL_TABLE   17 /* "$ion_symbol_table" */
 
#define ION_SYS_STRLEN_NAME   4 /* "name" */
 
#define ION_SYS_STRLEN_VERSION   7 /* "version" */
 
#define ION_SYS_STRLEN_IMPORTS   7 /* "imports" */
 
#define ION_SYS_STRLEN_SYMBOLS   7 /* "symbols" */
 
#define ION_SYS_STRLEN_MAX_ID   6 /* "max_id" */
 

Typedefs

typedef struct _ion_symbol_import_location ION_SYMBOL_IMPORT_LOCATION
 
typedef enum _ION_SYMBOL_TABLE_TYPE ION_SYMBOL_TABLE_TYPE
 

Enumerations

enum  _ION_SYMBOL_TABLE_TYPE { ist_EMPTY = 0 , ist_LOCAL = 1 , ist_SHARED = 2 , ist_SYSTEM = 3 }
 

Functions

ION_API_EXPORT iERR ion_symbol_table_open (hSYMTAB *p_hsymtab, hOWNER owner)
 
ION_API_EXPORT iERR ion_symbol_table_open_with_type (hSYMTAB *p_hsymtab, hOWNER owner, ION_SYMBOL_TABLE_TYPE type)
 
ION_API_EXPORT iERR ion_symbol_table_clone (hSYMTAB hsymtab, hSYMTAB *p_hclone)
 
ION_API_EXPORT iERR ion_symbol_table_clone_with_owner (hSYMTAB hsymtab, hSYMTAB *p_hclone, hOWNER owner)
 
ION_API_EXPORT iERR ion_symbol_table_get_system_table (hSYMTAB *p_hsystem_table, int32_t version)
 
ION_API_EXPORT iERR ion_symbol_table_load (hREADER hreader, hOWNER owner, hSYMTAB *p_hsymtab)
 
ION_API_EXPORT iERR ion_symbol_table_unload (hSYMTAB hsymtab, hWRITER hwriter)
 
ION_API_EXPORT iERR ion_symbol_table_lock (hSYMTAB hsymtab)
 
ION_API_EXPORT iERR ion_symbol_table_is_locked (hSYMTAB hsymtab, BOOL *p_is_locked)
 
ION_API_EXPORT iERR ion_symbol_table_get_type (hSYMTAB hsymtab, ION_SYMBOL_TABLE_TYPE *p_type)
 
ION_API_EXPORT iERR ion_symbol_table_get_name (hSYMTAB hsymtab, iSTRING p_name)
 
ION_API_EXPORT iERR ion_symbol_table_get_version (hSYMTAB hsymtab, int32_t *p_version)
 
ION_API_EXPORT iERR ion_symbol_table_get_max_sid (hSYMTAB hsymtab, SID *p_max_id)
 
ION_API_EXPORT iERR ion_symbol_table_set_name (hSYMTAB hsymtab, iSTRING name)
 
ION_API_EXPORT iERR ion_symbol_table_set_version (hSYMTAB hsymtab, int32_t version)
 
ION_API_EXPORT iERR ion_symbol_table_set_max_sid (hSYMTAB hsymtab, SID max_id)
 
ION_API_EXPORT iERR ion_symbol_table_get_imports (hSYMTAB hsymtab, ION_COLLECTION **p_imports)
 
ION_API_EXPORT iERR ion_symbol_table_add_import (hSYMTAB hsymtab, ION_SYMBOL_TABLE_IMPORT_DESCRIPTOR *pimport, hCATALOG catalog)
 
ION_API_EXPORT iERR ion_symbol_table_import_symbol_table (hSYMTAB hsymtab, hSYMTAB hsymtab_import)
 
ION_API_EXPORT iERR ion_symbol_table_find_by_name (hSYMTAB hsymtab, iSTRING name, SID *p_sid)
 
ION_API_EXPORT iERR ion_symbol_table_find_by_sid (hSYMTAB hsymtab, SID sid, iSTRING *p_name)
 
ION_API_EXPORT iERR ion_symbol_table_is_symbol_known (hSYMTAB hsymtab, SID sid, BOOL *p_is_known)
 
ION_API_EXPORT iERR ion_symbol_table_get_symbol (hSYMTAB hsymtab, SID sid, ION_SYMBOL **p_sym)
 
ION_API_EXPORT iERR ion_symbol_table_get_local_symbol (hSYMTAB hsymtab, SID sid, ION_SYMBOL **p_sym)
 
ION_API_EXPORT iERR ion_symbol_table_add_symbol (hSYMTAB hsymtab, iSTRING name, SID *p_sid)
 
ION_API_EXPORT iERR ion_symbol_table_close (hSYMTAB hsymtab)
 
ION_API_EXPORT iERR ion_symbol_copy_to_owner (hOWNER owner, ION_SYMBOL *dst, ION_SYMBOL *src)
 
ION_API_EXPORT iERR ion_symbol_is_equal (ION_SYMBOL *lhs, ION_SYMBOL *rhs, BOOL *is_equal)
 
ION_API_EXPORT const char * ion_symbol_table_type_to_str (ION_SYMBOL_TABLE_TYPE t)
 

Variables

GLOBAL BYTE ION_SYMBOL_ION_BYTES []
 
GLOBAL BYTE ION_SYMBOL_VTM_BYTES []
 
GLOBAL BYTE ION_SYMBOL_SYMBOL_TABLE_BYTES []
 
GLOBAL BYTE ION_SYMBOL_NAME_BYTES []
 
GLOBAL BYTE ION_SYMBOL_VERSION_BYTES []
 
GLOBAL BYTE ION_SYMBOL_IMPORTS_BYTES []
 
GLOBAL BYTE ION_SYMBOL_SYMBOLS_BYTES []
 
GLOBAL BYTE ION_SYMBOL_MAX_ID_BYTES []
 
GLOBAL BYTE ION_SYMBOL_SHARED_SYMBOL_TABLE_BYTES []
 
GLOBAL ION_STRING ION_SYMBOL_ION_STRING
 
GLOBAL ION_STRING ION_SYMBOL_VTM_STRING
 
GLOBAL ION_STRING ION_SYMBOL_SYMBOL_TABLE_STRING
 
GLOBAL ION_STRING ION_SYMBOL_NAME_STRING
 
GLOBAL ION_STRING ION_SYMBOL_VERSION_STRING
 
GLOBAL ION_STRING ION_SYMBOL_IMPORTS_STRING
 
GLOBAL ION_STRING ION_SYMBOL_SYMBOLS_STRING
 
GLOBAL ION_STRING ION_SYMBOL_MAX_ID_STRING
 
GLOBAL ION_STRING ION_SYMBOL_SHARED_SYMBOL_TABLE_STRING
 
GLOBAL char * SYSTEM_SYMBOLS []
 

Function Documentation

◆ ion_symbol_copy_to_owner()

ION_API_EXPORT iERR ion_symbol_copy_to_owner ( hOWNER  owner,
ION_SYMBOL dst,
ION_SYMBOL src 
)

Copies an ION_SYMBOL to a new memory owner.

◆ ion_symbol_is_equal()

ION_API_EXPORT iERR ion_symbol_is_equal ( ION_SYMBOL lhs,
ION_SYMBOL rhs,
BOOL *  is_equal 
)

Compares the two given ION_SYMBOLs for equality under the Ion data model.

◆ ion_symbol_table_add_import()

ION_API_EXPORT iERR ion_symbol_table_add_import ( hSYMTAB  hsymtab,
ION_SYMBOL_TABLE_IMPORT_DESCRIPTOR *  pimport,
hCATALOG  catalog 
)

Imports a shared symbol table into a local symbol table, given a description of the import and the catalog in which it can be found. NOTE: the best match for the described shared symbol table import that is available in the catalog will be used. If no match is found, all of the import's symbols will be considered to have unknown text.

Parameters
hsymtab- The local symbol table into which the imported symbol table will be incorporated.
pimport- The description of the shared symbol table to be imported.
catalog- The catalog to query for the matching shared symbol table.

◆ ion_symbol_table_clone()

ION_API_EXPORT iERR ion_symbol_table_clone ( hSYMTAB  hsymtab,
hSYMTAB *  p_hclone 
)

Clones the given symbol table, using that symbol table's memory owner as the owner of the newly allocated symbol table.

Parameters
hsymtab- They symbol table to clone.
p_hclone- Pointer to a handle to the newly-allocated symbol table clone.

◆ ion_symbol_table_clone_with_owner()

ION_API_EXPORT iERR ion_symbol_table_clone_with_owner ( hSYMTAB  hsymtab,
hSYMTAB *  p_hclone,
hOWNER  owner 
)

Clones the given symbol table, using the given owner as the newly-allocated symbol table's memory owner.

Parameters
hsymtab- They symbol table to clone.
p_hclone- Pointer to a handle to the newly-allocated symbol table clone.
owner- Handle to the new symbol table's memory owner. If NULL, the resulting symbol table is its own memory owner and must be freed using ion_symbol_table_close.

◆ ion_symbol_table_close()

ION_API_EXPORT iERR ion_symbol_table_close ( hSYMTAB  hsymtab)

If the given symbol table is its own memory owner, its memory and everything it owns is freed. If the given symbol table has an external owner and that owner has not been freed, this does nothing; this symbol table will be freed when its memory owner is freed. If the given symbol table has an external owner which has been freed, the behavior of this function is undefined. NOTE: Symbol tables constructed and returned by readers and writers are owned by those readers and writers.

◆ ion_symbol_table_get_system_table()

ION_API_EXPORT iERR ion_symbol_table_get_system_table ( hSYMTAB *  p_hsystem_table,
int32_t  version 
)

Gets the global system symbol table for the given Ion version. This global system symbol table must never be closed.

Parameters
p_hsystem_table- Pointer to a handle to the global system symbol table.
version- The Ion version. Currently, must be 1.

◆ ion_symbol_table_import_symbol_table()

ION_API_EXPORT iERR ion_symbol_table_import_symbol_table ( hSYMTAB  hsymtab,
hSYMTAB  hsymtab_import 
)

Imports a shared symbol table into a local symbol table.

Parameters
hsymtab- The local symbol table into which the imported symbol table will be incorporated.
hsymtab_import- The shared symbol table to import.

◆ ion_symbol_table_load()

ION_API_EXPORT iERR ion_symbol_table_load ( hREADER  hreader,
hOWNER  owner,
hSYMTAB *  p_hsymtab 
)

Deserializes a symbol table (shared or local) from the given reader.

Parameters
hreader- The reader, positioned at the start of the symbol table struct.
owner- Handle to the new symbol table's memory owner. If NULL, the resulting symbol table is its own memory owner and must be freed using ion_symbol_table_close.
p_hsymtab- Pointer to a handle to the newly-allocated symbol table.

◆ ion_symbol_table_open()

ION_API_EXPORT iERR ion_symbol_table_open ( hSYMTAB *  p_hsymtab,
hOWNER  owner 
)

Allocates a new local symbol table.

Parameters
p_hsymtab- Pointer to a handle to the newly-allocated symbol table.
owner- Handle to the new symbol table's memory owner. If NULL, the resulting symbol table is its own memory owner and must be freed using ion_symbol_table_close.

◆ ion_symbol_table_open_with_type()

ION_API_EXPORT iERR ion_symbol_table_open_with_type ( hSYMTAB *  p_hsymtab,
hOWNER  owner,
ION_SYMBOL_TABLE_TYPE  type 
)

Allocates a new local symbol table of the given type (i.e. shared or local).

Parameters
p_hsymtab- Pointer to a handle to the newly-allocated symbol table.
owner- Handle to the new symbol table's memory owner. If NULL, the resulting symbol table is its own memory owner and must be freed using ion_symbol_table_close.

◆ ion_symbol_table_unload()

ION_API_EXPORT iERR ion_symbol_table_unload ( hSYMTAB  hsymtab,
hWRITER  hwriter 
)

Serializes a symbol table (shared or local) using the given writer.

Parameters
hsymtab- The symbol table to serialize.
hwriter- The writer (text or binary).

Variable Documentation

◆ SYSTEM_SYMBOLS

GLOBAL char* SYSTEM_SYMBOLS[]

The set of system symbols as defined by Ion 1.0.