Browse Source

Support mapping a General Category to a General Category Group.

master
Reece H. Dunn 12 years ago
parent
commit
349e225aae
3 changed files with 21 additions and 4 deletions
  1. 7
    2
      src/categories.cpp
  2. 7
    0
      src/include/ucd/ucd.h
  3. 7
    2
      tools/categories.py

+ 7
- 2
src/categories.cpp View File

return Ii; // Invalid Unicode Codepoint return Ii; // Invalid Unicode Codepoint
} }


ucd::category_group ucd::lookup_category_group(codepoint_t c)
ucd::category_group ucd::lookup_category_group(category c)
{ {
switch (lookup_category(c))
switch (c)
{ {
case Cc: case Cf: case Cn: case Co: case Cs: case Cc: case Cf: case Cn: case Co: case Cs:
return C; return C;
return I; return I;
} }
} }

ucd::category_group ucd::lookup_category_group(codepoint_t c)
{
return lookup_category_group(lookup_category(c));
}

+ 7
- 0
src/include/ucd/ucd.h View File

Zs, /**< @brief Space Separator */ Zs, /**< @brief Space Separator */
}; };


/** @brief Lookup the General Category Group for a General Category.
*
* @param c The General Category to lookup.
* @return The General Category Group of the General Category.
*/
category_group lookup_category_group(category c);

/** @brief Lookup the General Category Group for a Unicode codepoint. /** @brief Lookup the General Category Group for a Unicode codepoint.
* *
* @param c The Unicode codepoint to lookup. * @param c The Unicode codepoint to lookup.

+ 7
- 2
tools/categories.py View File

sys.stdout.write('}\n') sys.stdout.write('}\n')


sys.stdout.write(""" sys.stdout.write("""
ucd::category_group ucd::lookup_category_group(codepoint_t c)
ucd::category_group ucd::lookup_category_group(category c)
{ {
switch (lookup_category(c))
switch (c)
{ {
case Cc: case Cf: case Cn: case Co: case Cs: case Cc: case Cf: case Cn: case Co: case Cs:
return C; return C;
return I; return I;
} }
} }

ucd::category_group ucd::lookup_category_group(codepoint_t c)
{
return lookup_category_group(lookup_category(c));
}
""") """)

Loading…
Cancel
Save