From b45cf54f4d426947fe4fdcacd2280f8ca228fc8f Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Mon, 30 May 2016 23:12:03 +0100 Subject: [PATCH] Convert tostring.cpp from C++ to C. --- Makefile.am | 3 +- src/include/ucd/ucd.h | 15 ++++-- src/{tostring.cpp => tostring.c} | 93 ++++++++++++++------------------ 3 files changed, 52 insertions(+), 59 deletions(-) rename src/{tostring.cpp => tostring.c} (66%) diff --git a/Makefile.am b/Makefile.am index 787b967f..64dbc31e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -103,13 +103,12 @@ libucd_include_HEADERS = \ lib_LTLIBRARIES += src/libucd.la src_libucd_la_LDFLAGS = -version-info $(LIBUCD_VERSION) -src_libucd_la_CXXFLAGS = ${AM_CXXFLAGS} src_libucd_la_SOURCES = \ src/case.cpp \ src/categories.cpp \ src/ctype.cpp \ src/scripts.cpp \ - src/tostring.cpp + src/tostring.c ############################# tests ########################################### diff --git a/src/include/ucd/ucd.h b/src/include/ucd/ucd.h index aedec89a..04702b74 100644 --- a/src/include/ucd/ucd.h +++ b/src/include/ucd/ucd.h @@ -458,7 +458,10 @@ namespace ucd * * @return The string representation, or "-" if the value is not recognized. */ - const char *get_category_group_string(category_group c); + inline const char *get_category_group_string(category_group c) + { + return ucd_get_category_group_string((ucd_category_group)c); + } /** @brief Unicode General Category Values * @see http://www.unicode.org/reports/tr44/ @@ -511,7 +514,10 @@ namespace ucd * * @return The string representation, or "--" if the value is not recognized. */ - const char *get_category_string(category c); + inline const char *get_category_string(category c) + { + return ucd_get_category_string((ucd_category)c); + } /** @brief Lookup the General Category Group for a General Category. * @@ -716,7 +722,10 @@ namespace ucd * * @return The string representation, or "----" if the value is not recognized. */ - const char *get_script_string(script s); + inline const char *get_script_string(script s) + { + return ucd_get_script_string((ucd_script)s); + } /** @brief Lookup the Script for a Unicode codepoint. * diff --git a/src/tostring.cpp b/src/tostring.c similarity index 66% rename from src/tostring.cpp rename to src/tostring.c index c1dd8c2c..d22b0f85 100644 --- a/src/tostring.cpp +++ b/src/tostring.c @@ -21,76 +21,61 @@ #include "ucd/ucd.h" const char *ucd_get_category_group_string(ucd_category_group c) -{ - return ucd::get_category_group_string((ucd::category_group)c); -} - -const char *ucd::get_category_group_string(category_group c) { switch (c) { - case C: return "C"; - case I: return "I"; - case L: return "L"; - case M: return "M"; - case N: return "N"; - case P: return "P"; - case S: return "S"; - case Z: return "Z"; + case UCD_CATEGORY_GROUP_C: return "C"; + case UCD_CATEGORY_GROUP_I: return "I"; + case UCD_CATEGORY_GROUP_L: return "L"; + case UCD_CATEGORY_GROUP_M: return "M"; + case UCD_CATEGORY_GROUP_N: return "N"; + case UCD_CATEGORY_GROUP_P: return "P"; + case UCD_CATEGORY_GROUP_S: return "S"; + case UCD_CATEGORY_GROUP_Z: return "Z"; default: return "-"; } } const char *ucd_get_category_string(ucd_category c) -{ - return ucd::get_category_string((ucd::category)c); -} - -const char *ucd::get_category_string(category c) { switch (c) { - case Cc: return "Cc"; - case Cf: return "Cf"; - case Cn: return "Cn"; - case Co: return "Co"; - case Cs: return "Cs"; - case Ii: return "Ii"; - case Ll: return "Ll"; - case Lm: return "Lm"; - case Lo: return "Lo"; - case Lt: return "Lt"; - case Lu: return "Lu"; - case Mc: return "Mc"; - case Me: return "Me"; - case Mn: return "Mn"; - case Nd: return "Nd"; - case Nl: return "Nl"; - case No: return "No"; - case Pc: return "Pc"; - case Pd: return "Pd"; - case Pe: return "Pe"; - case Pf: return "Pf"; - case Pi: return "Pi"; - case Po: return "Po"; - case Ps: return "Ps"; - case Sc: return "Sc"; - case Sk: return "Sk"; - case Sm: return "Sm"; - case So: return "So"; - case Zl: return "Zl"; - case Zp: return "Zp"; - case Zs: return "Zs"; + case UCD_CATEGORY_Cc: return "Cc"; + case UCD_CATEGORY_Cf: return "Cf"; + case UCD_CATEGORY_Cn: return "Cn"; + case UCD_CATEGORY_Co: return "Co"; + case UCD_CATEGORY_Cs: return "Cs"; + case UCD_CATEGORY_Ii: return "Ii"; + case UCD_CATEGORY_Ll: return "Ll"; + case UCD_CATEGORY_Lm: return "Lm"; + case UCD_CATEGORY_Lo: return "Lo"; + case UCD_CATEGORY_Lt: return "Lt"; + case UCD_CATEGORY_Lu: return "Lu"; + case UCD_CATEGORY_Mc: return "Mc"; + case UCD_CATEGORY_Me: return "Me"; + case UCD_CATEGORY_Mn: return "Mn"; + case UCD_CATEGORY_Nd: return "Nd"; + case UCD_CATEGORY_Nl: return "Nl"; + case UCD_CATEGORY_No: return "No"; + case UCD_CATEGORY_Pc: return "Pc"; + case UCD_CATEGORY_Pd: return "Pd"; + case UCD_CATEGORY_Pe: return "Pe"; + case UCD_CATEGORY_Pf: return "Pf"; + case UCD_CATEGORY_Pi: return "Pi"; + case UCD_CATEGORY_Po: return "Po"; + case UCD_CATEGORY_Ps: return "Ps"; + case UCD_CATEGORY_Sc: return "Sc"; + case UCD_CATEGORY_Sk: return "Sk"; + case UCD_CATEGORY_Sm: return "Sm"; + case UCD_CATEGORY_So: return "So"; + case UCD_CATEGORY_Zl: return "Zl"; + case UCD_CATEGORY_Zp: return "Zp"; + case UCD_CATEGORY_Zs: return "Zs"; default: return "--"; } } const char *ucd_get_script_string(ucd_script s) -{ - return ucd::get_script_string((ucd::script)s); -} - -const char *ucd::get_script_string(script s) { static const char *scripts[] = {