utf16_throw_if_error.cpp 841 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/utf16/status.h>
  5. #include<__vic/utf16/exceptions.h>
  6. #include<__vic/error.h>
  7. #include<__vic/string_buffer.h>
  8. namespace __vic { namespace utf16 {
  9. //----------------------------------------------------------------------------
  10. bool throw_if_error(status_t st)
  11. {
  12. switch(st)
  13. {
  14. case status::ok: return true;
  15. case status::eof: return false;
  16. case status::truncated_code_unit: throw truncated_code_unit();
  17. case status::truncated_code_point: throw truncated_code_point();
  18. case status::invalid_sequence: throw invalid_sequence();
  19. }
  20. // Must never happen
  21. throw __vic::exception(__vic::msg(64) <<
  22. "Unexpected utf16::status value " << static_cast<int>(st));
  23. }
  24. //------------------------------------------------------------------------------
  25. }} // namespace