Exemple #1
0
inline ConstStringS _Find_CodePage_From_Charset(const ConstStringS& strCharset) throw()
{
	ConstArray<_Charset_CP> c_arr(g_charset_cp_map::GetAddress(), g_charset_cp_map::GetCount());
	auto iter(c_arr.GetBegin());
	for( ; iter != c_arr.GetEnd(); iter.MoveNext() ) {
		const _Charset_CP& cc = iter.get_Value();
		if( ConstStringCompareTrait<ConstStringS>::IsEQ(strCharset, ConstStringS(cc.m_charset.m_first, cc.m_charset.m_size)) ) {
			return ConstStringS(cc.m_codepage.m_first, cc.m_codepage.m_size);
		}
	}
	return ConstStringS();
}
Exemple #2
0
inline ConstStringS _Find_ShortString_From_LCID(uint uLCID, uint& uIndex) throw()
{
	ConstArray<_LCID_ShortString> c_arr(g_lcid_short_string_map::GetAddress(), g_lcid_short_string_map::GetCount());
	auto iter(c_arr.GetBegin());
	for( ; iter != c_arr.GetEnd(); iter.MoveNext() ) {
		const _LCID_ShortString& ls = iter.get_Value();
		if( ls.m_lcid == uLCID ) {
			uIndex = ls.m_uIndex;
			return ConstStringS(ls.m_short_string.m_first, ls.m_short_string.m_size);
		}
	}
	return ConstStringS();
}
Exemple #3
0
inline uint _Find_LCID_From_ShortString(const ConstStringS& strShortString, uint& uIndex) throw()
{
	ConstArray<_LCID_ShortString> c_arr(g_lcid_short_string_map::GetAddress(), g_lcid_short_string_map::GetCount());
	auto iter(c_arr.GetBegin());
	for( ; iter != c_arr.GetEnd(); iter.MoveNext() ) {
		const _LCID_ShortString& ls = iter.get_Value();
		if( ConstStringCompareTrait<ConstStringS>::IsEQ(strShortString, ConstStringS(ls.m_short_string.m_first, ls.m_short_string.m_size)) ) {
			uIndex = ls.m_uIndex;
			return ls.m_lcid;
		}
	}
	return 0;
}
Exemple #4
0
	void expand_macro_one(StringA& str)
	{
		if( str.IsBlockNull() )
			return ;

		//loop
		do {
			//find
			uintptr uCount = 0;
			uintptr uStart = 0;
			do {
				auto iter(StringHelper::Find(str, '{', uStart));
				if( iter.IsNull() )
					break;
				intptr delta = iter.CalcDelta(str.GetAt(uStart));
				if( iter != str.GetBegin() ) {
					auto iter1(iter);
					iter1.MovePrev();
					// \{
					if( iter1.get_Value() == '\\' ) {
						uStart += (delta + 1);
						continue;
					}
				}
				uStart += (delta + 1);
				uCount ++;
				uintptr uLeftC = uStart;
				do {
					auto iterE(StringHelper::Find(str, '}', uStart));
					if( iterE.IsNull() ) {
						uCount --;
						break;
					}
					delta = iterE.CalcDelta(str.GetAt(uStart));
					auto iter1(iterE);
					iter1.MovePrev();
					// \}
					if( iter1.get_Value() == '\\' ) {
						uStart += (delta + 1);
						continue;
					}
					uStart += (delta + 1);
					intptr len = iterE.CalcDelta(iter);
					//empty
					if( len <= 1 ) {
						uCount --;
						break;
					}
					//macro name
					StringA strMacro(StringHelper::MakeEmptyString<CharA>(MemoryHelper::GetCrtMemoryManager()));  //may throw
					StringUtilHelper::Sub(str, uLeftC, len - 1, strMacro);  //may throw
					ConstStringA c_macro_name(StringUtilHelper::To_ConstString(strMacro));
					StringA strV;
					uint id = m_macro_table.get_ID(c_macro_name);
					if( id == 0 ) {
						id = m_token_table.get_ID(c_macro_name);
						if( id == 0 ) {
							uCount --;
							break;
						}
						strV = m_token_regex[id - m_token_table.GetMinID()].get_Value();
					}
					else {
						strV = m_macro_regex[id - m_macro_table.GetMinID()].get_Value();
					}
					iter.get_Value() = '(';
					iterE.get_Value() = ')';
					StringHelper::Delete(uLeftC, len - 1, str);
					StringUtilHelper::Insert(uLeftC, strV, str);  //may throw
					//now iterators are invalid
					uStart = uLeftC + strV.GetLength() + 1;
					break;
				} while(true);
			} while(true);
			if( uCount == 0 )
				break;
		} while(true);
	}
Exemple #5
0
	void ExpandTokenMacros()
	{
		for( auto iter(m_token_regex.GetBegin()); iter != m_token_regex.GetEnd(); iter.MoveNext() )
			expand_macro_one(iter.get_Value());  //may throw
	}