Alchemy  1.0
A framework to robustly process network messages and structured data
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
Carbon.h File Reference

Carbon generates c-linkable interfaces for constructs generated by Alchemy. More...

#include <Alchemy.h>

Go to the source code of this file.

Functions

Hg_msg_t * Hg_clone (const Hg_msg_t *p_src)
 Creates a complete clone of an existing Hg message object. The caller must call Hg_destroy when they are done with the returned object to return the messages allocated memory. More...
 
Hg_msg_t * Hg_create (Hg_type_t msg_type)
 Creates a new Hg message object of the specified type. The caller must call Hg_destroy when they are done with the returned object to return the messages allocated memory. More...
 
size_t Hg_data_size (const Hg_msg_t *p_msg)
 Returns the number of bytes that are required to serialize this object. More...
 
void Hg_destroy (Hg_msg_t *p_msg)
 The specified message is destroyed. ALL memory is reclaimed, including dynamically allocated space. More...
 
int Hg_local_endianess ()
 Reports the type of endianess of the local system. More...
 
size_t Hg_pack (const Hg_msg_t *p_msg, void *p_buffer, size_t len)
 Serializes the specified message into a buffer. More...
 
size_t Hg_resize_dynamic (Hg_msg_t *p_msg, void *p_field, size_t len)
 Resize the buffer for a dynamically allocated field in an existing message. More...
 
size_t Hg_size (const Hg_msg_t *p_msg)
 Returns the size of the specified message. More...
 
int Hg_to_big_end (Hg_msg_t *p_msg)
 Converts this object, in-place, to big-endian byte-order. The message will always be converted as requested. More...
 
int Hg_to_host (Hg_msg_t *p_msg)
 Converts this object, in-place, to host byte-order. No actions will be performed if the local platform is big-endian. More...
 
int Hg_to_little_end (Hg_msg_t *p_msg)
 Converts this object, in-place, to little-endian byte-order. The message will always be converted as requested. More...
 
int Hg_to_network (Hg_msg_t *p_msg)
 Converts this object, in-place, to network byte-order. No actions will be performed if the local platform is big-endian. More...
 
Hg_type_t Hg_type (const Hg_msg_t *p_msg)
 Returns the type of the specified message. More...
 
size_t Hg_unpack (Hg_msg_t *p_msg, const void *p_buffer, size_t len)
 Deserializes the specified message from a buffer. More...
 

Detailed Description

Carbon generates c-linkable interfaces for constructs generated by Alchemy.

The MIT License(MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file Carbon.h.

Function Documentation

Hg_msg_t* Hg_clone ( const Hg_msg_t *  p_src)

Creates a complete clone of an existing Hg message object. The caller must call Hg_destroy when they are done with the returned object to return the messages allocated memory.

Parameters
p_src[in]A valid message object that should be cloned. All of the data inside of the message, including dynamically allocated space will be initialized to match the source message.
Returns
On success, an allocated message pointer is returned. This pointer can be cast to the structure that matches the type of requested message. 0 is returned on failure.

Definition at line 50 of file carbonate.cpp.

Hg_msg_t* Hg_create ( Hg_type_t  msg_type)

Creates a new Hg message object of the specified type. The caller must call Hg_destroy when they are done with the returned object to return the messages allocated memory.

Parameters
msg_type[in]
Returns
On success, an allocated message pointer is returned. This pointer can be cast to the structure that matches the type of requested message. 0 is returned on failure.

Definition at line 30 of file carbonate.cpp.

size_t Hg_data_size ( const Hg_msg_t *  p_msg)

Returns the number of bytes that are required to serialize this object.

Parameters
p_msg[in]The message to query.
Returns
The calculated buffer size required to serialize the specified message. 0 is returned if the buffer does not represent a valid msg.

Definition at line 112 of file carbonate.cpp.

void Hg_destroy ( Hg_msg_t *  p_msg)

The specified message is destroyed. ALL memory is reclaimed, including dynamically allocated space.

Parameters
p_msg[in]The previously allocated message to be destroyed. This message should not be used after it is passed to this function.

Definition at line 62 of file carbonate.cpp.

int Hg_local_endianess ( )

Reports the type of endianess of the local system.

Returns

Definition at line 21 of file carbonate.cpp.

size_t Hg_pack ( const Hg_msg_t *  p_msg,
void *  p_buffer,
size_t  len 
)

Serializes the specified message into a buffer.

Parameters
p_msg[in]The message to serialize.
p_buffer[out]The buffer that will be written into.
len[in]The length of the output buffer.
Returns
The number of bytes written to the serialized buffer. 0 indicates an error occurred.

Definition at line 173 of file carbonate.cpp.

size_t Hg_resize_dynamic ( Hg_msg_t *  p_msg,
void *  p_field,
size_t  len 
)

Resize the buffer for a dynamically allocated field in an existing message.

Parameters
p_msg[inout]
p_field[inout]
len[in]
Returns
The number of bytes allocated for the field is returned. If no bytes can be allocated, 0 is returned.

Definition at line 80 of file carbonate.cpp.

size_t Hg_size ( const Hg_msg_t *  p_msg)

Returns the size of the specified message.

Parameters
p_msg[in]The message to query.
Returns
The size of the buffer to hold the main message. 0 is returned if the buffer does not represent a valid msg.

Definition at line 102 of file carbonate.cpp.

int Hg_to_big_end ( Hg_msg_t *  p_msg)

Converts this object, in-place, to big-endian byte-order. The message will always be converted as requested.

Parameters
p_msg[in]The message to convert.
Returns
A status code indicating the result. 0 indicates success A negative value indicates an error.

Definition at line 151 of file carbonate.cpp.

int Hg_to_host ( Hg_msg_t *  p_msg)

Converts this object, in-place, to host byte-order. No actions will be performed if the local platform is big-endian.

Parameters
p_msg[in]The message to convert.
Returns
A status code indicating the result. 0 indicates success A negative value indicates an error.

Definition at line 140 of file carbonate.cpp.

int Hg_to_little_end ( Hg_msg_t *  p_msg)

Converts this object, in-place, to little-endian byte-order. The message will always be converted as requested.

Parameters
p_msg[in]The message to convert.
Returns
A status code indicating the result. 0 indicates success A negative value indicates an error.

Definition at line 162 of file carbonate.cpp.

int Hg_to_network ( Hg_msg_t *  p_msg)

Converts this object, in-place, to network byte-order. No actions will be performed if the local platform is big-endian.

Parameters
p_msg[in]The message to convert.
Returns
A status code indicating the result. 0 indicates success A negative value indicates an error.

Definition at line 127 of file carbonate.cpp.

Hg_type_t Hg_type ( const Hg_msg_t *  p_msg)

Returns the type of the specified message.

Parameters
p_msg[in]The message to query.
Returns
The enumerated type identifying this message is returned.

Definition at line 92 of file carbonate.cpp.

size_t Hg_unpack ( Hg_msg_t *  p_msg,
const void *  p_buffer,
size_t  len 
)

Deserializes the specified message from a buffer.

Parameters
p_msg[in]The message to populate from the serialized buffer.
p_buffer[out]The buffer that will be read from.
len[in]The length of the input buffer.
Returns
The number of bytes read from the serialized buffer. 0 indicates an error occurred.

Definition at line 186 of file carbonate.cpp.