hooks_parser.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. #ifndef HOOKS_PARSER_H
  7. #define HOOKS_PARSER_H
  8. #include <cc/data.h>
  9. #include <cc/simple_parser.h>
  10. #include <hooks/hooks_config.h>
  11. namespace isc {
  12. namespace hooks {
  13. /// @brief Parser for hooks library list
  14. ///
  15. /// This parser handles the list of hooks libraries. This is an optional list,
  16. /// which may be empty, and is encapsulated into a @ref HooksConfig object.
  17. class HooksLibrariesParser : public isc::data::SimpleParser {
  18. public:
  19. /// @brief Parses parameters value
  20. ///
  21. /// Parses configuration entry (list of parameters) and adds each element
  22. /// to the hooks libraries list. The method also checks whether the
  23. /// list of libraries is the same as that already loaded. If not, it
  24. /// checks each of the libraries in the list for validity (they exist and
  25. /// have a "version" function that returns the correct value).
  26. ///
  27. /// The syntax for specifying hooks libraries allow for library-specific
  28. /// parameters to be specified along with the library, e.g.
  29. ///
  30. /// @code
  31. /// "hooks-libraries": [
  32. /// {
  33. /// "library": "hook-lib-1.so",
  34. /// "parameters": {
  35. /// "alpha": "a string",
  36. /// "beta": 42
  37. /// }
  38. /// },
  39. /// :
  40. /// ]
  41. /// @endcode
  42. ///
  43. /// The parsing code only checks that:
  44. ///
  45. /// -# Each element in the hooks-libraries list is a map
  46. /// -# The map contains an element "library" whose value is a not blank string
  47. /// -# That there is an optional 'parameters' element.
  48. /// -# That there are no other element.
  49. ///
  50. /// This method stores parsed libraries in libraries.
  51. ///
  52. /// @param libraries parsed libraries information will be stored here
  53. /// @param value pointer to the content to be parsed
  54. void parse(HooksConfig& libraries, isc::data::ConstElementPtr value);
  55. };
  56. }; // namespace isc::hooks
  57. }; // namespace isc
  58. #endif