From 5877be91301e5dd54ca125c0acd7bfb1ecc3dcd6 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 16 Dec 2015 20:35:54 +0000 Subject: No-op; remove trailing whitespace. --- src/stl_binary_tables.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/stl_binary_tables.cc') diff --git a/src/stl_binary_tables.cc b/src/stl_binary_tables.cc index 9aaf4b8..f843421 100644 --- a/src/stl_binary_tables.cc +++ b/src/stl_binary_tables.cc @@ -84,7 +84,7 @@ description_to_enum (string d, map > const & m) return boost::optional (); } - + DisplayStandard STLBinaryTables::display_standard_file_to_enum (string s) const { @@ -150,13 +150,13 @@ STLBinaryTables::comment_enum_to_file (Comment v) const { return enum_to_file (v, _comment_map); } - + string STLBinaryTables::display_standard_enum_to_description (DisplayStandard v) const { return enum_to_description (v, _display_standard_map); } - + string STLBinaryTables::language_group_enum_to_description (LanguageGroup v) const { @@ -205,13 +205,13 @@ STLBinaryTables::STLBinaryTables () code (_display_standard_map, "0", DISPLAY_STANDARD_OPEN_SUBTITLING, "Open subtitling"); code (_display_standard_map, "1", DISPLAY_STANDARD_LEVEL_1_TELETEXT, "Level 1 teletext"); code (_display_standard_map, "2", DISPLAY_STANDARD_LEVEL_2_TELETEXT, "Level 2 teletext"); - + code (_language_group_map, "00", LANGUAGE_GROUP_LATIN, "Latin"); code (_language_group_map, "01", LANGUAGE_GROUP_LATIN_CYRILLIC, "Latin/Cyrillic"); code (_language_group_map, "02", LANGUAGE_GROUP_LATIN_ARABIC, "Latin/Arabic"); code (_language_group_map, "03", LANGUAGE_GROUP_LATIN_GREEK, "Latin/Greek"); code (_language_group_map, "04", LANGUAGE_GROUP_LATIN_HEBREW, "Latin/Hebrew"); - + code (_language_map, "00", LANGUAGE_UNKNOWN, "Unknown"); code (_language_map, "01", LANGUAGE_ALBANIAN, "Albanian"); code (_language_map, "02", LANGUAGE_BRETON, "Breton"); -- cgit v1.2.3 From 5a843c4c224051237105a6e8de472ae9a216c001 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 16 Dec 2015 20:40:21 +0000 Subject: Replace use of cassert with exceptions. --- src/exceptions.cc | 30 ++++++++++++++++++++++++++++++ src/exceptions.h | 6 ++++++ src/stl_binary_tables.cc | 4 ++-- src/stl_binary_writer.cc | 31 ++++++++++++++++--------------- src/sub_assert.h | 22 ++++++++++++++++++++++ src/wscript | 1 + 6 files changed, 77 insertions(+), 17 deletions(-) create mode 100644 src/exceptions.cc create mode 100644 src/sub_assert.h (limited to 'src/stl_binary_tables.cc') diff --git a/src/exceptions.cc b/src/exceptions.cc new file mode 100644 index 0000000..f33a1e2 --- /dev/null +++ b/src/exceptions.cc @@ -0,0 +1,30 @@ +/* + Copyright (C) 2014-2015 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "compose.hpp" +#include "exceptions.h" + +using std::string; +using namespace sub; + +ProgrammingError::ProgrammingError (string file, int line) + : MessageError (String::compose ("Programming error at %1:%2", file, line)) +{ + +} diff --git a/src/exceptions.h b/src/exceptions.h index 62be0d5..5995942 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -99,6 +99,12 @@ public: {} }; +class ProgrammingError : public MessageError +{ +public: + ProgrammingError (std::string file, int line); +}; + } #endif diff --git a/src/stl_binary_tables.cc b/src/stl_binary_tables.cc index f843421..db623bf 100644 --- a/src/stl_binary_tables.cc +++ b/src/stl_binary_tables.cc @@ -19,8 +19,8 @@ #include "stl_binary_tables.h" #include "exceptions.h" +#include "sub_assert.h" #include "compose.hpp" -#include using std::map; using std::string; @@ -55,7 +55,7 @@ enum_to_file (E k, map > m) } } - assert (false); + SUB_ASSERT (false); return F (); } diff --git a/src/stl_binary_writer.cc b/src/stl_binary_writer.cc index b9bd7e0..aa8943c 100644 --- a/src/stl_binary_writer.cc +++ b/src/stl_binary_writer.cc @@ -26,6 +26,7 @@ #include "iso6937.h" #include "stl_util.h" #include "compose.hpp" +#include "sub_assert.h" #include #include #include @@ -62,7 +63,7 @@ put_string (char* p, string s) static void put_string (char* p, unsigned int n, string s) { - assert (s.length() <= n); + SUB_ASSERT (s.length() <= n); memcpy (p, s.c_str (), s.length ()); memset (p + s.length(), ' ', n - s.length ()); @@ -76,7 +77,7 @@ put_int_as_string (char* p, int v, unsigned int n) s.imbue (std::locale::classic ()); s << setw (n) << setfill ('0'); s << v; - assert (s.str().length() == n); + SUB_ASSERT (s.str().length() == n); put_string (p, s.str ()); } @@ -110,19 +111,19 @@ sub::write_stl_binary ( boost::filesystem::path file_name ) { - assert (original_programme_title.size() <= 32); - assert (original_episode_title.size() <= 32); - assert (translated_programme_title.size() <= 32); - assert (translated_episode_title.size() <= 32); - assert (translator_name.size() <= 32); - assert (translator_contact_details.size() <= 32); - assert (creation_date.size() == 6); - assert (revision_date.size() == 6); - assert (revision_number <= 99); - assert (country_of_origin.size() == 3); - assert (publisher.size() <= 32); - assert (editor_name.size() <= 32); - assert (editor_contact_details.size() <= 32); + SUB_ASSERT (original_programme_title.size() <= 32); + SUB_ASSERT (original_episode_title.size() <= 32); + SUB_ASSERT (translated_programme_title.size() <= 32); + SUB_ASSERT (translated_episode_title.size() <= 32); + SUB_ASSERT (translator_name.size() <= 32); + SUB_ASSERT (translator_contact_details.size() <= 32); + SUB_ASSERT (creation_date.size() == 6); + SUB_ASSERT (revision_date.size() == 6); + SUB_ASSERT (revision_number <= 99); + SUB_ASSERT (country_of_origin.size() == 3); + SUB_ASSERT (publisher.size() <= 32); + SUB_ASSERT (editor_name.size() <= 32); + SUB_ASSERT (editor_contact_details.size() <= 32); char* buffer = new char[1024]; memset (buffer, 0, 1024); diff --git a/src/sub_assert.h b/src/sub_assert.h new file mode 100644 index 0000000..67c8abe --- /dev/null +++ b/src/sub_assert.h @@ -0,0 +1,22 @@ +/* + Copyright (C) 2014 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "exceptions.h" + +#define SUB_ASSERT(x) if (!(x)) throw ProgrammingError (__FILE__, __LINE__); diff --git a/src/wscript b/src/wscript index a054a91..eafd1c9 100644 --- a/src/wscript +++ b/src/wscript @@ -15,6 +15,7 @@ def build(bld): colour.cc dcp_reader.cc effect.cc + exceptions.cc font_size.cc interop_dcp_reader.cc iso6937.cc -- cgit v1.2.3