strfunc.h 656 B

123456789101112131415161718192021222324
  1. #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_
  2. #define RAPIDJSON_INTERNAL_STRFUNC_H_
  3. namespace rapidjson {
  4. namespace internal {
  5. //! Custom strlen() which works on different character types.
  6. /*! \tparam Ch Character type (e.g. char, wchar_t, short)
  7. \param s Null-terminated input string.
  8. \return Number of characters in the string.
  9. \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints.
  10. */
  11. template <typename Ch>
  12. inline SizeType StrLen(const Ch* s) {
  13. const Ch* p = s;
  14. while (*p != '\0')
  15. ++p;
  16. return SizeType(p - s);
  17. }
  18. } // namespace internal
  19. } // namespace rapidjson
  20. #endif // RAPIDJSON_INTERNAL_STRFUNC_H_