//////////////////////////////////////////////////////////////////////////////// /// @brief logging macros and functions /// /// @file /// /// DISCLAIMER /// /// Copyright 2004-2012 triagens GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is triAGENS GmbH, Cologne, Germany /// /// @author Dr. Frank Celler /// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// #ifndef TRIAGENS_BASICS_C_STRING_BUFFER_H #define TRIAGENS_BASICS_C_STRING_BUFFER_H 1 #include "BasicsC/common.h" #ifdef __cplusplus extern "C" { #endif // ----------------------------------------------------------------------------- // --SECTION-- public types // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief string buffer with formatting routines //////////////////////////////////////////////////////////////////////////////// typedef struct TRI_string_buffer_s { char* _buffer; char* _current; size_t _len; } TRI_string_buffer_t; //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- constructors and destructors // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief create a new string buffer and initialise it //////////////////////////////////////////////////////////////////////////////// TRI_string_buffer_t* TRI_CreateStringBuffer (void); //////////////////////////////////////////////////////////////////////////////// /// @brief initialises the string buffer /// /// @warning You must call initialise before using the string buffer. //////////////////////////////////////////////////////////////////////////////// void TRI_InitStringBuffer (TRI_string_buffer_t *); //////////////////////////////////////////////////////////////////////////////// /// @brief frees the string buffer /// /// @warning You must call free or destroy after using the string buffer. //////////////////////////////////////////////////////////////////////////////// void TRI_DestroyStringBuffer (TRI_string_buffer_t *); //////////////////////////////////////////////////////////////////////////////// /// @brief frees the string buffer and cleans the buffer /// /// @warning You must call free after or destroy using the string buffer. //////////////////////////////////////////////////////////////////////////////// void TRI_AnnihilateStringBuffer (TRI_string_buffer_t *); //////////////////////////////////////////////////////////////////////////////// /// @brief frees the string buffer and the pointer //////////////////////////////////////////////////////////////////////////////// void TRI_FreeStringBuffer (TRI_string_buffer_t *); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief swaps content with another string buffer //////////////////////////////////////////////////////////////////////////////// void TRI_SwapStringBuffer (TRI_string_buffer_t * self, TRI_string_buffer_t * other); //////////////////////////////////////////////////////////////////////////////// /// @brief returns pointer to the beginning of the character buffer //////////////////////////////////////////////////////////////////////////////// char const * TRI_BeginStringBuffer (TRI_string_buffer_t const * self); //////////////////////////////////////////////////////////////////////////////// /// @brief returns pointer to the end of the character buffer //////////////////////////////////////////////////////////////////////////////// char const * TRI_EndStringBuffer (TRI_string_buffer_t const * self); //////////////////////////////////////////////////////////////////////////////// /// @brief returns length of the character buffer //////////////////////////////////////////////////////////////////////////////// size_t TRI_LengthStringBuffer (TRI_string_buffer_t const * self); //////////////////////////////////////////////////////////////////////////////// /// @brief returns true if buffer is empty //////////////////////////////////////////////////////////////////////////////// bool TRI_EmptyStringBuffer (TRI_string_buffer_t const * self); //////////////////////////////////////////////////////////////////////////////// /// @brief clears the buffer //////////////////////////////////////////////////////////////////////////////// void TRI_ClearStringBuffer (TRI_string_buffer_t * self); //////////////////////////////////////////////////////////////////////////////// /// @brief copies the string buffer //////////////////////////////////////////////////////////////////////////////// void TRI_CopyStringBuffer (TRI_string_buffer_t * self, TRI_string_buffer_t const * source); //////////////////////////////////////////////////////////////////////////////// /// @brief removes the first characters //////////////////////////////////////////////////////////////////////////////// void TRI_EraseFrontStringBuffer (TRI_string_buffer_t * self, size_t len); //////////////////////////////////////////////////////////////////////////////// /// @brief replaces characters //////////////////////////////////////////////////////////////////////////////// void TRI_ReplaceStringStringBuffer (TRI_string_buffer_t * self, char const * str, size_t len); //////////////////////////////////////////////////////////////////////////////// /// @brief replaces characters //////////////////////////////////////////////////////////////////////////////// void TRI_ReplaceStringBufferStringBuffer (TRI_string_buffer_t * self, TRI_string_buffer_t const * text); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- STRING APPENDERS // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief appends character //////////////////////////////////////////////////////////////////////////////// void TRI_AppendCharStringBuffer (TRI_string_buffer_t * self, char chr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends characters //////////////////////////////////////////////////////////////////////////////// void TRI_AppendStringStringBuffer (TRI_string_buffer_t * self, char const * str); //////////////////////////////////////////////////////////////////////////////// /// @brief appends characters //////////////////////////////////////////////////////////////////////////////// void TRI_AppendString2StringBuffer (TRI_string_buffer_t * self, char const * str, size_t len); //////////////////////////////////////////////////////////////////////////////// /// @brief appends a string buffer //////////////////////////////////////////////////////////////////////////////// void TRI_AppendStringBufferStringBuffer (TRI_string_buffer_t * self, TRI_string_buffer_t const * text); //////////////////////////////////////////////////////////////////////////////// /// @brief appends a blob //////////////////////////////////////////////////////////////////////////////// void TRI_AppendBlobStringBuffer (TRI_string_buffer_t * self, TRI_blob_t const * text); //////////////////////////////////////////////////////////////////////////////// /// @brief appends eol character //////////////////////////////////////////////////////////////////////////////// void TRI_AppendEolStringBuffer (TRI_string_buffer_t * self); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- INTEGER APPENDERS // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief appends integer with two digits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendInteger2StringBuffer (TRI_string_buffer_t * self, uint32_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends integer with three digits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendInteger3StringBuffer (TRI_string_buffer_t * self, uint32_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends integer with four digits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendInteger4StringBuffer (TRI_string_buffer_t * self, uint32_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends integer with 8 bits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendInt8StringBuffer (TRI_string_buffer_t * self, int8_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends unsigned integer with 8 bits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendUInt8StringBuffer (TRI_string_buffer_t * self, uint8_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends integer with 16 bits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendInt16StringBuffer (TRI_string_buffer_t * self, int16_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends unsigned integer with 32 bits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendUInt16StringBuffer (TRI_string_buffer_t * self, uint16_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends integer with 32 bits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendInt32StringBuffer (TRI_string_buffer_t * self, int32_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends unsigned integer with 32 bits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendUInt32StringBuffer (TRI_string_buffer_t * self, uint32_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends integer with 64 bits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendInt64StringBuffer (TRI_string_buffer_t * self, int64_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends unsigned integer with 64 bits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendUInt64StringBuffer (TRI_string_buffer_t * self, uint64_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends size_t //////////////////////////////////////////////////////////////////////////////// void TRI_AppendSizeStringBuffer (TRI_string_buffer_t * self, size_t attr); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- INTEGER OCTAL APPENDERS // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief appends unsigned integer with 32 bits in octal //////////////////////////////////////////////////////////////////////////////// void TRI_AppendUInt32OctalStringBuffer (TRI_string_buffer_t * self, uint32_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends unsigned integer with 64 bits in octal //////////////////////////////////////////////////////////////////////////////// void TRI_AppendUInt64OctalStringBuffer (TRI_string_buffer_t * self, uint64_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends size_t in octal //////////////////////////////////////////////////////////////////////////////// void TRI_AppendSizeOctalStringBuffer (TRI_string_buffer_t * self, size_t attr); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- INTEGER HEX APPENDERS // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief appends unsigned integer with 32 bits in hex //////////////////////////////////////////////////////////////////////////////// void TRI_AppendUInt32HexStringBuffer (TRI_string_buffer_t * self, uint32_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends unsigned integer with 64 bits in hex //////////////////////////////////////////////////////////////////////////////// void TRI_AppendUInt64HexStringBuffer (TRI_string_buffer_t * self, uint64_t attr); //////////////////////////////////////////////////////////////////////////////// /// @brief appends size_t in hex //////////////////////////////////////////////////////////////////////////////// void TRI_AppendSizeHexStringBuffer (TRI_string_buffer_t * self, size_t attr); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- FLOAT APPENDERS // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief appends floating point number with 8 bits //////////////////////////////////////////////////////////////////////////////// void TRI_AppendDoubleStringBuffer (TRI_string_buffer_t * self, double attr); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- DATE AND TIME APPENDERS // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief appends time in standard format //////////////////////////////////////////////////////////////////////////////// void TRI_AppendTimeStringBuffer (TRI_string_buffer_t * self, int32_t attr); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- CSV APPENDERS // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup Strings /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief appends csv 32-bit integer //////////////////////////////////////////////////////////////////////////////// void TRI_AppendCsvInt32StringBuffer (TRI_string_buffer_t * self, int32_t i); //////////////////////////////////////////////////////////////////////////////// /// @brief appends csv unisgned 32-bit integer //////////////////////////////////////////////////////////////////////////////// void TRI_AppendCsvUInt32StringBuffer (TRI_string_buffer_t * self, uint32_t i); //////////////////////////////////////////////////////////////////////////////// /// @brief appends csv 64-bit integer //////////////////////////////////////////////////////////////////////////////// void TRI_AppendCsvInt64StringBuffer (TRI_string_buffer_t * self, int64_t i); //////////////////////////////////////////////////////////////////////////////// /// @brief appends csv unsigned 64-bit integer //////////////////////////////////////////////////////////////////////////////// void TRI_AppendCsvUInt64StringBuffer (TRI_string_buffer_t * self, uint64_t i); //////////////////////////////////////////////////////////////////////////////// /// @brief appends csv double //////////////////////////////////////////////////////////////////////////////// void TRI_AppendCsvDoubleStringBuffer (TRI_string_buffer_t * self, double d); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus } #endif #endif // Local Variables: // mode: outline-minor // outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)" // End: