TransactionType
transaction_type_from_verb(wxString const& p_phrase)
{
    typedef map<wxString, TransactionType> Dict;
    static Dict dict;
    static bool calculated_already = false;
    if (!calculated_already)
    {
        JEWEL_ASSERT (dict.empty());
        dict[expenditure_verb()] = TransactionType::expenditure;
        dict[revenue_verb()] = TransactionType::revenue;
        dict[balance_sheet_verb()] = TransactionType::balance_sheet;
        dict[envelope_verb()] = TransactionType::envelope;
        dict[generic_verb()] = TransactionType::generic;
        calculated_already = true;
    }
    JEWEL_ASSERT (!dict.empty());
    JEWEL_ASSERT
    (   dict.size() ==
        static_cast<Dict::size_type>(TransactionType::num_transaction_types)
    );
    Dict::const_iterator const it = dict.find(p_phrase);
    if (it == dict.end())
    {
        JEWEL_THROW
        (   InvalidTransactionTypeException,
            "wxString passed to transaction_type_from_verb does not "
            "correspond to any TransactionType."
        );
    }
    JEWEL_ASSERT (it != dict.end());
    return it->second;
}
Ejemplo n.º 2
0
	bool build(Dict &_front, Dict &_back, Dict &dict, Tree &tree, bool flag)
	{
		if (_front.empty()) return false;
		if (_front.size() > _back.size())
			return build(_back, _front, dict, tree, !flag);
		for (auto &word : _front) dict.erase(word);
		for (auto &word : _back) dict.erase(word);
		Dict hoge;
		bool piyo = false;
		for (auto &i : _front)
		{
			string word = i;
			for (auto &c : word)
			{
				char fuga = c;
				for (c = 'a'; c <= 'z'; c++)
				{
					if (c == fuga) continue;
					if (_back.count(word))
					{
						piyo = true;
						!flag ? tree[i].push_back(word): tree[word].push_back(i);
					}
					else if (!piyo && dict.count(word))
					{
						hoge.insert(word);
						!flag ? tree[i].push_back(word): tree[word].push_back(i);
					}
				}
				c = fuga;
			}
		}
		return piyo || build(hoge, _back, dict, tree, flag);
	}
Ejemplo n.º 3
0
LLBC_Variant::LLBC_Variant(const Dict &dictVal)
{
    _holder.type = LLBC_VariantType::VT_DICT_DFT;
    if (!dictVal.empty())
    {
        _holder.dict= new Dict();
        _holder.dict->insert(dictVal.begin(), dictVal.end());
    }
}