Beispiel #1
0
		inline IntType
		string_to_int_dynamic(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx, int base = 10) {
			Elem* endptr = nullptr;
			IntType result = sprout::detail::str_to_int<IntType>(str.c_str(), &endptr, base);
			*idx = endptr - str.c_str();
			return result;
		}
Beispiel #2
0
	inline SPROUT_CONSTEXPR sprout::basic_string<T, N1 + N2, Traits>
	operator+(sprout::basic_string<T, N1, Traits> const& lhs, sprout::basic_string<T, N2, Traits> const& rhs) {
		return sprout::detail::string_concat(
			lhs, lhs.size(),
			rhs, rhs.size(),
			sprout::make_index_tuple<N1 + N2>::make()
			);
	}
Beispiel #3
0
	inline SPROUT_CONSTEXPR sprout::basic_string<T, (M - 1) + N, Traits>
	operator+(T const (& lhs)[M], sprout::basic_string<T, N, Traits> const& rhs) {
		return sprout::detail::string_concat(
			lhs, sprout::char_traits<T>::length(lhs),
			rhs, rhs.size(),
			sprout::index_range<0, (M - 1) + N>::make()
			);
	}
Beispiel #4
0
	inline SPROUT_CONSTEXPR sprout::basic_string<T, N, Traits>
	operator>>(sprout::basic_string<T, N, Traits> const& lhs, T const* rhs) {
		return sprout::detail::string_lshift(
			lhs, lhs.size(),
			rhs, Traits::length(rhs),
			sprout::make_index_tuple<N>::make()
			);
	}
Beispiel #5
0
	inline SPROUT_CONSTEXPR sprout::basic_string<T, 1 + N, Traits>
	operator+(T const& lhs, sprout::basic_string<T, N, Traits> const& rhs) {
		return sprout::detail::string_concat(
			lhs,
			rhs, rhs.size(),
			sprout::index_range<0, 1 + N>::make()
			);
	}
Beispiel #6
0
	inline SPROUT_INITIALIZER_LIST_CONSTEXPR sprout::basic_string<T, N, Traits>
	operator>>(sprout::basic_string<T, N, Traits> const& lhs, std::initializer_list<T> rhs) {
		return sprout::detail::string_lshift(
			lhs, lhs.size(),
			rhs, rhs.size(),
			sprout::make_index_tuple<N>::make()
			);
	}
Beispiel #7
0
	inline SPROUT_CONSTEXPR sprout::basic_string<T, (M - 1) + N, Traits>
	operator+(T const (& lhs)[M], sprout::basic_string<T, N, Traits> const& rhs) {
		typedef sprout::char_traits_helper<Traits> traits_type;
		return sprout::detail::string_concat(
			lhs, traits_type::length(lhs, M - 1),
			rhs, rhs.size(),
			sprout::make_index_tuple<(M - 1) + N>::make()
			);
	}
Beispiel #8
0
	inline SPROUT_NON_CONSTEXPR std::basic_istream<T, StreamTraits>&
	operator>>(std::basic_istream<T, StreamTraits>& lhs, sprout::basic_string<T, N, Traits>& rhs) {
		typedef T elem_type;
		typedef StreamTraits traits_type;
		typedef std::basic_istream<T, StreamTraits> istream_type;
		typedef sprout::basic_string<T, N, Traits> string_type;
		typedef std::ctype<elem_type> ctype_type;
		typedef typename string_type::size_type size_type;
		std::ios_base::iostate state = std::ios_base::goodbit;
		bool changed = false;
		size_type current = 0;
		if (typename istream_type::sentry(lhs)) {
			ctype_type const& ctype_fac = std::use_facet<ctype_type>(lhs.getloc());
			try {
				size_type remain = 0 < lhs.width() && static_cast<size_type>(lhs.width()) < rhs.max_size()
					? static_cast<size_type>(lhs.width())
					: rhs.max_size()
					;
				typename traits_type::int_type meta = lhs.rdbuf()->sgetc();
				for (; remain; --remain, meta = lhs.rdbuf()->snextc())
					if (traits_type::eq_int_type(traits_type::eof(), meta)) {
						state |= std::ios_base::eofbit;
						break;
					} else if (ctype_fac.is(ctype_type::space, traits_type::to_char_type(meta))) {
						break;
					} else {
						rhs[current] = traits_type::to_char_type(meta);
						changed = true;
						++current;
					}
			} catch (...) {
				state |= std::ios_base::badbit;
			}
		}
		lhs.width(0);
		if (!changed) {
			state |= std::ios_base::failbit;
		}
		lhs.setstate(state);
		rhs.resize(current);
		return lhs;
	}
		inline FloatType string_to_float_dynamic(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx) {
			Elem* endptr = nullptr;
			FloatType result = sprout::detail::str_to_float<FloatType>(str.c_str(), &endptr);
			*idx = endptr - str.c_str();
			return result;
		}
Beispiel #10
0
	inline SPROUT_CONSTEXPR IntType
	string_to_int(sprout::basic_string<Elem, N, Traits> const& str, int base = 10) {
		return sprout::detail::str_to_int<IntType>(str.begin(), base);
	}
Beispiel #11
0
	inline SPROUT_CONSTEXPR IntType
	string_to_int(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx, int base = 10) {
		return !idx ? sprout::detail::str_to_int<IntType>(str.begin(), base)
			: sprout::detail::string_to_int_dynamic<IntType>(str, idx, base)
			;
	}
Beispiel #12
0
	inline SPROUT_CONSTEXPR bool
	operator<(sprout::basic_string<T, N, Traits> const& lhs, T const* rhs) {
		return lhs.compare(rhs) < 0;
	}
Beispiel #13
0
	inline SPROUT_CONSTEXPR bool
	operator==(sprout::basic_string<T, N1, Traits> const& lhs, sprout::basic_string<T, N2, Traits> const& rhs) {
		return lhs.compare(rhs) == 0;
	}
Beispiel #14
0
	inline SPROUT_CONSTEXPR std::size_t hash_value(sprout::basic_string<T, N, Traits> const& v) {
		return sprout::hash_range(v.begin(), v.end());
	}
Beispiel #15
0
	inline SPROUT_CONSTEXPR FloatType
	string_to_float(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx) {
		return !idx ? sprout::detail::str_to_float<FloatType>(str.begin())
			: sprout::detail::string_to_float_dynamic<FloatType>(str, idx)
			;
	}
Beispiel #16
0
	inline SPROUT_CONSTEXPR FloatType
	string_to_float(sprout::basic_string<Elem, N, Traits> const& str) {
		return sprout::detail::str_to_float<FloatType>(str.begin());
	}
Beispiel #17
0
	inline SPROUT_CONSTEXPR bool
	operator<(T const* lhs, sprout::basic_string<T, N, Traits> const& rhs) {
		return 0 < rhs.compare(lhs);
	}