Skip to content
Snippets Groups Projects
  • Adam Wardynski's avatar
    Const contract on function return Value. · 10144629
    Adam Wardynski authored
    Generally we want to avoid accidental change of value of a constant or of a variable. Originally I'd copy value on access, but this changed it so a const Value is returned instead and copy is done only when it's needed.
    10144629
tolower.cpp 846 B
#include <libwccl/ops/tolower.h>
#include <libwccl/ops/formatters.h>

namespace Wccl {

std::string ToLower::to_string(const Corpus2::Tagset& tagset) const
{
	return UnaryFunctionFormatter::to_string(tagset, *this, *strset_expr_);
}

std::string ToLower::to_raw_string() const {
	return UnaryFunctionFormatter::to_raw_string(*this, *strset_expr_);
}

ToLower::BaseRetValPtr ToLower::apply_internal(const FunExecContext& context) const {	
	const boost::shared_ptr<const StrSet >& set = strset_expr_->apply(context);
	boost::shared_ptr<StrSet > l_set = boost::make_shared<StrSet>();
	//TODO: should tolower be a method of StrSet as well?
	foreach(const UnicodeString& s, set->contents()) {
		//TODO: what about locale? is default ok? should the context hold it?
		l_set->insert(UnicodeString(s).toLower());
	}
	return l_set;
}

} /* end ns Wccl */