Skip to content

Commit

Permalink
Minor tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martinho Fernandes committed Aug 30, 2012
1 parent 657d3c9 commit 4bdc733
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions include/ogonek/text.h++
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace ogonek {
validated(Range const& range, ValidationCallback&& callback) {
for(auto&& _ : EncodingForm::decode(range, std::forward<ValidationCallback>(callback))) {
(void)_;
// TODO this is *wrong*
// do nothing, just consume the input
}
}
Expand All @@ -55,6 +56,9 @@ namespace ogonek {
using IteratorValueType = typename std::iterator_traits<Iterator>::value_type;
template <typename Range>
using RangeValueType = typename boost::range_value<Range>::type;

template <typename Range, typename Value>
struct is_range_of : std::is_same<RangeValueType<Range>, Value> {};
} // namespace detail

template <typename EncodingForm, typename Container = std::basic_string<CodeUnit<EncodingForm>>>
Expand All @@ -68,6 +72,7 @@ namespace ogonek {
public:
//** Constructors **

// -- basic
//! Empty string
basic_text() = default;

Expand All @@ -77,6 +82,7 @@ namespace ogonek {
basic_text& operator=(basic_text const&) = default;
basic_text& operator=(basic_text&&) = default;

// -- codepoints
//! Construct from a null-terminated codepoint string (intended for UTF-32 literals)
basic_text(codepoint const* literal)
: basic_text(literal, throw_validation_error) {}
Expand All @@ -100,14 +106,12 @@ namespace ogonek {
"Can only construct text from a range of codepoints");
}

// -- code units

// -- storage
//! Construct from an underlying container
explicit basic_text(Container storage)
: basic_text(std::move(storage), throw_validation_error) {}

//! Construct from an underlying container, with validation callback
template <typename ValidationCallback>
basic_text(Container storage, ValidationCallback&& callback)
: detail::validated<EncodingForm>(storage, std::forward<ValidationCallback>(callback)),
: detail::validated<EncodingForm>(storage, throw_validation_error),
storage_(std::move(storage)) {}

//** Range **
Expand Down
2 changes: 1 addition & 1 deletion include/ogonek/validation.h++
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace ogonek {
valid, unassigned, illegal, irregular,
};

struct validation_error : std::exception {
struct validation_error : std::exception { // TODO Boost.Exception
char const* what() const throw() override {
return "Unicode validation failed";
}
Expand Down

0 comments on commit 4bdc733

Please sign in to comment.