bool DefaultOptionExpBuilder::ParseChoiceOptions(ChoiceOptionParamList* ptr, OptionContext* pContext, OptionParamList* pArray)
{
	std::string val;
	bool bRet = pContext->Get(ptr->szChoiceOptionID, val);
	if(!bRet)
	{
		if(IS_LOG_ENABLED(THE_LIB_LOGGER, log4cplus::DEBUG_LOG_LEVEL))
		{
			cfl::tstring szLog;
			cfl::tformat(szLog, _T("Failed to get choice option id : %s"), CFL_A2T(ptr->szChoiceOptionID));
			LOG4CPLUS_DEBUG_STR(THE_LIB_LOGGER, szLog)
		}
		return false;
	}
	for(int i = 0; i < ptr->nGroupCount; i++)
	{
		if(val.compare(0, val.size(), ptr->pGroups[i].szName) == 0)
		{
			pArray->pOptions = ptr->pGroups[i].pOptions;
			pArray->nCount = ptr->pGroups[i].nOptionCount;
			return true;
		}
	}
	return false;
}
Esempio n. 2
0
void CVCDlg::InitDeviceComboBox()
{
	ProfileNode* pRoot = ProfileMgr::GetInstance()->GetRootProfile();
	int nChildCount = ((pRoot == NULL) ? 0 : pRoot->GetChildCount());

	std::string szText;
	AttribMap* pAttribMap = NULL;
	for(int i = 0; i < nChildCount; i++)
	{
		ProfileNode* pProfile = (ProfileNode*)pRoot->GetChild(i);

		pAttribMap = (AttribMap*)pProfile->GetData();
		if(!pAttribMap->Get(PF_ATTRIB_DESC, szText))
		{
			pAttribMap->Get(PF_ATTRIB_NAME, szText);
		}
		LIST_ITEM item;
		item.strText = CFL_A2T(szText.c_str());
		item.vpItemData = pProfile;
		m_deviceComboBox.AddItem(&item);
	}

	if(nChildCount > 0)
	{
		m_deviceComboBox.SetCurSel(0);
		OnCategorySelChanged();
	}
}
static bool PassFuncSet(OptionExp* pOptExp, OptionContext* pContext, const std::string* pVal)
{
	if(IS_LOG_ENABLED(THE_LIB_LOGGER, log4cplus::TRACE_LOG_LEVEL))
	{
		cfl::tstring szLog;
		cfl::tformat(szLog, _T("PassFuncSet called: pval = %s, name=%s"),
			CFL_A2T(SafePStrA(pVal)), CFL_A2T(SafePStrA(pOptExp->GetField(OPT_FIELD_NAME))));
		LOG4CPLUS_TRACE_STR(THE_LIB_LOGGER, szLog)
	}
	//only work for pass 1
	if(pVal == NULL || pVal->compare(0, 1, "1") != 0)
	{
		return false;
	}

	if(FindSibling(pOptExp, "turbo") == NULL)
	{
		//add sibling "turbo" at next
		DefaultOptionExp* pSibling = new DefaultOptionExp();
		pSibling->SetOptionName("turbo").SetOptionValue("");
		pSibling->SetEvaluateMode(OPTEM_NAME_ONLY).SetEvaluateFlag(OPTEF_SELF);
		if(!AddNextSibling(pOptExp, pSibling))
		{
			delete pSibling;
			return false;
		}
	}
	
	OptionExp* pAncestor = GetNonRootAncestor(pOptExp);
	if(pAncestor != NULL && (FindSibling(pAncestor, "-nosound") == NULL))
	{
		//add sibling "-nosound" at global options
		DefaultOptionExp* pSibling = new DefaultOptionExp();
		pSibling->SetOptionName("-nosound").SetOptionValue("");
		pSibling->SetEvaluateMode(OPTEM_NAME_ONLY).SetEvaluateFlag(OPTEF_SELF);
		if(!AddNextSibling(pAncestor, pSibling))
		{
			delete pSibling;
			return false;
		}
	}
	return true;
}
Esempio n. 4
0
void CVCDlg::OnProfileSelChanged()
{
	int nCurSel = m_profileComboBox.GetCurSel();
	if(nCurSel >= 0)
	{
		ProfileNode* pProfile = (ProfileNode*)m_profileComboBox.GetItemDataPtr(nCurSel);
		AttribMap* pAttribMap = NULL;
		std::string szProfileFile;
		if(pProfile != NULL)
		{
			pAttribMap = (AttribMap*)pProfile->GetData();
			if(pAttribMap->Get(PF_ATTRIB_FILE, szProfileFile))
			{
				//Initialize the profile tree firstly
				CString szPath;
				if(SysUtils::GetProfile(szPath, CFL_A2T(szProfileFile.c_str())))
				{
					m_propListMgr.Init(CFL_T2A((LPCTSTR)szPath));
				}
			}
		}
	}
}
bool OptionExpTree::PostEvaluateGroup(OptionContext* pContext)
{
	//node that has children, but excludes root
	std::stack<OptionExp*> optExpStack;
	
	std::list<OptionExp*> optExpList;
	optExpList.push_back(m_pRoot);

	OptionExp *pExp, *pChild;
	while(!optExpList.empty())
	{
		pExp = optExpList.front();
		optExpList.pop_front();

		if(pExp->GetChildCount() > 0)
		{
			for(int i = pExp->GetChildCount() - 1; i >= 0; i--)
			{
				pChild = pExp->GetChild(i);
				if(pChild->GetChildCount() > 0)
				{
					if(IS_LOG_ENABLED(THE_LOGGER, log4cplus::TRACE_LOG_LEVEL))
					{
						cfl::tstring szLog;
						cfl::tformat(szLog, _T("[stack push]: id=%s,name=%s,value=%s"), 
							CFL_A2T(SafeStrA(pChild->GetFieldStr(OPT_FIELD_ID))),
							CFL_A2T(SafeStrA(pChild->GetFieldStr(OPT_FIELD_NAME))), 
							CFL_A2T(SafeStrA(pChild->GetFieldStr(OPT_FIELD_VALUE))));
						LOG4CPLUS_TRACE_STR(THE_LOGGER, szLog)
					}

					//visit
					optExpStack.push(pChild);

					//update data list
					optExpList.push_back(pChild);
				}
			}
		}
	}

	std::string val;
	while(!optExpStack.empty())
	{
		pExp = optExpStack.top();
		optExpStack.pop();
		if(IS_LOG_ENABLED(THE_LOGGER, log4cplus::TRACE_LOG_LEVEL))
		{
			cfl::tstring szLog;
			cfl::tformat(szLog, _T("[stack  pop]: id=%s,name=%s,value=%s"), 
				CFL_A2T(SafeStrA(pExp->GetFieldStr(OPT_FIELD_ID))),
				CFL_A2T(SafeStrA(pExp->GetFieldStr(OPT_FIELD_NAME))), 
				CFL_A2T(SafeStrA(pExp->GetFieldStr(OPT_FIELD_VALUE))));
			LOG4CPLUS_TRACE_STR(THE_LOGGER, szLog)
		}
		if(!pExp->Evaluate(pContext, val))
		{
			return false;
		}
	}
	return true;
}
Esempio n. 6
0
	std::string szText;
	AttribMap* pAttribMap = (AttribMap*)pProfile->GetData();
	if(!pAttribMap->Get(PF_ATTRIB_TAG, szText) || (szText.compare("device") != 0 && szText.compare("profile") != 0))
	{
		return NULL;
	}

	if(!pAttribMap->Get(PF_ATTRIB_DESC, szText))
	{
		cfl::tstring szLog;
		cfl::tformat(szLog, _T("Can't find the [desc] attribute"));
		LOG4CPLUS_INFO_STR(THE_LOGGER, szLog)
		return NULL;
	}
	LIST_ITEM item;
	item.strText = CFL_A2T(szText.c_str());
	item.vpItemData = pProfile;
	PLIST_ITEM pCurrItem = m_profileComboBox.AddItem(&item, pItemParent);

	int nChildCount = ((pProfile == NULL) ? 0 : pProfile->GetChildCount());
	for(int i = 0; i < nChildCount; i++)
	{
		AddProfile((ProfileNode*)pProfile->GetChild(i), pCurrItem);
	}

	return pCurrItem;
}
void CVCDlg::InitSplitters()
{
	m_splitterVBkBitmap.LoadBitmap(IDB_SPLITTER_V_BKG);
	m_splitterHBkBitmap.LoadBitmap(IDB_SPLITTER_H_BKG);