Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of libdom.
  3.  * Licensed under the MIT License,
  4.  *                      http://www.opensource.org/licenses/mit-license.php
  5.  * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
  6.  *
  7.  * This file contains the API used to validate whether certain character in
  8.  * name/value is legal according the XML 1.0 standard. See
  9.  *
  10.  * http://www.w3.org/TR/2004/REC-xml-20040204/
  11.  * http://www.w3.org/TR/REC-xml/
  12.  *
  13.  * for detail.
  14.  */
  15.  
  16. #ifndef dom_utils_character_valid_h_
  17. #define dom_utils_character_valid_h_
  18.  
  19. #include <stdbool.h>
  20. #include <stdlib.h>
  21.  
  22. struct xml_char_range {
  23.         unsigned int start;
  24.         unsigned int end;
  25. };
  26.  
  27. struct xml_char_group {
  28.         size_t len;
  29.         const struct xml_char_range *range;
  30. };
  31.  
  32. /* The groups */
  33. extern const struct xml_char_group base_char_group;
  34. extern const struct xml_char_group char_group;
  35. extern const struct xml_char_group combining_char_group;
  36. extern const struct xml_char_group digit_char_group;
  37. extern const struct xml_char_group extender_group;
  38. extern const struct xml_char_group ideographic_group;
  39.  
  40. bool _dom_is_character_in_group(unsigned int ch,
  41.                 const struct xml_char_group *group);
  42.  
  43. #define is_base_char(ch) _dom_is_character_in_group((ch), &base_char_group)
  44. #define is_char(ch) _dom_is_character_in_group((ch), &char_group)
  45. #define is_combining_char(ch) _dom_is_character_in_group((ch), \
  46.                 &combining_char_group)
  47. #define is_digit(ch) _dom_is_character_in_group((ch), &digit_char_group)
  48. #define is_extender(ch) _dom_is_character_in_group((ch), &extender_group)
  49. #define is_ideographic(ch) _dom_is_character_in_group((ch), &ideographic_group)
  50.  
  51. #define is_letter(ch)  (is_base_char(ch) || is_ideographic(ch))
  52.  
  53. #endif
  54.  
  55.