This is an automated email from the ASF dual-hosted git repository. bneradt pushed a commit to branch doc-lexicon in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit b69ecd7506ce95845b1de91d2d29d59380475e8d Author: Alan M. Carroll <a...@apache.org> AuthorDate: Tue May 19 10:42:15 2020 -0500 Initial pass. --- code/CMakeLists.txt | 2 +- doc/code/Lexicon.en.rst | 12 +++++++++++- unit_tests/CMakeLists.txt | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index e4608df..60a3916 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -48,7 +48,7 @@ add_library(libswoc STATIC ${CC_FILES}) target_compile_options(libswoc PRIVATE -Wall -Wextra -Werror -Wnon-virtual-dtor -Wpedantic) # Not quite sure how this works, but I think it generates one of two paths depending on the context. -# That is, the generator functions return non-empty strings only in the corresponding context. +# That is, the generator functions return non-empty stri ngs only in the corresponding context. target_include_directories(libswoc PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> diff --git a/doc/code/Lexicon.en.rst b/doc/code/Lexicon.en.rst index 6fcea5b..a554a2d 100644 --- a/doc/code/Lexicon.en.rst +++ b/doc/code/Lexicon.en.rst @@ -23,7 +23,13 @@ Lexicon **************** |Lexicon| is a bidirectional mapping between strings and a numeric / enumeration type. It is intended -to support parsing and diagnostics for enumerations. +to support parsing and diagnostics for enumerations. It has some significant advantages over a simple +array of strings. + +* The integer can be looked up by string. This makes parsing much easier and more robust. +* The integers do not have to be contiguous or zero based. +* Multiple names can map to the same integer. +* Defaults for missing names or integers. Definition ********** @@ -35,10 +41,14 @@ Definition Usage ***** +Lexicons can be used in a dynamic or static fashion. The basic use is as a static translation object +that converts between an enumeration and names. The constructors allow setting up the entire Lexicon. Examples ======== + + Design Notes ************ diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index e71c71e..a4295be 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -22,6 +22,7 @@ add_executable(test_libswoc ex_bw_format.cc ex_IntrusiveDList.cc ex_ipspace_properties.cc + ex_Lexicon.cc ex_MemArena.cc ex_TextView.cc )