diff options
author | Dmitri Pal <dpal@redhat.com> | 2010-03-05 17:23:00 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-03-08 13:42:47 -0500 |
commit | dd785dbfa82249c315e102f6a355f1580d3c7436 (patch) | |
tree | da5fd3c62b794431b0c70db1237fcf163ba3da0b | |
parent | 182a87ca35b3e6c87d7ad6a5e57c0f72efecd743 (diff) | |
download | sssd_unused-dd785dbfa82249c315e102f6a355f1580d3c7436.tar.gz sssd_unused-dd785dbfa82249c315e102f6a355f1580d3c7436.tar.xz sssd_unused-dd785dbfa82249c315e102f6a355f1580d3c7436.zip |
Documentation for collection interface
Passed through the interface and changed the comments to
comply with the collection interface.
-rw-r--r-- | common/collection/Makefile.am | 18 | ||||
-rw-r--r-- | common/collection/collection.cfg.doxy.in | 1566 | ||||
-rw-r--r-- | common/collection/collection.h | 3706 | ||||
-rw-r--r-- | common/collection/collection_cnv.c | 2 | ||||
-rw-r--r-- | common/collection/collection_iter.c | 3 | ||||
-rw-r--r-- | common/collection/collection_queue.h | 276 | ||||
-rw-r--r-- | common/collection/collection_stack.h | 277 | ||||
-rw-r--r-- | common/collection/collection_tools.h | 194 | ||||
-rw-r--r-- | common/collection/configure.ac | 9 |
9 files changed, 5171 insertions, 880 deletions
diff --git a/common/collection/Makefile.am b/common/collection/Makefile.am index 36e9558c..b9975d18 100644 --- a/common/collection/Makefile.am +++ b/common/collection/Makefile.am @@ -1,6 +1,8 @@ #DEBUG_FLAGS=@DEBUG_VAR@ TRACE_LEVEL=@TRACE_VAR@ +DOXYGEN = @DOXYGEN@ + topdir=$(srcdir)/.. AM_CFLAGS = @@ -50,6 +52,22 @@ collection_stack_ut_LDADD = libcollection.la collection_queue_ut_SOURCES = collection_queue_ut.c collection_queue_ut_LDADD = libcollection.la +if HAVE_DOXYGEN +docs: +# A temp way of building docs until we hook into the package build + rm -fR doc + mkdir -p doc + $(DOXYGEN) collection.cfg.doxy +else +docs: + @echo "Doxygen not installed, cannot generate documentation" + @exit 1 +endif + + TESTS = collection_ut collection_stack_ut collection_queue_ut tests: all $(check_PROGRAMS) + +clean-local: + rm -Rf doc diff --git a/common/collection/collection.cfg.doxy.in b/common/collection/collection.cfg.doxy.in new file mode 100644 index 00000000..e5ac3a12 --- /dev/null +++ b/common/collection/collection.cfg.doxy.in @@ -0,0 +1,1566 @@ +# Doxyfile 1.6.3 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "libcollection" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = @PACKAGE_VERSION@ + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = NO + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = YES + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = YES + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = NO + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = @srcdir@ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.c *.h + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = *_ut.c *priv* config.h + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# If the HTML_FOOTER_DESCRIPTION tag is set to YES, Doxygen will +# add generated date, project name and doxygen version to HTML footer. + +HTML_FOOTER_DESCRIPTION= NO + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = YES + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/common/collection/collection.h b/common/collection/collection.h index 1121b16f..52376097 100644 --- a/common/collection/collection.h +++ b/common/collection/collection.h @@ -24,499 +24,2018 @@ #include <stdint.h> -#ifndef EOK -#define EOK 0 -#endif - -#define COL_TYPE_STRING 0x00000001 /* For elements of type string the - lenght includes the trailing 0 */ -#define COL_TYPE_BINARY 0x00000002 -#define COL_TYPE_INTEGER 0x00000004 -#define COL_TYPE_UNSIGNED 0x00000008 -#define COL_TYPE_LONG 0x00000010 -#define COL_TYPE_ULONG 0x00000020 -#define COL_TYPE_DOUBLE 0x00000040 -#define COL_TYPE_BOOL 0x00000080 -#define COL_TYPE_COLLECTION 0x00000100 /* The item of this type denotes - that starting element of a - collection */ -#define COL_TYPE_COLLECTIONREF 0x00000200 /* An item of this type is a pointer - to an existing external - collection */ -#define COL_TYPE_END 0x10000000 /* Special type that denotes the end - of the collection. Useful when - traversing collections */ -#define COL_TYPE_ANY 0x0FFFFFFF /* Special type that denotes any. - Useful when traversing - collections */ - - -/* Default class for a free form collection */ -#define COL_CLASS_DEFAULT 0 - -/* The modes that define how one collection can be added to another */ - -#define COL_ADD_MODE_REFERENCE 0 /* The collection will contain a pointer - * to another */ -#define COL_ADD_MODE_EMBED 1 /* The collection will become part of - * another collection. - * After this operation the handle should - * not be used or freed. - * Can't be done more than once. - * If the collection is referenced by - * another collection, the operation will - * fail. */ -#define COL_ADD_MODE_CLONE 2 /* Creates a deep copy of a collection with - * its sub collections */ -#define COL_ADD_MODE_FLAT 3 /* Creates a deep copy of a collection with - * its sub collections flattening and NOT - * resolving duplicates. - */ -#define COL_ADD_MODE_FLATDOT 4 /* Creates a deep copy of a collection with - * its sub collections flattening and NOT - * resolving duplicates. Names are contructed - * in dotted notation. - * For example the subcollection - * named "sub" containing "foo" and - * "bar" will be flattened as: - * "sub.foo", "sub.bar". - */ - -/* Modes how the collection is traversed */ -#define COL_TRAVERSE_DEFAULT 0x00000000 /* Traverse all items */ -#define COL_TRAVERSE_ONELEVEL 0x00000001 /* Flag to traverse only top level - * ignored if the IGNORE flag is - * specified */ -#define COL_TRAVERSE_END 0x00000002 /* Call the handler once more when the - * end of the collection is reached. - * Good for processing nested - * collections. - */ -#define COL_TRAVERSE_IGNORE 0x00000004 /* Ignore sub collections as if none - * is present */ -#define COL_TRAVERSE_FLAT 0x00000008 /* Flatten the collection. */ - - -/* Additional iterator flags - * NOTE: ignored by traverse functions */ -#define COL_TRAVERSE_SHOWSUB 0x00010000 /* Include headers of sub collections - * By default iterators return just - * references and skips headers. - * Ignored if the ONELEVEL flag is - * specified and not ignored. - * Ignored if the FLAT flag is - * specified. */ -#define COL_TRAVERSE_ONLYSUB 0x00020000 /* Show the header of the sub - * collection instead of reference. - * Ignored if the ONELEVEL flag is - * specified and not ignored. - * Ignored if the FLAT flag is - * specified. */ - -/* NOTE COL_TRAVERSE_FLAT, COL_TRAVERSE_SHOWSUB, COL_TRAVERSE_ONLYSUB - * are mutually exclusive flags. If combined together - * results will be unpredictable. - * DO NOT MIX THEM IN ONE ITERATOR. - */ - - -/* Modes accepted by copy collection function */ -#define COL_COPY_NORMAL 0 /* Deep copy. Referenced collections - * of the donor are copied as sub - * collections. - */ -#define COL_COPY_FLAT 1 /* Deep copy. Collection is flattend. */ -#define COL_COPY_FLATDOT 2 /* Deep copy. Collection is flattend. - * Names are concatenated with dot. - */ -#define COL_COPY_KEEPREF 3 /* Deep copy but leave references - * as references. - */ -#define COL_COPY_TOP 4 /* Copy only top level - */ - -/* Match values */ -#define COL_NOMATCH 0 -#define COL_MATCH 1 - -/* Deapth for iteraor depth allocation block */ -#define STACK_DEPTH_BLOCK 15 - -/* Public declaration of the private data */ -#ifndef COLLECTION_PRIV_H -/* Structure that holds one property. */ -struct collection_item; - -/* Your implementation can assume that following members - * will always be members of the collection_item. - * but you should use get_item_xxx functions to get them. - * char *property; - * int property_len; - * int type; - * int length; - * void *data; - */ - - -/* Internal iterator structure */ -struct collection_iterator; -#endif /* COLLECTION_PRIV_H */ - -/* IMPORTANT - the collection is a set of items of different type. - * There is always a header item in any collection that starts the collection. - * Most of the functions in the interface (unless explicitly stated otherwise) - * assume that the collection_item * argument points to the header element. - * Passing in elements extracted from the middle of a collection to functions - * that expect header elements is illegal. There might be not enough checking - * at the moment but this will be enforced in future versions of the library. - - * IMPORTANT - To better understand how collections work imagine travel bags. +/** @mainpage The COLLECTION interface + * The collection is a set of items of different types. + * + * To better understand how collections work imagine travel bags. * They usually come in different sizes and one can put a bag in a bag when * they put away to the shelf in a garage or closet. Collection is such bag * except that you can put other bags into each other even if they are not - * empty. + * empty.<br> * When you put items into a bag you do not see the contents of the bag. * You just hold the bag. How many other bags inside this bag you do not know. * But you might know that you put a "wallet" somewhere there. * You ask the bag you hold: "find my wallet and give it to me". * get_item function will return you the item that is your "wallet". * You can then change something or just get information about the item you - * retrieved. But in most cases you do not the wallet itself. You want to get - * something from the wallet or put something into it. IMO money would be an - * obvious choice. To do this you use update_xxx_property functions. + * retrieved. But in most cases you do not need the wallet itself. You want to + * get something from the wallet or put something into it. IMO money would + * be an obvious choice. To do this you use update_xxx_property functions.<br> * There might be a bag somewhere deep and you might want to add something to * it. add_xxx_property_xxx functions allow you to specify sub collection you * want the item to be added to. If this sub collection argument is NULL top - * level collection is assumed. - * The search in the collections users a "x!y!z" notation to refer to an item (or + * level collection is assumed.<br> + * The search in the collections uses a "x!y!z" notation to refer to an item (or * property). You can search for "wallet" and it will find any first instance of * the "wallet" in your luggage. But you might have two wallets. One is yours and * another is your significant other's. So you might say find "my!wallet". - * It will find wallet in your bad (collection) named "my". This collection can + * It will find wallet in your bag (collection) named "my". This collection can * be many levels deep inside other collections. You do not need to know the * full path to get to it. But if you have the full path you can use the fill - * path like this "luggage!newbags!my!wallet". + * path like this "luggage!newbags!my!wallet".<br> * It is useful to be able to put bags into bags as well as get them out of each * other. When the collection is created the header keeps a reference count on * how many copies of the collection are known to the world. So one can put a - * collection into collection and give up its access to it (embed) of still hold + * collection into collection and give up its access to it (embed) or still hold * to the reference. By embedding the collection the caller effectively gives - * up its responsibility to destroy the collection after it is used. + * up its responsibility to destroy the collection after it is used.<br> * By extracting reference from an internal collection the caller gains access * to the collection directly and thus has responsibility to destroy it after * use. - * Characters with codes less than space in ASCII table are illegal for property - * names. - * Character '!' also illegal in property name and reserved for "x!y!z" notation. + * + * Internally collection is implemented as a link list rather than a hash + * table. + * This makes it suitable for small (dozens of items) sets of data for which + * the order is important. Thus the collection properties and sub collections + * can be used to model objects like a book case. Imagine a book case that + * consists of multiple shelves. You can perform operations like "add a new + * shelf after second shelf" or "put a book on the 4th shelf right before + * the book with the red cover." + * + * A bit of terminology: + * - <b>collection</b> - an object implemented as a link list that holds + * properties (attributes). + * - <b>property</b> - a named logical element of the collection. + * - <b>item</b> - physical element of the collection, think about it + * as a node in the link list. + * - <b>value</b> - data associated with the property. + * - <b>type</b> - type of the data associated with a property. + * - <b>length</b> - length of the data associated with the property. + * - <b>sub collection</b> - collection embedded into another collection. + * It is a property with the value of a special + * type. The name of the property that denotes + * a sub collection can be different from the name + * of the collection it refers to. + * - <b>traverse</b> - call a function that will internally iterate + * through a collection and do something with its + * elements. + * - <b>iterate</b> - step through a collection yourselves. + * + * Characters with codes less than space in ASCII table are illegal for + * property names. + * Character '!' also illegal in a property or collection name and + * reserved for "x!y!z" notation. + * + * There is always a header item in any collection that starts the collection. + * Most of the functions in the interface (unless explicitly stated otherwise) + * assume that the collection_item * argument points to the header element. + * Passing in elements extracted from the middle of a collection to functions + * that expect header elements is illegal. There might be not enough checking + * at the moment but this will be enforced in future versions of the library. + * + */ + +#ifndef EOK +#define EOK 0 +#endif + +/** + * @defgroup collection COLLECTION interface + * @{ + */ + +/** + * @brief Default class for a free form collection. + */ +#define COL_CLASS_DEFAULT 0 + +/** + * @brief Value indicates that property is not found. + * + * Used in search functions. + */ +#define COL_NOMATCH 0 +/** + * @brief Value indicates that property is found. + * + * Used in search functions. + */ +#define COL_MATCH 1 + + +/** + * @defgroup coltypes Type definition constants + * @{ + */ +/** + * @brief Indicates that property is of type "string". + * + * For elements of type string the length includes the trailing 0. + */ +#define COL_TYPE_STRING 0x00000001 +/** @brief Indicates that property is of type "binary". */ +#define COL_TYPE_BINARY 0x00000002 +/** @brief Indicates that property is of type "integer". */ +#define COL_TYPE_INTEGER 0x00000004 +/** @brief Indicates that property is of type "unsigned". */ +#define COL_TYPE_UNSIGNED 0x00000008 +/** @brief Indicates that property is of type "long". */ +#define COL_TYPE_LONG 0x00000010 +/** @brief Indicates that property is of type "unsigned long". */ +#define COL_TYPE_ULONG 0x00000020 +/** @brief Indicates that property is of type "double". */ +#define COL_TYPE_DOUBLE 0x00000040 +/** @brief Indicates that property is of Boolean type. */ +#define COL_TYPE_BOOL 0x00000080 +/** + * @brief Indicates that property is of type "collection". + * + * The item of this type denotes that starting element of a + * collection. + */ +#define COL_TYPE_COLLECTION 0x00000100 +/** + * @brief Indicates that property is of type "sub collection". + * + * An item of this type is a pointer to an existing external + * collection. + */ +#define COL_TYPE_COLLECTIONREF 0x00000200 +/** + * @brief Special type that denotes the end of the collection. + * + * Useful when traversing collections. + */ +#define COL_TYPE_END 0x10000000 +/** + * @brief Special type that denotes any property in the collection. + * + * Useful when traversing collection and searching for a property + * of unknown type but known name. + */ +#define COL_TYPE_ANY 0x0FFFFFFF +/** + * @} + */ + + +/** + * @defgroup addmodes Constants defining add modes + * + * The following constants define how one collection can be added to another. + * + * @{ + */ +/** @brief Add a collection into a collection as a reference */ +#define COL_ADD_MODE_REFERENCE 0 +/** + * @brief Embed the collection into another collection. + * + * The collection will become part of another collection. + * After this operation the handle to the collection being added + * should not be used or freed. + * Embedding a collection can be done only once. + * If the collection is referenced by another collection, + * the operation will fail. + */ +#define COL_ADD_MODE_EMBED 1 +/** + * @brief Perform a deep copy. + * + * Perform a deep copy of a collection with + * all its sub collections */ +#define COL_ADD_MODE_CLONE 2 +/** + * @brief Create a flattened copy. + * + * Create a deep copy of a collection with + * its sub collections flattening and NOT + * resolving duplicates. + */ +#define COL_ADD_MODE_FLAT 3 +/** + * @brief Create a flattened copy with constructed names. + * + * Creates a deep copy of a collection with + * its sub collections flattening and NOT + * resolving duplicates. Names are constructed + * in dotted notation. + * For example the sub collection + * named "sub" containing "foo" and + * "bar" will be flattened as: + * "sub.foo", "sub.bar". + */ +#define COL_ADD_MODE_FLATDOT 4 +/** + * @} + */ + + +/** + * @defgroup traverseconst Constants defining traverse modes + * + * The following constants define how a collection can be + * traversed or iterated. + * + * Flags defined below can generally be combined with each other. + * + * \ref COL_TRAVERSE_FLAT, \ref COL_TRAVERSE_SHOWSUB, + * \ref COL_TRAVERSE_ONLYSUB are mutually exclusive flags. + * If combined together results will be unpredictable.<br> + * <b>DO NOT MIX THEM IN ONE ITERATOR.</b> + * + * + * @{ + */ +/** @brief Traverse all items in the collection. */ +#define COL_TRAVERSE_DEFAULT 0x00000000 +/** + * @brief Traverse only the top level. + * + * Traverse only top level + * ignored if the IGNORE flag is + * specified + */ +#define COL_TRAVERSE_ONELEVEL 0x00000001 +/** + * @brief Insert end collection marker. + * + * Call the handler once more when the + * end of the collection is reached. + * Specifying this flag would cause a traversing + * function to call a callback once more passing + * in a virtual property of type \ref COL_TYPE_END. + * Good for processing nested collections. + */ +#define COL_TRAVERSE_END 0x00000002 +/** @brief Ignore sub collections as if none is present. */ +#define COL_TRAVERSE_IGNORE 0x00000004 +/** + * @brief Flatten the collection. + * + * Traversing this way would act as if + * all the properties of sub collection are properties + * of the root collection. The referencing properties or + * headers of the referenced collections are skipped. + * + * If we think of the book case example + * this is very useful when one wants to iterate through + * all the books skipping information about + * which shelf they are on. + */ +#define COL_TRAVERSE_FLAT 0x00000008 +/** + * @defgroup moreiterflag Additional iterator flags + * + * \note NOTE: These flags ignored by traverse functions and + * can be used only in the iterator. + * + * @{ + */ +/** + * @brief Include headers of sub collections. + * + * When one collection is embedded or referenced by another collection + * there are two names we can be interested in. The name of the property + * that defines the reference and the name of the embedded collection. + * It is recommended that they be the same, however there may be cases + * when the name of the referencing property and referenced collection + * should be different. By default only the name of the referencing + * property is returned while iterating through the collection and + * its sub collections. Specifying this flag would cause the names + * of the collection (header elements) be included into the iteration + * process. + * + * Flag is ignored if the \ref COL_TRAVERSE_ONELEVEL flag is + * specified and not ignored. + * Flag is ignored is also ignored if the FLAT flag is specified. */ +#define COL_TRAVERSE_SHOWSUB 0x00010000 +/** + * @brief Show sub collections. + * + * Show the header of the sub collection instead of the reference. + * Flag is ignored if the \ref COL_TRAVERSE_ONELEVEL flag is + * specified and not ignored. + * Flag is ignored is also ignored if the FLAT flag is specified. */ +#define COL_TRAVERSE_ONLYSUB 0x00020000 +/** + * @} + */ + +/** + * @} + */ + +/** + * @defgroup copyconst Constants defining copy modes + * + * The following constants define modes accepted by copy + * collection function(s). + * + * @{ + */ +/** + * @brief Perform a deep copy. + * + * Referenced collections of the donor are copied as sub + * collections. + */ +#define COL_COPY_NORMAL 0 +/** + * @brief Perform a deep flat copy. + * + * Collection is flattened. No name construction performed. + */ +#define COL_COPY_FLAT 1 +/** + * @brief Perform a deep flat copy constructing names. + * + * Collection is flattened. Names are concatenated with dot. + */ +#define COL_COPY_FLATDOT 2 +/** @brief Perform a deep copy but leave references as references. */ +#define COL_COPY_KEEPREF 3 +/** @brief Copy only top level collection. */ +#define COL_COPY_TOP 4 +/** + * @} + */ + +/** + * @defgroup sortconst Constants defining sort order + * + * All flags can be combined in OR operation. + * Flags \ref COL_SORT_ASC and \ref COL_SORT_DESC are + * mutually exclusive. If both specified the + * collection will be sorted in the descending order. + * + * @{ + */ +/** @brief Sort in ascending order. */ +#define COL_SORT_ASC 0x00000000 +/** @brief Sort in descending order. */ +#define COL_SORT_DESC 0x00000001 +/** @brief Sort all sub collections. */ +#define COL_SORT_SUB 0x00000002 +/** + * @brief Sort only embedded sub collections. + * + * Ignored if \ref COL_SORT_SUB is not specified. + */ +#define COL_SORT_MYSUB 0x00000004 +/** + * @} */ -/* Function that creates a named collection */ + +/* Public declaration of the private data */ +#ifndef COLLECTION_PRIV_H +/** + * @struct collection_item + * @brief Opaque structure that holds one property. + * + * Your implementation can assume that following members + * will always be members of the collection_item. + * but you should use get_item_xxx functions to get them + * and never access internal data directly. + * + * - char *property; + * - int property_len; + * - int type; + * - int length; + * - void *data; + */ +struct collection_item; +/** + * @struct collection_iterator + * @brief Opaque iterator structure. + * + * The iterator structure is used + * when one wants to traverse the collection + * going through its properties and optionally + * sub collections. + * + * Caller should never assume + * anything about internals of this structure. + */ +struct collection_iterator; + +#endif /* COLLECTION_PRIV_H */ + + +/** + * @brief Create a collection + * + * The function will create a collection. + * Each collection should have name and class. + * + * @param[out] ci Newly allocated collection object. + * @param[in] name The name is supposed to be a unique identifier of + * the collection. This is useful when the collections + * are stored within other collections or inside other + * aggregation objects. Caller is free to use any name. + * Name should consist of the ASCII characters with codes + * non less than space. Exclamation mark character is + * a special character and can't be used in name of + * collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] cclass Class is used to relate the collection to a specific + * group of the collections of the same structure. + * This is very useful when you try to represent + * objects using collections and you want to check if + * the objects have same structure or not. + * There is no predefined name space for the collection + * classes. Defining classes is left to the application + * developers.<br> + * <b>NOTE:</b> + * If you decide to build an interface using collection + * library pick a range for the classes you are + * going to use and make sure that they do not collide + * with other interfaces built on top of the collection. + * + * @return 0 - Collection was created successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the collection name. + * @return EMSGSIZE - Collection name is too long. + */ int col_create_collection(struct collection_item **ci, const char *name, unsigned cclass); -/* Function that destroys a collection */ +/** + * @brief Destroy a collection + * + * The function will destroy a collection. + * + * @param[in] ci Collection object. + * + */ void col_destroy_collection(struct collection_item *ci); -/* Family of functions that add properties to a collection */ -/* See details about subcollection argument above. */ -/* Family includes the following convinience functions: */ -/* Add a string property to collection. The length should include the - * terminating 0 */ +/** + * @brief Copy item callback. + * + * Callback is used by the + * \ref col_copy_collection_with_cb "col_copy_collection_with_cb" function. + * Function is called after the new item is created but not yet + * inserted into the target collection. + * The implementer of the callback can alter the item data + * or indicate to the caller that the item should be skipped. + * + * @param[in] item Newly allocated item that will be inserted + * into the new collection. + * @param[in] ext_data Data the application might want to + * pass to the callback. + * @param[out] skip Pointer to a variable that indicates if the + * item should be skipped or not. + * Set this variable to any nonzero value + * and the item will be skipped. + * @return 0 - Success + * @return Function can return any error code. This code + * will be propagated through the internal functions and + * returned to the application. + * + */ +typedef int (*col_copy_cb)(struct collection_item *item, + void *ext_data, + int *skip); + +/** + * @brief Copy collection with data modification. + * + * Function create a deep copy of the current collection. + * Calls caller provided callback before copying each item's data. + * This is useful if the data needs to be resolved in some way. + * The best use is when the template is copied and the values + * in the template are resolved to the actual values. + * The acceptable modes are defined \ref copyconst "here". + * + * @param[out] col_copy Newly created collection object. + * @param[in] col_to_copy Collection object that will be copied. + * @param[in] name_to_use Name of the new collection. + * @param[in] copy_mode How to \ref copyconst "copy". + * @param[in] copy_cb Pointer to a callback \ref col_copy_cb. + * Can be NULL. In this case data is copied + * without modification. + * @param[in] ext_data Data the application might want to + * pass to the callback. + * + * @return 0 - Collection was copied successfully. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * @return Any error code returned by the callback. + * + */ +int col_copy_collection_with_cb(struct collection_item **col_copy, + struct collection_item *col_to_copy, + const char *name_to_use, + int copy_mode, + col_copy_cb copy_cb, + void *ext_data); + +/** + * @brief Copy collection without data modification. + * + * Function creates a deep copy of the current collection. + * It wraps the \ref col_copy_collection_with_cb function. + * The acceptable modes are defined \ref copyconst "here". + * + * @param[out] col_copy Newly created collection object. + * @param[in] col_to_copy Collection object that will be copied. + * @param[in] name_to_use Name of the new collection. + * @param[in] copy_mode How to \ref copyconst "copy". + * + * @return 0 - Collection was copied successfully. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * + */ +int col_copy_collection(struct collection_item **col_copy, + struct collection_item *col_to_copy, + const char *name_to_use, + int copy_mode); + +/** + * @brief Add collection to collection. + * + * Function adds one collection into another + * depending upon a specified \ref addmodes "mode". + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add collection to. If NULL the collection + * is added to the root collection. + * @param[in] as_property Name of the property that will constitute + * the reference. If NULL the name of + * the collection being added will be used. + * If specified the restrictions to + * the name characters and length apply. + * For more details about the name related + * restrictions see + * \ref addproperty "col_add_xxx_property" + * functions. + * @param[in] ci_to_add Collection to add. + * @param[in] mode Specifies \ref addmodes "how" + * the collection should be added. + * + * @return 0 - Collection was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * The attempt to update a property which is + * a reference to a collection or a collection + * name. + * @return ENOENT - Property to update is not found. +*/ +int col_add_collection_to_collection(struct collection_item *ci, + const char *subcollection, + const char *as_property, + struct collection_item *ci_to_add, + int mode); +/** + * @brief Search Callback + * + * Signature of the callback that needs to be used when + * traversing a collection or looking for a specific item. + * + * @param[in] property The name of the property will + * be passed in this parameter. + * @param[in] property_len Length of the property name + * will be passed in this parameter. + * @param[in] type Type of the data will be passed + * in this parameter. + * @param[in] data Pointer to the data will be passed + * in this parameter. + * @param[in] length Length of data will be passed in + * this parameter. + * @param[in] custom_dat Custom data will be passed in + * this parameter. + * @param[out] stop Pointer to a variable where the handler + * can put nonzero to stop traversing + * of the collection. + * @return 0 - Success + * @return Function can return any error code. This code + * will be propagated through the internal functions and + * returned to the application. + */ +typedef int (*col_item_fn)(const char *property, + int property_len, + int type, + void *data, + int length, + void *custom_dat, + int *stop); + + +/** + * @brief Traverse collection + * + * Function to traverse the entire collection + * including (optionally) sub collections. + * + * @param[in] ci Collection object to traverse. + * @param[in] mode_flags How to traverse. + * See details \ref traverseconst "here". + * @param[in] item_handler Application supplied callback. + * It will be called for each item + * in the collection including headers. + * @param[in] custom_data Custom data that application + * might want to pass to the callback. + * + * @return 0 - Collection was traversed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * @return Any error code returned by the callback. + * + */ +int col_traverse_collection(struct collection_item *ci, + int mode_flags, + col_item_fn item_handler, + void *custom_data); + +/** + * @brief Search and do function. + * + * Looks up an item in the collection based on the property and type. + * Actually it is a traverse function with special traversing logic. + * It traverses the whole collection but calls the supplied + * callback only for the items that match the search criteria. + * It is the responsibility of the caller to define how the callback + * is going to indicate that the item it was looking for is found. + * Function will not return error if the item is not found. + * It is the responsibility of the calling application to check + * the data passed in custom_data and see if the item was found and + * that the action was performed. + * + * @param[in] ci Collection object to traverse. + * @param[in] property_to_find Name of the property to find. + * Parameter supports "x!y" + * notation. + * @param[in] type Type filter. Only properties + * of the given type will match. + * Can be 0 to indicate that all + * types should be evaluated. + * @param[in] mode_flags How to traverse the collection. + * See details \ref traverseconst "here". + * @param[in] item_handler Function to call when the item is found. + * @param[in] custom_data Custom data passed to the callback. + * + * @return 0 - Operation completed successfully. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOENT - The search criteria is incorrect. + * @return ENOMEM - No memory. + * @return Any error code returned by the callback. + * + */ +int col_get_item_and_do(struct collection_item *ci, + const char *property_to_find, + int type, + int mode_flags, + col_item_fn item_handler, + void *custom_data); + +/** + * @brief Search function to get an item. + * + * Convenience function to get individual item. + * Caller should be aware that this is not a copy of the item + * but the pointer to actual item stored in the collection. + * The returned pointer should never be altered or freed by caller of the function. + * The caller should be sure that the collection does not go out of scope + * while the pointer to its data is in use. + * Working with the internals of the collection item structure directly + * may cause problems in future if the internal implementation changes. + * The caller needs to be aware that function does not return + * error if item is not found. The caller needs to check if + * item is not NULL to determine whether something was found. + * Internally function is a wrapper around the \ref col_get_item_and_do + * function. + * + * Use \ref getitem "item management" functions to work with the item. + * + * @param[in] ci Collection object to traverse. + * @param[in] property_to_find Name of the property to find. + * Parameter supports "x!y" + * notation. + * @param[in] type Type filter. Only properties + * of the given type will match. + * Can be 0 to indicate that all + * types should be evaluated. + * @param[in] mode_flags How to traverse the collection. + * See details \ref traverseconst "here". + * @param[in] item Pointer to found item or NULL + * if item is not found. + * + * @return 0 - No internal errors during search. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOENT - The search criteria is incorrect. + * @return ENOMEM - No memory. + * + */ +int col_get_item(struct collection_item *ci, + const char *property_to_find, + int type, + int mode_flags, + struct collection_item **item); + +/** + * @brief Sort collection. + * + * If the sub collections are included in sorting + * each collection is sorted separately (this is not a global sort). + * It might be dangerous to sort sub collections if + * sub collection is not owned by the current collection. + * If it is a reference to an external collection + * there might be an issue. To skip the collections that + * externally referenced use \ref COL_SORT_MYSUB flag. + * Keep in mind that if a collection is referenced + * more than once by other collection and that collection + * is sorted with sub collections the referenced + * collection will be sorted more than once. + * + * NOTE: Current implementation of the sorting + * function is very simple and alternative + * implementations might be provided later. + * + * @param[in] col Collection to sort. + * @param[in] cmp_flags For more information see + * \ref compflags "comparison flags". + * @param[in] sort_flags For more information see + * \ref sortconst "sort flags". + * + * @return 0 - No internal errors during sorting. + * @return EINVAL - The value of some of the arguments is invalid. + * + */ +int col_sort_collection(struct collection_item *col, + unsigned cmp_flags, + unsigned sort_flags); + +/** + * @brief Delete property. + * + * Delete property from the collection. + * It is recommended to use a more efficient function + * \ref col_remove_item for the same purpose if + * the property is unique or if the collection + * has a known structure. + * The col_delete_property function has some advantage only + * if it is not known where property + * resides and what is the structure of the collection. + * In this case "foo!bar!baz" notation can be used in + * the property_to_find argument to find and delete + * the property "baz" that is in a sub collection "bar" + * which is in turn a part of a collection "foo". + * + * @param[in] ci Collection to delete property from. + * @param[in] property_to_find Property to delete. + * @param[in] type Use type if names are not unique + * and you know the type of the value + * you want to delete. Otherwise set to 0. + * @param[in] mode_flags The flags define how the collection + * should be searched. For more information + * see \ref traverseconst "traverse constants". + * + * @return 0 - Property was deleted successfully. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOMEM - No memory. + * @return ENOENT - Property not found. + * + */ +int col_delete_property(struct collection_item *ci, + const char *property_to_find, + int type, + int mode_flags); + +/** + * @brief Is property in the collection? + * + * Convenience function to check if the property + * is indeed in the collection. + * + * @param[in] ci Collection to search. + * @param[in] property_to_find Property to find. + * @param[in] type Use type if names are not unique + * and you know the type of the value + * you want to check. Otherwise set to 0. + * @param[in] mode_flags The flags define how the collection + * should be searched. For more information + * see \ref traverseconst "traverse constants". + * @param[out] found The variable that will receive the result + * of the search. + * COL_NOMATCH - if not found + * COL_MATCH if found + * + * @return 0 - Search completed successfully. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOMEM - No memory. + * + */ +int col_is_item_in_collection(struct collection_item *ci, + const char *property_to_find, + int type, + int mode_flags, + int *found); + +/** + * @brief Get a reference to a collection + * + * Get a pointer to a collection included into another collection. + * If the col_to_find is NULL function returns a reference + * to the top level collection. + * Delete extracted collection after use to decrease reference count. + * + * @param[in] ci Collection to search. + * @param[out] acceptor Variable that accepts pointer to + * an extracted collection. + * Use \ref col_destroy_collection to + * free returned object reference after + * use. + * @param[in] col_to_find Collection to find. + * "foo!bar!baz" notation can be used. + * + * @return 0 - Success. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOMEM - No memory. + */ +int col_get_collection_reference(struct collection_item *ci, + struct collection_item **acceptor, + const char *col_to_find); + +/** + * @brief Get a reference from the item + * + * Get a pointer to a collection from a current item + * if current item is a reference to the collection. + * If current item is not a reference to a collection an error + * will be returned. + * Delete extracted collection after use to decrease reference count. + * + * @param[in] item Item to extract the reference from. + * @param[out] acceptor Variable that accepts pointer to + * an extracted collection. + * Use \ref col_destroy_collection to + * free returned object reference after + * use. + * + * @return 0 - Success. + * @return EINVAL - The value of some of the arguments is invalid. + */ +int col_get_reference_from_item(struct collection_item *item, + struct collection_item **acceptor); + + + +/** + * @brief Get collection class. + * + * The classes of the collections can be used to convey information + * about the collection's internal structure. + * Some interfaces built on top of the collection might + * impose restrictions on the collection structure. + * For example the interface can decide that it is going + * to deal with the collections that do not have sub collections + * and elements of the collections are always only strings. + * So the interface will define a class of the collection + * and create a function that would take the strings and create + * such a collection. Then other functions of that interface + * would check if the provided collection is of the specified class. + * If not the interface would reject the collection right away. + * If the collection is of the valid class the interface might + * call the validation function to make sure that this is really + * the case however it needs to validate it only once and lower level + * functions can rely on the class value of the collection + * without performing duplicate validation. + * + * @param[in] ci Collection object. + * @param[out] cclass Variable that will receive + * the value of the class. + * @return 0 - Success. + * @return EINVAL - The value of some of the arguments is invalid. + * + */ +int col_get_collection_class(struct collection_item *ci, + unsigned *cclass); + +/** + * @brief Set collection class. + * + * Sometimes as a result of the collection modification + * the class of the collection can change. + * + * @param[in] ci Collection object. + * @param[in] cclass New class value. + * + * @return 0 - Success. + * @return EINVAL - The value of some of the arguments is invalid. + * + */ +int col_set_collection_class(struct collection_item *ci, + unsigned cclass); + +/** + * @brief Get count of the elements. + * + * It is useful to know how many items are there in the collection. + * + * @param[in] ci Collection object. + * @param[out] count Variable will receive the value + * of the number of the items in + * the collection. Collection + * header or references to external + * collections are counted as well. + * This means that every collection + * has at least one item - the header. + * + * @return 0 - Success. + * @return EINVAL - The value of some of the arguments is invalid. + * + */ +int col_get_collection_count(struct collection_item *ci, + unsigned *count); + + +/** + * @brief Check the class of collection. + * + * Convenience function to check if the collection is of the specific class. + * In case of internal error assumes that collection is not of the right class. + * + * @param[in] ci Collection object. + * @param[in] cclass Class value to compare to to. + * + * @return 0 - If any internal error or classes do not match. + * @return 1 - No error and classes do match. + * + */ +int col_is_of_class(struct collection_item *ci, + unsigned cclass); + + +/** + * @defgroup addproperty Add property functions + * + * Functions in this section add properties to a collection. + * + * All the functions in this section add a property of the specified + * type to the collection object. + * They are convenience wrappers around the col_insert_xxx_property + * functions. + * They always append property to the end of the collection. + * + * Common parameters for these functions are: + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + * @{ + */ + +/** + * @brief Add a string property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] string Null terminated string to add. + * @param[in] length Length of the string. Should include the length + * of the terminating 0. + * If the length is shorter than the full string + * the string will be truncated. If the length is + * longer than the actual string there might be + * garbage at end of the actual string. + * Library will always properly NULL terminate + * the string at the given position dictated + * by length but in no way will inspect the validity + * of the passed in data. This is left to the calling + * application. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_str_property(struct collection_item *ci, const char *subcollection, const char *property, const char *string, int length); -/* Add a binary property to collection. */ + +/** + * @brief Add a binary property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] binary_data Data to add. + * @param[in] length Length of the data. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_binary_property(struct collection_item *ci, const char *subcollection, const char *property, void *binary_data, int length); -/* Add an int property to collection. */ + +/** + * @brief Add an integer property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Integer value to add. Value is signed. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_int_property(struct collection_item *ci, const char *subcollection, const char *property, int number); -/* Add an unsigned int property. */ + +/** + * @brief Add an unsigned integer property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Unsigned integer value to add. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_unsigned_property(struct collection_item *ci, const char *subcollection, const char *property, unsigned int number); -/* Add a long property. */ + +/** + * @brief Add an long property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Long integer value to add. Value is signed. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_long_property(struct collection_item *ci, const char *subcollection, const char *property, long number); -/* Add an unsigned long property. */ + +/** + * @brief Add an unsigned long property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Unsigned long integer value to add. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_ulong_property(struct collection_item *ci, const char *subcollection, const char *property, unsigned long number); -/* Add a double property. */ + +/** + * @brief Add a property of type double to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Floating point value. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_double_property(struct collection_item *ci, const char *subcollection, const char *property, double number); -/* Add a bool property. */ +/** + * @brief Add a Boolean property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] logical Boolean value. 0 - false, nonzero - true. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_bool_property(struct collection_item *ci, const char *subcollection, const char *property, unsigned char logical); -/* Add any property */ -int col_add_any_property(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Subcollection */ - const char *property, /* Name */ - int type, /* Data type */ - void *data, /* Pointer to the data */ - int length); /* Length of the data. For - * strings it includes the - * trailing 0 */ - -/* The functions that add an item and immediately return you this item - * in the ret_ref parameter */ + +/** + * @brief Add a property of a specified type to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] type See type definitions \ref coltypes "here". + * @param[in] data Data to add. + * @param[in] length Length of the data. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ +int col_add_any_property(struct collection_item *ci, + const char *subcollection, + const char *property, + int type, + void *data, + int length); + +/** + * @defgroup addprop_withref Add properties with reference + * + * Family of functions that add properties to a collection + * and return reference to an item that holds + * a newly created property. + * + * All the functions in this section append a property of + * the specified type to the collection object. + * + * Parameters for the functions and return values are the same + * as for the \ref addproperty "col_add_xxx_property" functions. + * The only difference is that these functions have one additional + * argument: + * + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @{ + */ + +/** + * @brief Add a string property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] string Null terminated string to add. + * @param[in] length Length of the string. Should include the length + * of the terminating 0. + * If the length is shorter than the full string + * the string will be truncated. If the length is + * longer than the actual string there might be + * garbage at end of the actual string. + * Library will always properly NULL terminate + * the string at the given position dictated + * by length but in no way will inspect the validity + * of the passed in data. This is left to the calling + * application. + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_str_property_with_ref(struct collection_item *ci, const char *subcollection, const char *property, char *string, int length, struct collection_item **ret_ref); + +/** + * @brief Add a binary property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] binary_data Data to add. + * @param[in] length Length of the data. + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_binary_property_with_ref(struct collection_item *ci, const char *subcollection, const char *property, void *binary_data, int length, struct collection_item **ret_ref); + +/** + * @brief Add an integer property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Integer value to add. Value is signed. + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_int_property_with_ref(struct collection_item *ci, const char *subcollection, const char *property, int number, struct collection_item **ret_ref); + +/** + * @brief Add an unsigned integer property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Unsigned integer value to add. + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_unsigned_property_with_ref(struct collection_item *ci, const char *subcollection, const char *property, unsigned int number, struct collection_item **ret_ref); + +/** + * @brief Add an long property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Long integer value to add. Value is signed. + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_long_property_with_ref(struct collection_item *ci, const char *subcollection, const char *property, long number, struct collection_item **ret_ref); + +/** + * @brief Add an unsigned long property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Unsigned long integer value to add. + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_ulong_property_with_ref(struct collection_item *ci, const char *subcollection, const char *property, unsigned long number, struct collection_item **ret_ref); + +/** + * @brief Add a property of type double to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Floating point value. + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_double_property_with_ref(struct collection_item *ci, const char *subcollection, const char *property, double number, struct collection_item **ret_ref); + +/** + * @brief Add a Boolean property to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] logical Boolean value. 0 - false, nonzero - true. + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_bool_property_with_ref(struct collection_item *ci, const char *subcollection, const char *property, unsigned char logical, struct collection_item **ret_ref); + + +/** + * @brief Add a property of a specified type to a collection. + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] type See type definitions \ref coltypes "here". + * @param[in] data Data to add. + * @param[in] length Length of the data. + * @param[out] ret_ref Reference to the newly added item that + * holds the property. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection is not found. + * + */ int col_add_any_property_with_ref(struct collection_item *ci, const char *subcollection, const char *property, int type, void *data, int length, struct collection_item **ret_ref); -/* Update functions */ -/* All update functions search the property using the search algorithm - * described at the top of the header file. +/** + * @} + */ + +/** + * @} + */ + +/** + * @defgroup insertproperty Insert property functions + * + * Functions in this section insert properties into a collection + * at a specified position. + * + * Common parameters for these functions are: + * + * @param[in] ci Root collection object. + * @param[in] subcollection Name of the inner collection to + * add property to. If NULL the property + * is added to the root collection. + * @param[in] disposition Defines relation point. + * For more information see + * \ref dispvalues "disposition defines". + * @param[in] refprop Property to relate to + * @param[in] idx Index (see comments below). + * @param[in] flags Flags that control naming issues. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * + * + * Other arguments are the same as the arguments for the + * \ref addproperty "col_add_xxx_property" functions. + * + * @return 0 - Property was insterted successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * @return ENOENT - Sub collection or property to relate to is not found. + * @return EEXIST - Property with given name already exists. + * This error is returned if collection + * should hold unique names. + * For more information see description of the + * "flags" argument. + * @return ENOSYS - Flag or disposition value is not implemented. + * @{ + */ +/** @brief Insert a string property. */ +int col_insert_str_property(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + const char *string, + int length); + +/** @brief Insert a binary property. */ +int col_insert_binary_property(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + void *binary_data, + int length); + +/** @brief Insert an integer property. */ +int col_insert_int_property(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + int number); + +/** @brief Insert an unsigned property. */ +int col_insert_unsinged_property(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + unsigned number); + +/** @brief Insert a long property. */ +int col_insert_long_property(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + long number); + +/** @brief Insert an unsigned long property. */ +int col_insert_ulong_property(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + unsigned long number); + +/** @brief Insert a property with a floating point value. */ +int col_insert_double_property(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + double number); + +/** @brief Insert a property with a Boolean value. */ +int col_insert_bool_property(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + unsigned char logical); + +/** @brief Insert a string property and get back a reference. */ +int col_insert_str_property_with_ref(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + const char *string, + int length, + struct collection_item **ret_ref); + +/** @brief Insert a binary property and get back a reference. */ +int col_insert_binary_property_with_ref(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + void *binary_data, + int length, + struct collection_item **ret_ref); + +/** @brief Insert an integer property and get back a reference. */ +int col_insert_int_property_with_ref(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + int number, + struct collection_item **ret_ref); + +/** @brief Insert an unsigned property and get back a reference. */ +int col_insert_unsinged_property_with_ref(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + unsigned number, + struct collection_item **ret_ref); + +/** @brief Insert a long property and get back a reference. */ +int col_insert_long_property_with_ref(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + long number, + struct collection_item **ret_ref); + +/** @brief Insert an unsigned long property and get back a reference. */ +int col_insert_ulong_property_with_ref(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + unsigned long number, + struct collection_item **ret_ref); + +/** + * @brief Insert a property with a floating + * point value and get back a reference. + */ +int col_insert_double_property_with_ref(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + double number, + struct collection_item **ret_ref); + +/** @brief Insert a property with a Boolean value and get back a reference. */ +int col_insert_bool_property_with_ref(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + unsigned char logical, + struct collection_item **ret_ref); + +/** @brief Insert property of any type and get back a reference. */ +int col_insert_property_with_ref(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + unsigned flags, + const char *property, + int type, + const void *data, + int length, + struct collection_item **ret_ref); + + +/** + * @} + */ + +/** + * @defgroup updateproperty Update property functions + * + * Functions in this section update properties in a collection. + * + * All update functions search the property using the + * internal traverse function. * Use same "x!y" notation to specify a property. + * For more details about the search logic see + * \ref col_get_item_and_do function. + * + * The existing value of the property is destroyed and lost. + * + * It is not possible to rename the property using these functions. + * To do more advanced modifications see \ref col_modify_item function + * and \ref modwrap "item modification wrappers" . + * + * Common parameters for these functions are: + * + * @param[in] ci Root collection object. + * @param[in] property Name of the property. + * @param[in] mode_flags Specify how the collection + * should to be traversed. + * + * The rest of the arguments specify the new values for + * the property. For more details about these arguments see + * the description of the \ref addproperty "col_add_xxx_property" + * corresponding function. + * + * + * @return 0 - Property was updated successfully. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * The attempt to update a property which is + * a reference to a collection or a collection + * name. + * @return ENOENT - Property to update is not found. + * + * @{ + */ +/** + * Update a property with a string value. + * Length should include the terminating 0. */ -/* Update a string property in the collection. - * Length should include the terminating 0 */ int col_update_str_property(struct collection_item *ci, const char *property, int mode_flags, char *string, int length); -/* Update a binary property in the collection. */ +/** + * Update a property with a binary value. + */ int col_update_binary_property(struct collection_item *ci, const char *property, int mode_flags, void *binary_data, int length); -/* Update an int property in the collection. */ +/** + * Update a property with an integer value. + */ int col_update_int_property(struct collection_item *ci, const char *property, int mode_flags, int number); -/* Update an unsigned int property. */ +/** + * Update a property with an unsigned value. + */ int col_update_unsigned_property(struct collection_item *ci, const char *property, int mode_flags, unsigned int number); -/* Update a long property. */ +/** + * Update a property with a long value. + */ int col_update_long_property(struct collection_item *ci, const char *property, int mode_flags, long number); -/* Update an unsigned long property. */ +/** + * Update a property with an unsigned long value. + */ int col_update_ulong_property(struct collection_item *ci, const char *property, int mode_flags, unsigned long number); -/* Update a double property. */ +/** + * Update a property with a floating point value. + */ int col_update_double_property(struct collection_item *ci, const char *property, int mode_flags, double number); -/* Update a double property. */ +/** + * Update a property with a Boolean value. + */ int col_update_bool_property(struct collection_item *ci, const char *property, int mode_flags, unsigned char logical); -/* Update property in the collection */ -int col_update_property(struct collection_item *ci, /* A collection of items */ - const char *property_to_find, /* Name to match */ - int type, /* Data type */ - void *new_data, /* Pointer to the data */ - int length, /* Length of the data. For - * strings, it includes the - * trailing 0 */ - int mode_flags); /* How to traverse the collection */ - - -/* Add collection to collection */ -int col_add_collection_to_collection(struct collection_item *ci, /* Collection handle to with we add - * another collection */ - const char *sub_collection_name, /* Name of the sub collection - * to which collection needs to be - * added as a property. - * If NULL high level collection is assumed. */ - const char *as_property, /* Name of the collection property. - * If NULL, same property as the name of - * the collection being added will be used. */ - struct collection_item *collection_to_add, /* Collection to add */ - int mode); /* How this collection needs to be added */ - -/* Create a deep copy of the current collection. - * Wraps the function below. - * The acceptable modes are defined at the top. - */ -int col_copy_collection(struct collection_item **collection_copy, - struct collection_item *collection_to_copy, - const char *name_to_use, - int copy_mode); - -/* Callback used in the next function */ -typedef int (*col_copy_cb)(struct collection_item *item, - void *ext_data, - int *skip); - -/* Create a deep copy of the current collection. - * Calls caller provided callback before - * copying each item's data. - * The acceptable modes are defined at the top. +/** + * Update a property with a value by specifying type + * and value. See definitions of the type constants + * \ref coltypes "here". + * All other col_update_xxx_property functions are wrappers + * around this one. */ -int col_copy_collection_with_cb(struct collection_item **collection_copy, - struct collection_item *collection_to_copy, - const char *name_to_use, - int copy_mode, - col_copy_cb copy_cb, - void *ext_data); - -/* Signature of the callback that needs to be used when - traversing a collection or looking for a specific item */ -typedef int (*col_item_fn)(const char *property, /* The name of the property will be passed in this parameter. */ - int property_len, /* Length of the property name will be passed in this parameter. */ - int type, /* Type of the data will be passed in this parameter */ - void *data, /* Pointer to the data will be passed in this parameter */ - int length, /* Length of data will be passed in this parameter */ - void *custom_dat, /* Custom data will be passed in this parameter */ - int *stop); /* Pointer to variable where the handler can put non zero to stop processing */ - -/* Function to traverse the entire collection including optionally sub collections */ -int col_traverse_collection(struct collection_item *ci, /* Collection to traverse */ - int mode_flags, /* Flags defining how to traverse */ - col_item_fn item_handler, /* Handler called for each item */ - void *custom_data); /* Custom data passed around */ - -/* Search function. Looks up an item in the collection based on the property. - * Actually it is a traverse function with special traversing logic. - * It is the responsibility of the handler to set something in the custom data - * to indicate that the item was found. - * Function will not return error if the item is not found. - * It is the responsibility of the calling application to check - * the data passed in custom_data and see if the item was found and - * that the action was performed. - */ -int col_get_item_and_do(struct collection_item *ci, /* A collection of items */ - const char *property_to_find,/* Name to match */ - int type, /* Type filter */ - int mode_flags, /* How to traverse the collection */ - col_item_fn item_handler, /* Function to call when the item is found */ - void *custom_data); /* Custom data passed around */ - -/* Convenience function to get individual item */ -/* Caller should be aware that this is not a copy of the item - * but the pointer to actual item stored in the collection. - * The returned pointer should never be altered or freed by caller of the function. - * The caller should be sure that the collection does not go out of scope - * while the pointer to its data is in use. - * Working with the internals of the collection item structure directly - * may cause problems in future if the internal implementation changes. - * The caller needs to be aware that function does not return - * error if item is not found. The caller needs to check if - * item is not NULL to determine whether something was found. - */ -int col_get_item(struct collection_item *ci, /* Collection to find things in */ - const char *property_to_find, /* Name to match */ - int type, /* Type filter */ - int mode_flags, /* How to traverse the collection */ - struct collection_item **item); /* Found item */ +int col_update_property(struct collection_item *ci, + const char *property, + int type, + void *new_data, + int length, + int mode_flags); -/* Group of functions that allows retrieving individual elements of the collection_item - * hiding the internal implementation. - */ -const char *col_get_item_property(struct collection_item *ci, int *property_len); -int col_get_item_type(struct collection_item *ci); -int col_get_item_length(struct collection_item *ci); -void *col_get_item_data(struct collection_item *ci); -uint64_t col_get_item_hash(struct collection_item *ci); -/* Calculates hash of the string using internal hashing - * algorithm. Populates "length" with length - * of the string not counting 0. - * Length argument can be NULL. - * If sub_len is greater than zero - * this value is used to count how many characters - * from string should be included into hash - * calculation. +/** + * @} */ -uint64_t col_make_hash(const char *string, int sub_len, int *length); -/* Compare two items. - * The second item is evaluated against the first. - * Function returns 0 if two items are the same - * and non-zero otherwise. - * The in_flags is a bit mask that defines - * how the items should be compared. - * See below the list of conbstants - * defined for this purpose. - * If items are different they might be orderable - * or not. For example one can order items by name - * but not by type. - * If the result of the function is non-zero - * the out_flags (if provided) will be - * set to indicate if the second item is greater - * then the first. +/** + * @defgroup getitem Item management + * + * Group of functions that allows retrieving individual elements + * of the \ref collection_item hiding the internal implementation. + * + * @{ */ -int col_compare_items(struct collection_item *first, - struct collection_item *second, - unsigned in_flags, - unsigned *out_flags); -/********* Possible valies for input flags ********/ -/* How to compare properties? - * The following 4 flags are mutually exclusive +/** + * @defgroup compflags Comparison flags + * + * This section describes the flags used in item comparison. + * + * Flags: + * - \ref COL_CMPIN_PROP_EQU + * - \ref COL_CMPIN_PROP_BEG + * - \ref COL_CMPIN_PROP_MID + * - \ref COL_CMPIN_PROP_END + * + * are mutually exclusive. + * + * All other flags can be provided in any combination. + * + * @{ */ -#define COL_CMPIN_PROP_EQU 0x000000004 /* Properties should be same */ -#define COL_CMPIN_PROP_BEG 0x000000005 /* Properties start same */ -#define COL_CMPIN_PROP_MID 0x000000006 /* One is substring of another */ -#define COL_CMPIN_PROP_END 0x000000007 /* One property ends with another */ - -/* Make sure that there is a dot. +/** @brief Properties should be exactly equal */ +#define COL_CMPIN_PROP_EQU 0x000000004 +/** @brief Properties should start with the same substring. */ +#define COL_CMPIN_PROP_BEG 0x000000005 +/** @brief One property should be a substring of another. */ +#define COL_CMPIN_PROP_MID 0x000000006 +/** @brief Properties should have the same substring at the end. */ +#define COL_CMPIN_PROP_END 0x000000007 + +/** + * @brief Make sure that there is a dot. + * * Useful with _BEG, _MID and _END flags to check that the there is * a dot (if present) in the right place (before, after or both). * For example the first item is named "foo.bar" and the second @@ -527,77 +2046,452 @@ int col_compare_items(struct collection_item *first, */ #define COL_CMPIN_PROP_DOT 0x000000008 -/* Compare property lenghts */ +/** @brief Compare property lengths. */ #define COL_CMPIN_PROP_LEN 0x000000010 -/* Compare types */ +/** @brief Compare types. */ #define COL_CMPIN_TYPE 0x000000020 -/* Compare data len */ +/** @brief Compare data lengths. */ #define COL_CMPIN_DATA_LEN 0x000000040 -/* Compare data (up to the length of the second one) +/** + * @brief Compare data. + * + * Compares data (up to the length of the second one) * if type is the same. If type is different * function will assume data is different * without performing actual comparison. */ #define COL_CMPIN_DATA 0x000000080 -/********* Possible values for output flags *********/ -/* If _EQU was specified and the property of the second item +/** + * @} + */ + + +/** + * @defgroup outflags Comparison results flags + * + * This section describes the flags set as a result of + * a comparison operation. + * + * @{ + */ + +/** + * @brief Second item's property is greater. + * + * If _EQU was specified and the property of the second item * is greater the following bit will be set */ #define COL_CMPOUT_PROP_STR 0x00000001 -/* If we were told to compare property lengths - * and second is longer this bit will be set + +/** + * @brief Second item's property is longer. + * + * If told to compare property lengths + * and the second is longer this bit will be set. */ #define COL_CMPOUT_PROP_LEN 0x00000002 -/* If we were told to compare data lengths +/** + * @brief Second item's data is longer. + * + * If told to compare data lengths * and second is longer this bit will be set */ #define COL_CMPOUT_DATA_LEN 0x00000004 -/* If we were told to compare data - * and types are the same then +/** + * @brief Second item's data is greater. + * + * If told to compare data + * and types are the same, then * if the second one is greater this bit will - * be set. If data is binary flag is never set + * be set. If data is binary flag is never set. */ #define COL_CMPOUT_DATA 0x00000008 +/** + * @} + */ -/* Sort collection. - * cmp_flags are the same as in_flags for the compare - * function. The sort_flags is an OR of the costants - * defined below. - * If the subcollections are included in sorting - * each collection is sorted separately (this is not a global sort). - * It might be dangerous to sort subcollections if - * subcollection is not owned by current collection. - * If it is a reference to an external collection - * there might be an issue. To skip the collections that - * externally referenced use MYSUB flag. - * Keep in mind that if the collection - * has two references to the same other - * collection it is impossible to detect - * this situation. If MYSUB is used in this - * case such collection will be ignored - * If MYSUB is not used the collection - * will be sorted more than once. +/** + * @defgroup dispvalues Disposition constants + * + * Possible dispositions for insert, extract and delete function(s). + * Not all of these dispositions are implemented day one. + * If disposition is not implemented the function + * will return error ENOSYS. + * + * Other dispositions might be possible in future. + * + * @{ + */ +/** + * @brief Relate to the end of the collection + * + * For "insert": + * - Add property to the end of the collection. + * + * For "extract" or "delete": + * - Extract or delete the last property in the collection. + */ +#define COL_DSP_END 0 +/** + * @brief Relate to the beginning of the collection + * + * For "insert": + * - Add property to the beginning of the collection right after the header. + * + * For "extract" or "delete": + * - Extract or delete the first property in the collection. + * This is the one right after the header. + */ +#define COL_DSP_FRONT 1 +/** + * @brief Before the given property + * + * For "insert": + * - Add property before the referenced property. + * + * For "extract" or "delete": + * - Extract or delete the property that stands + * before the referenced property in the collection. + * If given property is the first in the collection + * ENOENT is returned. + */ +#define COL_DSP_BEFORE 2 +/** + * @brief After the given property + * + * For "insert": + * - Add property immediately the referenced property. + * + * For "extract" or "delete": + * - Extract or delete the property that stands + * after the referenced property in the collection. + * If given property is the last in the collection + * ENOENT is returned. + */ +#define COL_DSP_AFTER 3 +/** + * @brief Use index + * + * For "insert": + * - The COL_DSP_INDEX adds the item as N-th item after header in the list. + * Index is zero based. + * If there are less than N items in the list the item is added to the end. + * The index value of 0 means that the item will be added immediately + * after the header. Index of 1 will mean that it is added after first data + * item and so on. + * + * For "extract" or "delete": + * - In case of extraction or deletion the N-th item of the collection + * will be extracted or deleted. + * Index is zero based. + * If there are less than N+1 items in the list the function will return ENOENT. + * + */ +#define COL_DSP_INDEX 4 +/** + * @brief Use first among duplicates + * + * This mode applies only to the list of duplicate + * properties that are going one after another. + * + * For "insert": + * - Add property as a first dup of the given property. + * The property name is taken from the item + * and the value refprop is ignored. + * + * For "extract" or "delete": + * - Delete or extract first duplicate property. + * The property name is taken from the refprop. + * The property will be extracted or deleted if found + * regardless of whether there are any duplicates or not. + */ +#define COL_DSP_FIRSTDUP 5 +/** + * @brief Use last among duplicates + * + * This mode applies only to the list of duplicate + * properties that are going one after another. + * + * For "insert": + * - Add property as the last dup of the given property. + * The property name is taken from the item + * and the value refprop is ignored. + * + * For "extract" or "delete": + * - Delete or extract the last duplicate of the property. + * The property name is taken from the refprop. + * Extracts or deletes last duplicate property in the uninterrupted + * sequence of properties with the same name. + * The property will be extracted or deleted if found + * regardless of whether there are any duplicates or not. + */ +#define COL_DSP_LASTDUP 6 +/** + * @brief Use N-th among duplicates + * + * This mode applies only to the list of duplicate + * properties that are going one after another. + * + * For "insert": + * - Add property as a N-th dup of the given property. + * The property name is taken from the item + * and the value refprop is ignored. + * Index is zero based. + * The COL_DSP_NDUP is used in case of the multi value property + * to add a new property with the same name into specific place + * in the list of properties with the same name. + * The index of 0 will mean to add the property before the first + * instance of the property with the same name. + * If the property does not exist ENOENT will be returned. + * If the index is greater than the last property with the same + * name the item will be added immediately after last + * property with the same name. + * + * For "extract" or "delete": + * - Delete or extract N-th duplicate property. + * Index is zero based. + * The property name is taken from the refprop. + * If index is greater than number of duplicate + * properties in the sequence ENOENT is returned. + * + */ +#define COL_DSP_NDUP 7 +/** + * @} */ -int col_sort_collection(struct collection_item *col, - unsigned cmp_flags, - unsigned sort_flags); -/* Sort flags */ -#define COL_SORT_ASC 0x00000000 -#define COL_SORT_DESC 0x00000001 -#define COL_SORT_SUB 0x00000002 -#define COL_SORT_MYSUB 0x00000004 +/** + * @defgroup insflags Flags used in insert item functions + * + * Flags that can be used with insert functions. + * + * In future can more flags might be added. + * + * <b>NOTE:</b> Use of the duplicate checking flags is costly + * since it requires a forward look up of the whole + * collection before the item is inserted. + * Do not use it until it is absolutely necessary. + * + * @{ + */ +/** @brief This is the default mode - no dup checks on insert */ +#define COL_INSERT_NOCHECK 0 +/** + * @brief Check for duplicate name and overwrite. + * Position arguments are ignored. + */ +#define COL_INSERT_DUPOVER 1 +/** + * @brief Check for duplicate name and type and overwrite. + * Position arguments are ignored. + */ +#define COL_INSERT_DUPOVERT 2 +/** @brief Return error EEXIST if the entry with the same name exists. */ +#define COL_INSERT_DUPERROR 3 +/** + * @brief Return error EEXIST if the entry + * with the same name and type exists. + */ +#define COL_INSERT_DUPERRORT 4 +/** @brief Check for duplicates, overwrite, + * extract and then move to the position requested. + */ +#define COL_INSERT_DUPMOVE 5 +/** @brief Check for duplicate name and type, overwrite, + * extract and then move to the position requested. + */ +#define COL_INSERT_DUPMOVET 6 + +/** + * @} + */ + + + +/** + * @brief Get item property. + * + * Get name of the property from the item. If the item is a header + * the name of the property is the name of the collection. + * The element that denotes the collection header has + * type \ref COL_TYPE_COLLECTION. + * Optionally the property length can be retrieved too. + * + * @param[in] ci Item to get property from. + * If item is invalid the function + * will cause a segment violation. + * @param[out] property_len If not NULL the variable + * will receive the length + * of the property not counting + * terminating 0. + * + * @return Property name. + * + */ +const char *col_get_item_property(struct collection_item *ci, + int *property_len); -/* If you want to modify the item that you got as a result of iterating through collection - * or by calling col_get_item(). If you want to rename item provide a new name in the property - * argument. If you want the data to remain unchanged use 0 as length parameter. - * If item is a reference or collection the call will return error. +/** + * @brief Get item type. + * + * Get type from the item. + * + * @param[in] ci Item to get type from. + * If item is invalid the function + * will cause a segment violation. + * + * @return Item type. + * + */ +int col_get_item_type(struct collection_item *ci); + +/** + * @brief Get value length from the item. + * + * Get value length from the item. For strings this includes + * NULL terminating zero. + * + * @param[in] ci Item to get value length from. + * If item is invalid the function + * will cause a segment violation. + * + * @return Value length. + * + */ +int col_get_item_length(struct collection_item *ci); + +/** + * @brief Get property value from the item. + * + * Get property value from the item. + * + * @param[in] ci Item to get value from. + * If item is invalid the function + * will cause a segment violation. + * + * @return Property value. + * + */ +void *col_get_item_data(struct collection_item *ci); + +/** + * @brief Get hash value from the item. + * + * Get hash value from the item. The hash value is + * 64-bit hash created from the property name. + * It is done to optimize the searches. + * + * This function is exposed for some corner cases + * that require low level operations, for example + * for custom search callbacks to take advantage + * of the internal hashes. + * + * @param[in] ci Item to get hash from. + * If item is invalid the function + * will cause a segment violation. + * + * @return Hash value. + * + */ +uint64_t col_get_item_hash(struct collection_item *ci); + +/** + * @brief Calculate hash value for a string. + * + * Calculates hash value of the string using internal hashing + * algorithm. Populates "length" with length + * of the string not counting 0. + * + * This function is useful if you want to build a custom + * search or collection sorting function. + * + * @param[in] string String to hash. If NULL hash is 0. + * @param[in] sub_len If it is greater than zero + * it is used to count how many + * characters from string should + * be included into hash calculation. + * If 0 the actual length of the string + * is determined and used. + * @param[out] length Will receive the calculated length + * of the provided string. + * Length argument can be NULL. + * + * @return Hash value. + */ +uint64_t col_make_hash(const char *string, int sub_len, int *length); + + +/** + * @brief Compare two items. + * + * The second item is evaluated against the first. + * Function returns 0 if two items are the same + * and non-zero otherwise. + * The \ref compflags "in_flags" is a bit mask that + * defines how the items should be compared. + * + * If items are different they might be sorted following + * some order. For example one can order items by name + * but not by type. + * If the result of the function is non-zero + * the \ref outflags "out_flags" (if provided) will be + * set to indicate if the second item is greater + * then the first. + * + * @param[in] first First item to compare. + * @param[in] second Second item to compare. + * @param[in] in_flags See \ref compflags "comparison flags". + * @param[out] out_flags See \ref outflags "output flags". + * + * + * @return 0 if items are the same and nonzero otherwise. + + */ +int col_compare_items(struct collection_item *first, + struct collection_item *second, + unsigned in_flags, + unsigned *out_flags); + + + +/** + * @brief Modify any item element. + * + * This function is useful if you want to modify the item that + * you got as a result of \ref iterfunc "iterating" through + * collection or by calling \ref col_get_item. * Previous type and data of the item is destroyed. + * + * If you want to rename an item provide a new name in the property + * argument otherwise keep it NULL. + * + * If you want the data to remain unchanged use 0 as a length parameter. + * + * If item is a reference or a collection the call will return an error. + * + * The are several convenience function that are wrappers + * around this function. For more information + * see \ref modwrap "item modification wrappers". + * + * @param[in] item Item to modify. + * @param[in] property Property name. Use NULL to leave the property + * unchanged. + * @param[in] type See \ref coltypes "types" for more information. + * @param[in] data New value. + * @param[in] length New value. Use 0 to leave the value and its type + * unchanged. + * + * @return 0 - Item was successfully modified. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * The attempt to modify an item which is + * a reference to a collection or a collection + * name. */ int col_modify_item(struct collection_item *item, const char *property, @@ -605,106 +2499,577 @@ int col_modify_item(struct collection_item *item, const void *data, int length); -/* Rename the item */ +/** + * @defgroup modwrap Item modification wrappers + * + * The functions in this section are convenience wrappers + * around \ref col_modify_item. + * They return same error codes. + * + * @{ + */ + +/** + * @brief Modify item property. + * + * This function is a convenience wrapper around \ref col_modify_item. + * It is equivalent to: col_modify_item(item, property, 0, NULL, 0); + * + */ int col_modify_item_property(struct collection_item *item, const char *property); -/* Convenience functions that wrap modify_item(). - * They always assign new value. - * To rename the property just use modify_item_property(); +/** + * @brief Modify item value to be a string. + * + * This function is a convenience wrapper around \ref col_modify_item. + * It sets a value of the item to a provided string. + * If property is not NULL it also renames the property. + * If the length argument is not zero the string will be truncated to + * this length. If the length is 0 the length will be calculated based + * on the length of the actual string. + * Original value is always destroyed. + * + * @return - same error values as \ref col_modify_item. */ int col_modify_str_item(struct collection_item *item, const char *property, const char *string, int length); +/** + * @brief Modify item value to be a binary blob. + * + * This function is a convenience wrapper around \ref col_modify_item. + * It sets a value of the item to a provided binary buffer. + * If property is not NULL it also renames the property. + * Original value is always destroyed. + * + * @return - same error values as \ref col_modify_item. + */ int col_modify_binary_item(struct collection_item *item, const char *property, void *binary_data, int length); +/** + * @brief Modify item value to be a Boolean. + * + * This function is a convenience wrapper around \ref col_modify_item. + * It sets a value of the item to a provided logical value. + * If property is not NULL it also renames the property. + * Original value is always destroyed. + * + * @return - same error values as \ref col_modify_item. + */ int col_modify_bool_item(struct collection_item *item, const char *property, unsigned char logical); +/** + * @brief Modify item value to be an integer. + * + * This function is a convenience wrapper around \ref col_modify_item. + * It sets a value of the item to a provided integer value. + * If property is not NULL it also renames the property. + * Original value is always destroyed. + * + * @return - same error values as \ref col_modify_item. + */ int col_modify_int_item(struct collection_item *item, const char *property, int number); +/** + * @brief Modify item value to be a long integer. + * + * This function is a convenience wrapper around \ref col_modify_item. + * It sets a value of the item to a provided long integer value. + * If property is not NULL it also renames the property. + * Original value is always destroyed. + * + * @return - same error values as \ref col_modify_item. + */ int col_modify_long_item(struct collection_item *item, const char *property, long number); +/** + * @brief Modify item value to be an unsigned long. + * + * This function is a convenience wrapper around \ref col_modify_item. + * It sets a value of the item to a provided unsigned long value. + * If property is not NULL it also renames the property. + * Original value is always destroyed. + * + * @return - same error values as \ref col_modify_item. + */ int col_modify_ulong_item(struct collection_item *item, const char *property, unsigned long number); +/** + * @brief Modify item value to be an unsigned integer. + * + * This function is a convenience wrapper around \ref col_modify_item. + * It sets a value of the item to a provided unsigned integer value. + * If property is not NULL it also renames the property. + * Original value is always destroyed. + * + * @return - same error values as \ref col_modify_item. + */ int col_modify_unsigned_item(struct collection_item *item, const char *property, unsigned number); +/** + * @brief Modify item value to be a floating point. + * + * This function is a convenience wrapper around \ref col_modify_item. + * It sets a value of the item to a provided floating point value. + * If property is not NULL it also renames the property. + * Original value is always destroyed. + * + * @return - same error values as \ref col_modify_item. + */ int col_modify_double_item(struct collection_item *item, const char *property, double number); -/* Delete property from the collection. */ -/* It is recomended to use a more efficient function - * col_remove_item() for the same purpose if - * the property is unique or if the collection - * has a known structure. - * This function has some advantage only - * if it is not known where propery - * resides and what is the structure of the collection. - * In this case "foo.bar.baz" notation - * can be used in the property_to_find argument to find - * and delete the property "baz" that is in sub collection "bar" - * which is in turn a part of collection "foo". +/** + * @} */ -int col_delete_property(struct collection_item *ci, /* A collection of items */ - const char *property_to_find, /* Name to match */ - int type, /* Type filter */ - int mode_flags); /* How to traverse the collection */ +/** + * @brief Extract item from the collection. + * + * Function to find and remove an item from the collection. + * Function does not destroy the item instead it returns a reference + * to the item so it can be used later and inserted back into this or + * other collection. + * The function assumes that the caller knows the collection + * the property is stored in. + * The header of the collection can't be extracted with this function + * but the reference to the collection can. + * + * Function allows specifying relative position of the item in the + * collection. One can specify that he wants to extract an item + * that is first in the collection or last, or after other item + * in the collection. For more details see parameter definitions. + * + * After extracting the item from the collection the caller has to + * either insert it back into some collection using \ref col_insert_item + * or delete it using \ref col_delete_item. + * + * + * @param[in] ci Collection object. + * @param[in] subcollection Name of the sub collection to extract + * item from. If NULL, the top level collection + * is used. One can use "foo!bar!baz" + * notation to identify the sub collection. + * @param[in] disposition Constant that controls how the relative + * position of the item to extract is determined. + * For more information see \ref dispvalues + * "disposition constants". + * @param[in] refprop Name of the property to relate to. + * This can be used to specify that function + * should extract next item after the item + * with this name. Leave NULL if the + * disposition you are using does not + * relate to an item in the collection. + * @param[in] idx Index of the property to extract. + * Useful for multi-value properties where + * several properties have same name in a row. + * @param[in] type Type filter. Only the item of the matching + * type will be used. It can be a bit mask of + * more than one type. Use 0 if you do not + * need to filter by type. + * @param[out] ret_ref Variable will receive the value of the + * pointer to the extracted item. + * + * @return 0 - Item was successfully extracted. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOENT - Sub collection is not found. + * The position can't be determined. For example + * extracting next item after item with name "foo" + * will cause this error if item "foo" is the last + * item in the collection. There are other cases + * when this error can be returned but the common + * theme is that something was not found. + * @return ENOSYS Unknown disposition value. + */ +int col_extract_item(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + int type, + struct collection_item **ret_ref); + +/** + * @brief Extract item from the current collection. + * + * Function is similar to the \ref col_extract_item. + * It acts exactly the same as \ref col_extract_item when the + * subcollection parameter of the \ref col_extract_item is set to NULL. + * + * @param[in] ci Collection object. + * @param[in] disposition Constant that controls how the relative + * position of the item to extract is determined. + * For more information see \ref dispvalues + * "disposition constants". + * @param[in] refprop Name of the property to relate to. + * This can be used to specify that function + * should extract next item after the item + * with this name. Leave NULL if the + * disposition you are using does not + * relate to an item in the collection. + * @param[in] idx Index of the property to extract. + * Useful for multi-value properties where + * several properties have same name in a row. + * @param[in] type Type filter. Only the item of the matching + * type will be used. It can be a bit mask of + * more than one type. Use 0 if you do not + * need to filter by type. + * @param[out] ret_ref Variable will receive the value of the + * pointer to the extracted item. + * + * @return 0 - Item was successfully extracted. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOENT - Sub collection is not found. + * The position can't be determined. For example + * extracting next item after item with name "foo" + * will cause this error if item "foo" is the last + * item in the collection. There are other cases + * when this error can be returned but the common + * theme is that something was not found. + * @return ENOSYS Unknown disposition value. + */ +int col_extract_item_from_current(struct collection_item *ci, + int disposition, + const char *refprop, + int idx, + int type, + struct collection_item **ret_ref); -/* Convenience function to check if the property is indeed in the collection */ -int col_is_item_in_collection(struct collection_item *ci, /* Collection to find things in */ - const char *property_to_find, /* Name to match */ - int type, /* Type filter */ - int mode_flags, /* How to traverse the collection */ - int *found); /* Boolean that turns to nonzero if the match is found */ +/** + * @brief Remove item from the collection. + * + * Function internally calls \ref col_extract_item and then + * \ref col_delete_item for the extracted item. + * + * Function is similar to \ref col_delete_property function + * but allows more specific information about what item (property) + * to remove. + * + * The header will not be considered for deletion. + * + * @param[in] ci Collection object. + * @param[in] subcollection Name of the sub collection to remove + * item from. If NULL, the top level collection + * is used. One can use "foo!bar!baz" + * notation to identify the sub collection. + * @param[in] disposition Constant that controls how the relative + * position of the item to remove is determined. + * For more information see \ref dispvalues + * "disposition constants". + * @param[in] refprop Name of the property to relate to. + * This can be used to specify that function + * should remove next item after the item + * with this name. Leave NULL if the + * disposition you are using does not + * relate to an item in the collection. + * @param[in] idx Index of the property to remove. + * Useful for multi-value properties where + * several properties have same name in a row. + * @param[in] type Type filter. Only the item of the matching + * type will be used. It can be a bit mask of + * more than one type. Use 0 if you do not + * need to filter by type. + * + * @return 0 - Item was successfully removed. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOENT - Sub collection is not found. + * The position can't be determined. For example + * deleting next item after item with name "foo" + * will cause this error if item "foo" is the last + * item in the collection. There are other cases + * when this error can be returned but the common + * theme is that something was not found. + * @return ENOSYS Unknown disposition value. + */ +int col_remove_item(struct collection_item *ci, + const char *subcollection, + int disposition, + const char *refprop, + int idx, + int type); -/* Get collection - get a pointer to a collection included into another collection. - * If the collection_to_find is NULL function reterns a reference to the top level collection. - * Delete extracted collection after use to decrease reference count. +/** + * @brief Remove item from the current collection. + * + * Function is similar to the \ref col_remove_item. + * It acts exactly the same as \ref col_remove_item when the + * subcollection parameter of the \ref col_remove_item is set to NULL. + * + * @param[in] ci Collection object. + * @param[in] disposition Constant that controls how the relative + * position of the item to remove is determined. + * For more information see \ref dispvalues + * "disposition constants". + * @param[in] refprop Name of the property to relate to. + * This can be used to specify that function + * should remove next item after the item + * with this name. Leave NULL if the + * disposition you are using does not + * relate to an item in the collection. + * @param[in] idx Index of the property to remove. + * Useful for multi-value properties where + * several properties have same name in a row. + * @param[in] type Type filter. Only the item of the matching + * type will be used. It can be a bit mask of + * more than one type. Use 0 if you do not + * need to filter by type. + * + * @return 0 - Item was successfully removed. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOENT - Sub collection is not found. + * The position can't be determined. For example + * deleting next item after item with name "foo" + * will cause this error if item "foo" is the last + * item in the collection. There are other cases + * when this error can be returned but the common + * theme is that something was not found. + * @return ENOSYS Unknown disposition value. + */ +int col_remove_item_from_current(struct collection_item *ci, + int disposition, + const char *refprop, + int idx, + int type); + +/** + * @brief Insert item to the collection. + * + * <b>WARNING:</b> Only use this function to insert items + * that were extracted using \ref col_extract_item or + * \ref col_extract_item_from_current. + * <b>NEVER</b> use it with items that were returned by: + * - \ref col_get_item + * - \ref addproperty "add property" functions + * - \ref addprop_withref "add property with reference" functions + * - \ref insertproperty "instert property" functions. + * + * The fundamental difference is that when you extracted item + * using col_extract_item() it stops to be managed by a collection. + * With such item you can: + * - a) Insert this item into another (or same) collection + * - b) Get item information using corresponding item management functions. + * - c) Destroy item using col_delete_item(). + * + * You are required to do either a) or c) with such item. + * + * @param[in] ci Collection object. + * @param[in] subcollection Name of the sub collection to insert + * item into. If NULL, the top level collection + * is used. One can use "foo!bar!baz" + * notation to identify the sub collection. + * @param[in] item Item to insert. + * @param[in] disposition Constant that controls where to insert + * the item. + * For more information see \ref dispvalues + * "disposition constants". + * @param[in] refprop Name of the property to relate to. + * This can be used to specify that function + * should insert the item after the item + * with this name. Leave NULL if the + * disposition you are using does not + * relate to an item in the collection. + * @param[in] idx Index of the property to insert. + * Useful for multi-value properties where + * several properties have same name in a row. + * @param[in] flags Flags that control naming issues. + * See \ref insflags "insert flags" + * for more details. + * + * @return 0 - Item was successfully extracted. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOENT - Sub collection is not found. + * The position can't be determined. For example + * extracting next item after item with name "foo" + * will cause this error if item "foo" is the last + * item in the collection. There are other cases + * when this error can be returned but the common + * theme is that something was not found. + * @return ENOSYS Unknown disposition value. + * @return EEXIST If duplicate name/type checking is turned on + * and duplicate name/type is detected. + * + */ +int col_insert_item(struct collection_item *ci, + const char *subcollection, + struct collection_item *item, + int disposition, + const char *refprop, + int idx, + unsigned flags); + +/** + * @brief Insert item to the current collection. + * + * Function is equivalent to \ref col_insert_item with + * subcollection parameter equal NULL. + * + * @param[in] ci Collection object. + * @param[in] item Item to insert. + * @param[in] disposition Constant that controls where to insert + * the item. + * For more information see \ref dispvalues + * "disposition constants". + * @param[in] refprop Name of the property to relate to. + * This can be used to specify that function + * should insert the item after the item + * with this name. Leave NULL if the + * disposition you are using does not + * relate to an item in the collection. + * @param[in] idx Index of the property to insert. + * Useful for multi-value properties where + * several properties have same name in a row. + * @param[in] flags Flags that control naming issues. + * See \ref insflags "insert flags" + * for more details. + * + * @return 0 - Item was successfully extracted. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * @return ENOENT - Sub collection is not found. + * The position can't be determined. For example + * extracting next item after item with name "foo" + * will cause this error if item "foo" is the last + * item in the collection. There are other cases + * when this error can be returned but the common + * theme is that something was not found. + * @return ENOSYS Unknown disposition value. + * @return EEXIST If duplicate name/type checking is turned on + * and duplicate name/type is detected. + * + */ +int col_insert_item_into_current(struct collection_item *ci, + struct collection_item *item, + int disposition, + const char *refprop, + int idx, + unsigned flags); + + + +/** + * @brief Delete extracted item. + * + * <b>NEVER</b> use this function to delete an item + * that was not previously extracted from the collection. + * + * There is currently no function to create an item aside and + * then insert it into the collection so the col_delete_item + * has only one use. In future this may change. + * + * @param[in] item Item to delete. + * + */ +void col_delete_item(struct collection_item *item); + +/** + * @} */ -int col_get_collection_reference(struct collection_item *ci, /* High level collection */ - struct collection_item **acceptor, /* The pointer that will accept extracted handle */ - const char *collection_to_find); /* Name to of the collection */ -/* Get collection - if current item is a reference get a real collection from it. */ -/* Delete extracted collection after use to decrease reference count. */ -int col_get_reference_from_item(struct collection_item *ci, /* Reference element of the high level collection */ - struct collection_item **acceptor); /* The pointer that will accept extracted handle */ -/* Bind iterator to a collection */ -int col_bind_iterator(struct collection_iterator **iterator, /* The iterator to bind */ - struct collection_item *ci, /* Collection to bind iterator to */ - int mode_flags); /* How the collection needs to be iterated */ +/** + * @defgroup iterfunc Iterator interface + * + * The functions in this section allow iterating + * through a collection in a loop where the caller + * implements the loop. It is different from the search and + * traverse functions described in other sections because those + * functions implement the loop themselves and call provided + * callback in a specific situation. + * + * @{ + */ -/* Unbind the iterator from the collection */ +/** + * @brief Bind iterator to a collection. + * + * This function creates an iterator object and binds it to the collection. + * + * @param[out] iterator Newly created iterator object. + * @param[in] ci Collection to iterate. + * @param[in] mode_flags Flags define how to traverse the collection. + * For more information see \ref traverseconst + * "constants defining traverse modes". + * + * @return 0 - Iterator was created successfully. + * @return ENOMEM - No memory. + * @return EINVAL - The value of some of the arguments is invalid. + * + */ +int col_bind_iterator(struct collection_iterator **iterator, + struct collection_item *ci, + int mode_flags); + +/** + * @brief Unbind the iterator from the collection. + * + * @param[in] iterator Iterator object to free. + */ void col_unbind_iterator(struct collection_iterator *iterator); -/* Get items from the collection one by one following the tree */ +/** + * @brief Iterate collection. + * + * Advance to next item in the collection. After the iterator is + * bound it does not point to any item in the collection. + * Use this function in the loop to step through all items + * in the collection. See unit test for code examples. + * + * @param[in] iterator Iterator object to use. + * @param[out] item Pointer to the collection item. + * Do not destroy or alter this pointer + * in any ways. To access the internals + * of the item use \ref getitem "item management" + * functions. + * The value of the item will be set to NULL if + * the end of the collection is reached. + * + * @return 0 - Item was successfully retrieved. + * @return EINVAL - The value of some of the arguments is invalid. + */ int col_iterate_collection(struct collection_iterator *iterator, struct collection_item **item); -/* Stop processing this subcollection and move to the next item in the - * collection 'level' levels up. - * The 'Level' parameter indicates how many levels up you want to jump. - * If 0 - call is a no op. - * If the depth is less then requested level the iterator will - * get to the 0 level and next call to col_iterate_collection - * will return NULL item. +/** + * @brief Move up + * + * Stop processing this sub collection and move to the next item in the + * collection some levels up. + * + * @param[in] iterator Iterator object to use. + * @param[in] level Indicates how many levels up you want to jump. + * If 0 - call is a no op. + * If the depth is less then requested level + * the iterator will get to the 0 level and + * next call to \ref col_iterate_collection + * will return NULL item. + * + * @return 0 - Iterator was successfully repositioned. + * @return EINVAL - The value of some of the arguments is invalid. */ int col_iterate_up(struct collection_iterator *iterator, unsigned level); -/* How deep are we relative to the top level. - * This function might report depth that might look misleading. - * The reason is that traverse flags affect the internal +/** + * @brief Get current depth + * + * How deep are we relative to the top level? + * This function will report depth that in some cases might look + * misleading. The reason is that traverse flags affect the internal * level we are on at each moment. * For example the default traverse behavior is to show * references to the sub collections. @@ -714,404 +3079,111 @@ int col_iterate_up(struct collection_iterator *iterator, unsigned level); * denote the level inside collection. * Now imagine that this collection is empty so the attempt to read * element will push you automatically one level up (in absence of the - * COL_TRAVERSE_END flag). If in this situation you encounter another + * \ref COL_TRAVERSE_END flag). If in this situation you encounter another * collection the reference will be returned and level automatically * adjusted to level inside the collection. * The point is that the level is reliable only after * a data item was returned. - * To avoid this ambiguity another function is introduced. - * See below. -*/ + * To avoid this ambiguity another function \ref col_get_item_depth + * was introduced. + * + * @param[in] iterator Iterator object to use. + * @param[in] depth The variable will receive the depth + * the iterator is on. The value is 0 + * if the iterator is on the top level. + * + * @return 0 - Success. + * @return EINVAL - The value of some of the arguments is invalid. + */ int col_get_iterator_depth(struct collection_iterator *iterator, int *depth); -/* Returns item depth for the last read item. - * Returns 0 if no item has been read yet. +/** + * @brief Get depth of the last returned item. + * + * @param[in] iterator Iterator object to use. + * @param[in] depth The variable will receive the depth + * the iterator is on. + * Item from the top level will have + * depth equal to 0. The value of 0 + * will also be returned if no item + * was read so far. + * + * @return 0 - Success. + * @return EINVAL - The value of some of the arguments is invalid. */ int col_get_item_depth(struct collection_iterator *iterator, int *depth); -/* Pins down the iterator to loop around current point */ +/** + * @brief Pin iterator + * + * Pins down the iterator to loop around current point. + * + * This feature allows some search optimization. + * The idea is to be able to put a 'pin' + * into a specific place while iterating + * the collection and make this place a new + * "wrap around" place for the collection. + * This means that next time you + * iterate this collection you will start + * iterating from the next item and + * the item you got before setting pin will be + * the last in your iteration cycle. + * + * Here is the example: + * + * Assume you have two collections that you need + * to compare and perform some action on collection + * 1 based on the presence of the item in collection 2. + * - Collection1 = A, B, C, D, E, F + * - Collection2 = A, C, F + * + * The usual approach is to try A from collection 1 + * against A, B, C from collection 2. "A" will be found + * right away. But to find "F" it has to be compared + * to "A" and "C" first. The fact that the collections + * are to some extent ordered can in some cases + * help to reduce the number of comparisons. + * If we found "C" in the list we can put a "pin" + * into the collection there causing the iterator + * to warp at this "pin" point. Since "D" and "E" + * are not in the second collection we will have + * to make same amount of comparisons in traditional + * or "pinned" case to not find them. + * To find "F" in pinned case there will be just one + * comparison. + * - Traditional case = 1 + 3 + 2 + 3 + 3 + 3 = 15 + * - Pinned case = 1 + 3 + 1 + 3 + 3 + 1 = 12 + * + * It is a 20% comparison reduction. + * + * @param[in] iterator Iterator object to use. + * + * @return 0 - Success. + * @return EINVAL - The value of the argument is invalid. + */ void col_pin_iterator(struct collection_iterator *iterator); -/* Rewinds iterator to the beginning */ +/** + * @brief Rewind iterator + * + * Rewinds iterator to the current pin point which is by + * default the beginning of the collection until changed by + * \ref col_pin_iterator function. + * + * @param[in] iterator Iterator object to use. + * + * @return 0 - Success. + * @return EINVAL - The value of the argument is invalid. + */ void col_rewind_iterator(struct collection_iterator *iterator); -/* Set collection class */ -int col_set_collection_class(struct collection_item *item, /* Collection */ - unsigned cclass); /* Collection class */ - -/* Get collection class */ -int col_get_collection_class(struct collection_item *item, /* Collection */ - unsigned *cclass); /* Collection class */ - -/* Get collection count */ -int col_get_collection_count(struct collection_item *item, /* Collection */ - unsigned *count); /* Number of elements in - * this collection. - * Each subcollection is - * counted as 1 element. - * Header is also counted. - */ - -/* Convenience function to check if the collection is of the specific class */ -/* In case of internal error assumes that collection is not of the right class */ -int col_is_of_class(struct collection_item *item, /* Collection */ - unsigned cclass); /* Class of the collection */ - - -/* - * Series of collection functions that allow using collection as a stack or a FIFO - */ - - -/* Extract the item from the collection */ -/* The header will not be considered for extraction. */ -int col_extract_item(struct collection_item *ci, /* Top collection */ - const char *subcollection, /* Sub collection */ - int disposition, /* Which to extract */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to extract. See notes. */ - int type, /* Type filter */ - struct collection_item **ret_ref); /* Returns the reference back */ - -/* Similar extraction function as above just considers only one level. */ -int col_extract_item_from_current(struct collection_item *ci, /* Top collection */ - int disposition, /* Which to extract */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to extract. See notes. */ - int type, /* Type filter */ - struct collection_item **ret_ref); /* Returns the reference back */ - -/* Remove item (property) from collection. - * It is similar to delete_property function but allows more specific - * information about what item (property) to remove. - * The header will not be considered for deletion. +/** + * @} */ -int col_remove_item(struct collection_item *ci, /* Top collection */ - const char *subcollection, /* Sub collection */ - int disposition, /* Which to remove */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to remove. See notes. */ - int type); /* Type filter */ - -/* Similar function as above just considers only one level. */ -int col_remove_item_from_current(struct collection_item *ci, /* Top collection */ - int disposition, /* Which to remove */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to remove. See notes. */ - int type); /* Type filter */ - - -/* Insert item to the collection */ -/* WARNING: Only use this function to insert items - * that were extracted using extract_item(). - * NEVER use it with items that were returned - * by col_get_item() or col_add_xxx_property_with_ref() or - * with col_insert_xxx_property_with_ref(). - * The fundamental difference is that when you extracted item - * using col_extract_item() it stops to be managed by a collection. - * With such item you can: - * a) Insert this item into another (or same) collection - * b) Get item information using col_get_item_xxx() functions. - * c) Destroy item using col_delete_item(). - * You are required to do either a) or c) with such item. - */ -int col_insert_item(struct collection_item *collection, /* Top collection */ - const char *subcollection, /* Sub collection */ - struct collection_item *item, /* Item to insert */ - int disposition, /* What should be the position of the item */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to extract. See notes. */ - unsigned flags); /* Flags that control naming issues */ - -/* Insert the item into the top level collection (similar to the function above) - * but does not provide access to the sub collection. - */ -int col_insert_item_into_current(struct collection_item *collection, - struct collection_item *item, - int disposition, - const char *refprop, - int idx, - unsigned flags); - - -/* Function to delete the item */ -void col_delete_item(struct collection_item *item); - -/* Possible dispositions for insert, extract and delete function(s). - * Not all of these dispositions are implemented day one. - * If disposition is not implemented the function - * will return error ENOSYS. +/** + * @} */ -#define COL_DSP_END 0 /* Add property to the end of the collection */ - /* Extract or delete last property in collection */ -#define COL_DSP_FRONT 1 /* Add property to the top of the collection */ - /* Extract or delete firat property in collection */ -#define COL_DSP_BEFORE 2 /* Add property before other named property */ - /* Extract or delete property that is before given - * property. If the given property is first - * in the list ENOENT is returned. - */ -#define COL_DSP_AFTER 3 /* Add property immediately after other named property */ - /* Delete or extract property immediately after given - * property. If the given property is last in the list - * ENOENT is returned. - */ -#define COL_DSP_INDEX 4 /* Add, extract or delete property using index. - * See notes below. - */ -/* NOTE ABOUT USING: COL_DSP_INDEX. */ -/* The COL_DSP_INDEX adds the item as N-th item after header in the list. - * Index is zero based. - * If there are less than N items in the list the item is added to the end. - * The index value of 0 means that the item will be added immediately - * after the header. Index of 1 will mean that it is added after first data item and so on. - * - * In case of extraction or deletion the N-th item of the collection - * will be extracted or deleted. - * Index is zero based. - * If there are less than N+1 items in the list the function will return ENOENT. - */ - -/* The following three dispositions operate only with list of duplicate - * properties that are going one after another. - * In case of addition the property name is taken from the item - * and the value refprop is ignored. - * In case of extraction or deletion the property name is taken - * from the refprop. - */ -#define COL_DSP_FIRSTDUP 5 /* Add property as a first dup of the given property */ - /* In case of extraction or deletion extracts or deletes - * given property. - */ -#define COL_DSP_LASTDUP 6 /* Add property as a last dup of the given property */ - /* In case of extraction or deletion extracts or deletes - * last duplicate property in the uninterrupted sequence of - * properties with the same name. - */ -#define COL_DSP_NDUP 7 /* Add property as a N-th dup (0- based) of the given property. */ - /* In case of extraction or deletion extracts or deletes - * N-th (0-based) duplicate of the given property. - * If index is greater than number of duplicate - * properties in sequence ENOENT is returned. - * See more details below. - */ - -/* Other dispositions might be possible in future. */ - -/* The COL_DSP_NDUP is used in case of the multi value property - * to add a new property with the same name into specific place - * in the list of properties with the same name. - * The index of 0 will mean to add the property before the first instance of the property with the same name. - * If the property does not exist ENOENT will be returned. - * If the index is greater than the last property with the same name the item will be added - * immediately after last property with the same name. - */ - -/* Flags that can be used with insert functions */ -#define COL_INSERT_NOCHECK 0 /* This is the default mode - no dup checks on insert */ -#define COL_INSERT_DUPOVER 1 /* Check for dup name and overwrite - position ignored */ -#define COL_INSERT_DUPOVERT 2 /* Check for dup name and type and overwrite - position ignored */ -#define COL_INSERT_DUPERROR 3 /* Return error EEXIST if the entry with the same name exists */ -#define COL_INSERT_DUPERRORT 4 /* Return error EEXIST if the entry with the same name and type exists */ -#define COL_INSERT_DUPMOVE 5 /* Check for dups, overwrite, extracts and - * then move to the position requested */ -#define COL_INSERT_DUPMOVET 6 /* Check for dup name and type, overwrite, extracts - * and then move to the position requested */ - -/* In future can be made more complex */ - -/* NOTE ABOUT FLAGS: Use of the DUP checking flags is costly since it requires a forward look up of the whole - * collection before the item is inserted. Do not use it until it is absolutely necessary. - */ - - - -/* The attributes in the collection are always added to the end. - * The family of the insert_xxx(functions) provides - * much more flexibility than add_xxx_property_xxx() functions. - */ - -/* Insert property with reference */ -int col_insert_property_with_ref(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - int type, /* Data type */ - const void *data, /* Pointer to the data */ - int length, /* Length of the data. For - * strings it includes the - * trailing 0 - */ - struct collection_item **ret_ref); /* Returns the reference back */ - - -int col_insert_str_property(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - const char *string, /* String */ - int length); /* Length */ - -int col_insert_binary_property(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - void *binary_data, /* Binary data */ - int length); /* Length */ - - -int col_insert_int_property(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - int number); /* Integer */ - - -int col_insert_unsinged_property(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - unsigned number); /* Unsigned */ - - -int col_insert_long_property(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - long number); /* Long */ - -int col_insert_ulong_property(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - unsigned long number); /* Unsigned long */ - -int col_insert_double_property(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - double number); /* Double */ - -int col_insert_bool_property(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - unsigned char logical); /* Bool */ - - - -int col_insert_str_property_with_ref(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - char *string, /* String */ - int length, /* Length */ - struct collection_item **ret_ref); /* Returns the reference back */ - -int col_insert_binary_property_with_ref(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - void *binary_data, /* Binary data */ - int length, /* Length */ - struct collection_item **ret_ref); /* Returns the reference back */ - - -int col_insert_int_property_with_ref(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - int number, /* Integer */ - struct collection_item **ret_ref); /* Returns the reference back */ - - -int col_insert_unsinged_property_with_ref(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - unsigned number, /* Unsigned */ - struct collection_item **ret_ref); /* Returns the reference back */ - -int col_insert_long_property_with_ref(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - long number, /* Long */ - struct collection_item **ret_ref); /* Returns the reference back */ - -int col_insert_ulong_property_with_ref(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - unsigned long number, /* Unsigned long */ - struct collection_item **ret_ref); /* Returns the reference back */ - -int col_insert_double_property_with_ref(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - double number, /* Double */ - struct collection_item **ret_ref); /* Returns the reference back */ - -int col_insert_bool_property_with_ref(struct collection_item *ci, /* A collection of items */ - const char *subcollection, /* Sub collection */ - int disposition, /* Where to insert */ - const char *refprop, /* Property to relate to */ - int idx, /* Index of the property to add */ - unsigned flags, /* Flags that control naming issues */ - const char *property, /* Name */ - unsigned char logical, /* Bool */ - struct collection_item **ret_ref); /* Returns the reference back */ - #endif diff --git a/common/collection/collection_cnv.c b/common/collection/collection_cnv.c index e60935ae..f887ff2e 100644 --- a/common/collection/collection_cnv.c +++ b/common/collection/collection_cnv.c @@ -290,7 +290,7 @@ int col_insert_str_property_with_ref(struct collection_item *ci, int idx, unsigned flags, const char *property, - char *string, + const char *string, int length, struct collection_item **ret_ref) { diff --git a/common/collection/collection_iter.c b/common/collection/collection_iter.c index 0baefe83..f3735d7d 100644 --- a/common/collection/collection_iter.c +++ b/common/collection/collection_iter.c @@ -32,7 +32,8 @@ #include "collection_priv.h" #include "collection.h" - +/* Depth for iterator depth allocation block */ +#define STACK_DEPTH_BLOCK 15 /* Grow iteration stack */ static int col_grow_stack(struct collection_iterator *iterator, unsigned desired) diff --git a/common/collection/collection_queue.h b/common/collection/collection_queue.h index ff150ef6..2fe07489 100644 --- a/common/collection/collection_queue.h +++ b/common/collection/collection_queue.h @@ -24,66 +24,298 @@ #include "collection.h" +/** + * @defgroup queue QUEUE interface + * + * Queue interface is a wrapper on top of the \ref collection + * interface. It implements a queue using a collection object. + * + * @{ + */ +/** @brief Class for the queue object */ #define COL_CLASS_QUEUE 40000 +/** @brief All queues use this name as the name of the collection */ #define COL_NAME_QUEUE "queue" -/* Function that creates a queue object */ +/** + * @brief Create queue. + * + * Function that creates a queue object. + * + * @param[out] queue Newly created queue object. + * + * @return 0 - Queue was created successfully. + * @return ENOMEM - No memory. + * + */ int col_create_queue(struct collection_item **queue); -/* Function that destroys a queue object */ +/** + * @brief Destroy queue. + * + * Function that destroys a queue object. + * + * @param[in] queue Queue object to destroy. + * + */ void col_destroy_queue(struct collection_item *queue); -/* Family of functions that add property to a queue */ -/* Put a string property to queue. */ +/** + * @brief Add string to the queue. + * + * @param[in] queue Queue object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] string Null terminated string to add. + * @param[in] length Length of the string. Should include the length + * of the terminating 0. + * If the length is shorter than the full string + * the string will be truncated. If the length is + * longer than the actual string there might be + * garbage at end of the actual string. + * Library will always properly NULL terminate + * the string at the given position dictated + * by length but in no way will inspect the validity + * of the passed in data. This is left to the calling + * application. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * + */ int col_enqueue_str_property(struct collection_item *queue, const char *property, const char *string, int length); -/* Put a binary property to queue. */ +/** + * @brief Add binary value to the queue. + * + * @param[in] queue Queue object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] binary_data Data to add. + * @param[in] length Length of the binary data. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_enqueue_binary_property(struct collection_item *queue, const char *property, void *binary_data, int length); -/* Put an int property to queue. */ +/** + * @brief Add integer value to the queue. + * + * @param[in] queue Queue object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_enqueue_int_property(struct collection_item *queue, const char *property, int number); -/* Put an unsigned int property to queue. */ +/** + * @brief Add unsigned value to the queue. + * + * @param[in] queue Queue object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_enqueue_unsigned_property(struct collection_item *queue, const char *property, unsigned int number); -/* Put a long property. */ +/** + * @brief Add long integer value to the queue. + * + * @param[in] queue Queue object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_enqueue_long_property(struct collection_item *queue, const char *property, long number); -/* Put an unsigned long property. */ +/** + * @brief Add unsigned long value to the queue. + * + * @param[in] queue Queue object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_enqueue_ulong_property(struct collection_item *queue, const char *property, unsigned long number); -/* Put a double property. */ +/** + * @brief Add floating point value to the queue. + * + * @param[in] queue Queue object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_enqueue_double_property(struct collection_item *queue, const char *property, double number); -/* Put a bool property. */ +/** + * @brief Add Boolean value to the queue. + * + * @param[in] queue Queue object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] logical Value to add. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_enqueue_bool_property(struct collection_item *queue, const char *property, unsigned char logical); -/* Put any property */ -int col_enqueue_any_property(struct collection_item *queue, /* Queue */ - const char *property, /* Name */ - int type, /* Data type */ - void *data, /* Pointer to the data */ - int length); /* Length of the data. For - * strings it includes the - * trailing 0 */ -/* Push item */ +/** + * @brief Add value of any type to the queue. + * + * @param[in] queue Queue object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] type Type to use. + * @param[in] data Data to add. + * @param[in] length Length of the data. + * + * @return 0 - Property was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * + */ +int col_enqueue_any_property(struct collection_item *queue, + const char *property, + int type, + void *data, + int length); + +/** + * @brief Push item into the queue. + * + * @param[in] queue Queue object. + * @param[in] item Item to push. + * + * @return 0 - Item was added successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + */ int col_enqueue_item(struct collection_item *queue, struct collection_item *item); - -/* Get item from queue */ +/** + * @brief Get item from the queue. + * + * @param[in] queue Queue object. + * @param[out] item Variable receives the value + * of the retrieved item. + * Will be set to NULL if there are + * no more items in the queue. + * + * @return 0 - No internal issues detected. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + */ int col_dequeue_item(struct collection_item *queue, struct collection_item **item); diff --git a/common/collection/collection_stack.h b/common/collection/collection_stack.h index 256094c2..e4be156b 100644 --- a/common/collection/collection_stack.h +++ b/common/collection/collection_stack.h @@ -24,66 +24,301 @@ #include <collection.h> +/** + * @defgroup stack STACK interface + * + * Stack interface is a wrapper on top of the \ref collection + * interface. It implements a stack using a collection object. + * + * @{ + */ +/** @brief Class for the stack object */ #define COL_CLASS_STACK 30000 +/** @brief All stacks use this name as the name of the collection */ #define COL_NAME_STACK "stack" -/* Function that creates a stack object */ +/** + * @brief Create stack. + * + * Function that creates a stack object. + * + * @param[out] stack Newly created stack object. + * + * @return 0 - Stack was created successfully. + * @return ENOMEM - No memory. + * + */ int col_create_stack(struct collection_item **stack); -/* Function that destroys a stack object */ +/** + * @brief Destroy stack. + * + * Function that destroys a stack object. + * + * @param[in] stack Stack object to destroy. + * + */ + void col_destroy_stack(struct collection_item *stack); -/* Family of functions that push property to stack */ -/* Push a string property to stack. */ +/** + * @brief Push string to the stack. + * + * @param[in] stack Stack object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] string Null terminated string to add. + * @param[in] length Length of the string. Should include the length + * of the terminating 0. + * If the length is shorter than the full string + * the string will be truncated. If the length is + * longer than the actual string there might be + * garbage at end of the actual string. + * Library will always properly NULL terminate + * the string at the given position dictated + * by length but in no way will inspect the validity + * of the passed in data. This is left to the calling + * application. + * + * @return 0 - Property was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * + */ int col_push_str_property(struct collection_item *stack, const char *property, const char *string, int length); -/* Push a binary property to stack. */ +/** + * @brief Push binary value to the stack. + * + * @param[in] stack Stack object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] binary_data Data to add. + * @param[in] length Length of the binary data. + * + * @return 0 - Property was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_push_binary_property(struct collection_item *stack, const char *property, void *binary_data, int length); -/* Push an int property to stack. */ +/** + * @brief Push integer value to the stack. + * + * @param[in] stack Stack object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_push_int_property(struct collection_item *stack, const char *property, int number); -/* Push an unsigned int property to stack. */ +/** + * @brief Push unsigned value to the stack. + * + * @param[in] stack Stack object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_push_unsigned_property(struct collection_item *stack, const char *property, unsigned int number); -/* Push a long property. */ +/** + * @brief Push long integer value to the stack. + * + * @param[in] stack Stack object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_push_long_property(struct collection_item *stack, const char *property, long number); -/* Push an unsigned long property. */ +/** + * @brief Push unsigned long value to the stack. + * + * @param[in] stack Stack object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_push_ulong_property(struct collection_item *stack, const char *property, unsigned long number); -/* Push a double property. */ +/** + * @brief Push floating point value to the stack. + * + * @param[in] stack Stack object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] number Value to add. + * + * @return 0 - Property was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_push_double_property(struct collection_item *stack, const char *property, double number); -/* Push a bool property. */ +/** + * @brief Push Boolean value to the stack. + * + * @param[in] stack Stack object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] logical Value to add. + * + * @return 0 - Property was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * @return EMSGSIZE - Property name is too long. + * + */ int col_push_bool_property(struct collection_item *stack, const char *property, unsigned char logical); -/* Push any property */ -int col_push_any_property(struct collection_item *stack, /* Stack */ - const char *property, /* Name */ - int type, /* Data type */ - void *data, /* Pointer to the data */ - int length); /* Length of the data. For - * strings it includes the - * trailing 0 */ -/* Push item */ +/** + * @brief Push value of any type to the stack. + * + * @param[in] stack Stack object. + * @param[in] property Name of the property.<br> + * Name should consist of the ASCII characters + * with codes non less than space. + * Exclamation mark character is + * a special character and can't be used + * in name of collection or property.<br> + * Maximum allowed length is defined at compile time. + * The default value is 64k. + * @param[in] type Type to use. + * @param[in] data Data to add. + * @param[in] length Length of the data. + * + * @return 0 - Property was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid characters in the property name. + * Value argument is invalid in some way. + * @return EMSGSIZE - Property name is too long. + * + */ +int col_push_any_property(struct collection_item *stack, + const char *property, + int type, + void *data, + int length); + +/** + * @brief Push item into the stack. + * + * @param[in] stack Stack object. + * @param[in] item Item to push. + * + * @return 0 - Item was pushed successfully. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + */ + int col_push_item(struct collection_item *stack, struct collection_item *item); -/* Pop item */ +/** + * @brief Pop item from the stack. + * + * @param[in] stack Stack object. + * @param[out] item Variable receives the value + * of the retrieved item. + * Will be set to NULL if there are + * no more items in the stack. + * + * @return 0 - No internal issues detected. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + */ int col_pop_item(struct collection_item *stack, struct collection_item **item); diff --git a/common/collection/collection_tools.h b/common/collection/collection_tools.h index 55770c6e..eec91caf 100644 --- a/common/collection/collection_tools.h +++ b/common/collection/collection_tools.h @@ -25,27 +25,59 @@ #include "collection.h" +/** + * @defgroup tools TOOLS interface + * + * Additional functions retaed to tracing, + * printing, debugging and serializaing collections. + * + * Functions in this module are more a sample implementation + * than a part of the interface. There is a chance they will + * change over time. + * + * @{ + */ + #ifdef HAVE_TRACE #define COL_DEBUG_COLLECTION(collection) col_debug_collection(collection,COL_TRAVERSE_DEFAULT); #else #define COL_DEBUG_COLLECTION(collection) ; #endif +/** @brief Name used for string type. */ #define COL_TYPE_NAME_STRING "string" +/** @brief Name used for binary type. */ #define COL_TYPE_NAME_BINARY "bin" +/** @brief Name used for integer type. */ #define COL_TYPE_NAME_INTEGER "int" +/** @brief Name used for unsigned integer type. */ #define COL_TYPE_NAME_UNSIGNED "uint" +/** @brief Name used for long type. */ #define COL_TYPE_NAME_LONG "long" +/** @brief Name used for unsigned long type. */ #define COL_TYPE_NAME_ULONG "ulong" +/** @brief Name used for floating point type. */ #define COL_TYPE_NAME_DOUBLE "double" +/** @brief Name used for boolean type. */ #define COL_TYPE_NAME_BOOL "bool" +/** @brief Name used for unknown type. */ #define COL_TYPE_NAME_UNKNOWN "unknown" +/** @brief Literal used in the default serialization. */ #define TEXT_COLLECTION "SET" +/** @brief Length of the \ref TEXT_COLLECTION literal. */ #define TEXT_COLLEN 3 +/** + * @brief The data will be allocated in BLOCK_SIZE + * blocks during serialization. + */ #define BLOCK_SIZE 1024 +/** + * @struct col_serial_data + * @brief Structure is used to incrementaly serialize collection. + */ struct col_serial_data { char *buffer; int size; @@ -54,16 +86,58 @@ struct col_serial_data { }; -/* Calculate the potential size of the item */ +/** + * @brief Calculate the potential size of the item. + * + * @param[in] type Type of the value. + * @param[in] length Length of the value. + * + * @return Maximum length the value would occupy when serialized. + */ int col_get_data_len(int type, int length); -/* Grow buffer to accomodate more space */ +/** + * @brief Grow serialization buffer. + * + * @param[in] buf_data Serialization object. + * @param[in] len For how much the serialization storage + * should be incrementally increased. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + */ int col_grow_buffer(struct col_serial_data *buf_data, int len); -/* Specail function to add different formatting symbols to the output */ -int col_put_marker(struct col_serial_data *buf_data, const void *data, int len); +/** + * @brief Add special data to the serialization output. + * + * @param[in] buf_data Serialization object. + * @param[in] data Pointer to special data. + * @param[in] len Length of the data to insert. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + */ +int col_put_marker(struct col_serial_data *buf_data, + const void *data, int len); -/* Serialization of data user handler */ +/** + * @brief Serialization of data callback. + * + * @param[in] property_in Property to serialize. + * @param[in] property_len_in Length of the property to serialize. + * @param[in] type Type of the value. + * @param[in] data_in Value to serialize. + * @param[in] length_in Length of the value. + * @param[in] custom_data State data passed to callback. + * It is actually a serialization object. + * @param[in] dummy Not used. It is here because + * the callback needs to comply + * to the functions signature. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + */ int col_serialize(const char *property_in, int property_len_in, int type, @@ -72,7 +146,22 @@ int col_serialize(const char *property_in, void *custom_data, int *dummy); -/* Debug handle */ +/** + * @brief Debug property callback. + * + * @param[in] property Property to debug. + * @param[in] property_len Length of the property to debug. + * @param[in] type Type of the value. + * @param[in] data Value to serialize. + * @param[in] length Length of the value. + * @param[in] custom_data State data passed to the callback. + * @param[in] dummy Not used. It is here because + * the callback needs to comply + * to the functions signature. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + */ int col_debug_handle(const char *property, int property_len, int type, @@ -81,26 +170,99 @@ int col_debug_handle(const char *property, void *custom_data, int *dummy); -/* Convenience function to debug an item */ +/** + * @brief Convenience function to debug an item. + * + * Prints item internals. + * + * @param[in] item Item to print. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + */ int col_debug_item(struct collection_item *item); -/* Print collection for debugging purposes */ -int col_debug_collection(struct collection_item *handle,int flag); +/** + * @brief Print collection for debugging purposes. + * + * Prints collection internals. + * + * @param[in] handle Collection to debug. + * @param[in] flag See traverse flags. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + */ +int col_debug_collection(struct collection_item *handle, + int flag); -/* Print the collection using default serialization */ +/** + * @brief Print collection data. + * + * Prints collection data. + * Uses traverse function to iterate through + * the collection. + * + * @param[in] handle Collection to print. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + */ int col_print_collection(struct collection_item *handle); -/* Print the collection using iterator */ +/** + * @brief Print collection data. + * + * Prints collection data. + * Uses iterator to process the collection. + * + * @param[in] handle Collection to print. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + */ int col_print_collection2(struct collection_item *handle); - -/* Find and print one item using default serialization */ +/** + * @brief Find and print one property. + * + * Prints item data. + * + * @param[in] handle Collection to search. + * @param[in] name Item to find and print. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + */ int col_print_item(struct collection_item *handle, const char *name); -/* Convert collection to list of properties */ -char **col_collection_to_list(struct collection_item *handle, int *size, int *error); +/** + * @brief Convert collection to the array of properties. + * + * @param[in] handle Collection to convert. + * @param[in] size Will receive the number of + * the strings in the array. + * Can be NULL if caller is not interested + * in the size of the array. + * @param[in] error Will receive error value if any. + * Can be NULL if the caller does + * not care about error codes. + * - 0 - Success. + * - ENOMEM - No memory. + * + * @return List of strings that constitute + * the properties in the collection. + * Collection name is not included. + */ +char **col_collection_to_list(struct collection_item *handle, + int *size, + int *error); -/* Function to free the list of properties. */ +/** + * @brief Free list of properties. + * + * @param[in] str_list List to free. + */ void col_free_property_list(char **str_list); #endif diff --git a/common/collection/configure.ac b/common/collection/configure.ac index 2ec6c019..25aba162 100644 --- a/common/collection/configure.ac +++ b/common/collection/configure.ac @@ -1,4 +1,6 @@ -AC_INIT([collection],[0.4.0],[sssd-devel@lists.fedorahosted.org]) +AC_INIT([collection], + [0.4.0], + [sssd-devel@lists.fedorahosted.org]) AC_CONFIG_SRCDIR([collection.c]) AC_CONFIG_AUX_DIR([build]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) @@ -32,6 +34,9 @@ AC_CHECK_FUNC([strcasestr], AC_DEFINE([COL_MAX_DATA], [65535], [Max length of the data block allowed in the collection value.]) +AC_PATH_PROG([DOXYGEN], [doxygen], [false]) +AM_CONDITIONAL([HAVE_DOXYGEN], [test x$DOXYGEN != xfalse ]) -AC_CONFIG_FILES([Makefile collection.pc]) + +AC_CONFIG_FILES([Makefile collection.cfg.doxy collection.pc]) AC_OUTPUT |