当前位置: 首页>>代码示例>>C++>>正文


C++ CIniParser类代码示例

本文整理汇总了C++中CIniParser的典型用法代码示例。如果您正苦于以下问题:C++ CIniParser类的具体用法?C++ CIniParser怎么用?C++ CIniParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CIniParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LOG

// Specific Burst cmds for Gateway Caching
bool GatewayConfig::BurstSpecificCmds()
{
    m_oSpecificBurstCmds.clear();

    CIniParser specificCmdsConfig;
    CIniParser::valuesList burstSpecificCmds;
    if (!specificCmdsConfig.Load(FILE_PATH_CONFIGINI))
    {
        LOG("------- NO CONFIG.INI FILE -------");
        return 0;
    }

    if (!specificCmdsConfig.GetVar("WH_GATEWAY", "BURST_SPECIFIC_CMDS", &burstSpecificCmds))
    {
        return 0;
    }

    CIniParser::valuesList::iterator it = burstSpecificCmds.begin();

    for (; it != burstSpecificCmds.end(); it++)
    {
        CHartCmdWrapper::Ptr cmdTemp(new CHartCmdWrapper);

        cmdTemp->LoadRaw((*it), 0, NULL, 0);
        m_oSpecificBurstCmds.push_back(cmdTemp);

    }

    return 1;
}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:31,代码来源:GatewayConfig.cpp

示例2: sprintf

int CDiscoveryApp::Init( const char * p_szInterface )
{
	char szBuffer[ 64 ];
	sprintf( szBuffer, "/tmp/%s.log", p_szInterface);
	
	if( !CApp::Init( szBuffer ) )
	{	
		LOG("CApp::Init(%s) return 0", szBuffer);
		
		return 0;
	}
	
	if( !m_stCfg.Init( "GLOBAL") )
	{
		LOG("m_stCfg.Init(\"GLOBAL\") return 0");
		
		return 0;
	}
	
	//read ETH_NAME
	CIniParser configParser;
	if(!configParser.Load(RC_NET_INFO) || configParser.GetVar((const char*)NULL, "ETH_NAME", m_szEthInterf, sizeof(m_szEthInterf), 0, false) == 0)
	{
		strcpy(m_szEthInterf, "eth0");
	}
	snprintf(m_szEthInterf_0, READ_BUF_SIZE, "%s:0", m_szEthInterf);
	snprintf(m_szEthInterf_1, READ_BUF_SIZE, "%s:1", m_szEthInterf);

	srand(time(NULL));
	
	LOG( "Init DONE");
	
	return 1;    //all went OK
}
开发者ID:singhshobhit,项目名称:RPL_Node,代码行数:34,代码来源:DiscoveryApp.cpp

示例3: WriteCmdFinalAssemblyNumber

// write Command Final Assembly Number to config_universal.ini file
bool GatewayConfig::WriteCmdFinalAssemblyNumber(uint32_t finalAssemblyNumber)
{
    CIniParser gwVarConfig;
    if (!gwVarConfig.Load(FILE_PATH_GW_INFO_UNIV, "r+"))
    {
        LOG("------- NO CONFIG.INI FILE -------");
        return 0;
    }

    if (!gwVarConfig.FindGroup("WH_GATEWAY", true))
    {
        return 0;
    }

    else
    {
        int finAssemblyNumber;
        finAssemblyNumber = (int) finalAssemblyNumber;
        if (!gwVarConfig.SetVar("WH_GATEWAY", "FINAL_ASSEMBLY_NUMBER", finAssemblyNumber))
            return 0;

    }
    return 1;

}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:26,代码来源:GatewayConfig.cpp

示例4: LoadPidList

int CWatchdogMngr::LoadPidList()
{
	CIniParser oIniParser;

	if ( !oIniParser.Load(m_pPidListFile) )
	{
		throw CWatchdog::exception::exception("Unable to load pidListFile") ;
	}

	LOG("Loaded pidListFile [%s]", m_pPidListFile);

	char*  currentPidList[WTD_PIDLIST_ENTRIES]={0,};
	size_t currentPidListLen=0;
	char   pidFile[256];
	for ( unsigned pos=0
		; oIniParser.GetVar("WTD", "watch", pidFile, sizeof(pidFile), pos)
		  && currentPidListLen < WTD_PIDLIST_ENTRIES
		;  ++pos )
	{
		void*key=pidFile;
		void *el=lfind( &key,currentPidList,&currentPidListLen,sizeof(currentPidList[0]),qsortcmp ) ;
		if ( NULL == el )
		{
			currentPidList[currentPidListLen] = strdup(pidFile);
			LOG( WTD"fw.cfg:[%s]", currentPidList[currentPidListLen] );
			++currentPidListLen ;
		}
	}
	qsort( currentPidList, currentPidListLen, sizeof(currentPidList[0]), qsortcmp );

	/// Check if any pidFile from m_ppPidList is missing from currentPidList.
	for (   unsigned j=0; j < m_nPidListLength && m_ppPidList[j]; ++j )
	{
		void *el=bsearch( &m_ppPidList[j], currentPidList, currentPidListLen, sizeof(currentPidList[0]), qsortcmp) ;
		if ( NULL == el )
		{
			LOG( WTD "STOP watching pid[%s]", m_ppPidList[j]);
			systemf_to( 20, "log2flash 'WTD: STOP watching pid[%s]'&", m_ppPidList[j]);
		}
	}
	/// Free the old list to prepare the copy of the new one.
	clearPidList() ;

	m_nPidListLength=currentPidListLen ;
	m_ppPidList[m_nPidListLength] = 0;

	LOG( WTD"WATCH:%d modules", m_nPidListLength );
	if ( !m_nPidListLength )
	{
		return true ;
	}
	memmove(m_ppPidList, currentPidList, WTD_PIDLIST_ENTRIES*sizeof(currentPidList[0]) );
	for ( unsigned j = 0; j< m_nPidListLength ; j++)
	{
		LOG( WTD "WATCH:[%s]", m_ppPidList[j]);
	}
	return true ;
}
开发者ID:dndusdndus12,项目名称:ISA100.11a-Gateway-1,代码行数:58,代码来源:WatchdogMngr.cpp

示例5: LoadBurstMessage

/*BURST=<command number>, <burst message>, <update period>, <maximum update period>*/
int PublisherConf::LoadBurstMessage(CIniParser& parser /*[in]*/, const hart7::hostapp::MAC& mac, int burstMessageID, hart7::hostapp::BurstMessage& burstMessage/*[in/out]*/)
{
	char szLogVarString[256] = "";
	LOG_INFO_APP( "[LoadPublishers]: loading burst message...");

	if (!parser.GetVarRawString(NULL, "BURST", szLogVarString, sizeof(szLogVarString), burstMessageID))
		return -1;
	LOG_INFO_APP( "[LoadPublishers]: BURST[" << mac << "]=" << szLogVarString);

	unsigned int cmdNo, burstMsg;
	char szSubdevMAC[32] = "", exData[2];

	int rv = sscanf( szLogVarString, "%u, %u, %lf, %lf, %s, %1s "
		, &cmdNo
		, &burstMsg
		, &(burstMessage.updatePeriod)
		, &(burstMessage.maxUpdatePeriod)
        , szSubdevMAC
		, exData
	);

	if(rv != 4 && rv != 5)
	{
	    LOG_ERROR_APP("[LoadPublishers]: read " << rv << " items from buffer instead of 4 or 5");
		return -1;
	}

	if (rv == 4)
	{
	    hart7::hostapp::MAC emptyMAC;
	    burstMessage.subDeviceMAC = emptyMAC;
	}
	else
	{
		try
		{
			hart7::hostapp::MAC subdevMAC(szSubdevMAC);
			burstMessage.subDeviceMAC = subdevMAC;
	    }
	    catch (...)
	    {
	        return -1;
	    }
	}

	char burstNo[10]="";
	snprintf(burstNo,sizeof(burstNo),"%d",burstMessageID);	
	char szVarName[] = "BURST_SET_PUBLISH_PERIOD_";
	strcat(szVarName, burstNo);
	
	if (parser.GetVarRawString(NULL, szVarName, szLogVarString, sizeof(szLogVarString)))
	{
		std::stringstream(szLogVarString) >> burstMessage.updatePeriod;
		LOG_INFO_APP("[LoadPublishers]: BURST_SET_PUBLISH_PERIOD loaded: updatePeriod=" << burstMessage.updatePeriod << " overrides base update period.");
	}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:56,代码来源:PublisherConf.cpp

示例6: LoadNextMAC

int PublisherConf::LoadNextMAC(CIniParser& parser /*[in]*/, hart7::hostapp::MAC& mac/*[in/out]*/)
{
    const char *pgroup = NULL;
	LOG_INFO_APP( "[LoadPublishers]: loading next mac...");
    if (!(pgroup = parser.FindGroup(NULL, true, true, true)))
	{
		LOG_WARN_APP( "[LoadPublishers]: no mac found");
		return -1;
	}


	if (pgroup[hart7::hostapp::MAC::TEXT_SIZE] != '\0')
	{
		LOG_ERROR_APP( "[LoadPublishers]: read mac has not the proper format.");
		return -1;
	}


    std::string strMac = pgroup;
	LOG_INFO_APP("[LoadPublishers]: mac=" << strMac << " read from conf." );

    try
    {
        mac = hart7::hostapp::MAC(strMac);
    }
    catch (...)
    {
        return -1;
    }
    return 0;
}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:31,代码来源:PublisherConf.cpp

示例7: WriteDeviceStatus

// write Device Status to config_universal.ini file
// TODO: Beni - save Device Status on C038_ResetConfigurationChangedFlag
bool GatewayConfig::WriteDeviceStatus(uint8_t deviceStatus)
{
    CIniParser gwVarConfig;
    if (!gwVarConfig.Load(FILE_PATH_GW_INFO_UNIV, "r+"))
    {
        LOG("------- NO CONFIG.INI FILE -------");
        return 0;
    }

    if (!gwVarConfig.SetVar("WH_GATEWAY", "DEVICE_STATUS", deviceStatus))
        return 0;

    m_u8DeviceStatus = deviceStatus;

    return 1;
}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:18,代码来源:GatewayConfig.cpp

示例8: WriteGwReqMaxRetryNo

bool GatewayConfig::WriteGwReqMaxRetryNo(uint8_t p_u8RetryNo)
{
    CIniParser gwVarConfig;
    if (!gwVarConfig.Load(FILE_PATH_CONFIGINI, "r+"))
    {
        LOG("------- NO CONFIG.INI FILE -------");
        return 0;
    }

    if (!gwVarConfig.FindGroup("WH_GATEWAY", true))
    {
        return 0;
    }

    if (!gwVarConfig.SetVar("WH_GATEWAY", "GW_REQ_MAX_RETRY_NO", p_u8RetryNo, 0, true))
    {
        return 0;
    }
    return 1;
}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:20,代码来源:GatewayConfig.cpp

示例9: WriteCmdUniversalMessage

bool GatewayConfig::WriteCmdUniversalMessage(char * universalmessage)
{
    CIniParser gwVarConfig;
    if (!gwVarConfig.Load(FILE_PATH_GW_INFO_UNIV, "r+"))
    {
        LOG("------- NO CONFIG.INI FILE -------");
        return 0;
    }

    if (!gwVarConfig.FindGroup("WH_GATEWAY", true))
    {
        return 0;
    }

    if (!gwVarConfig.SetVar("WH_GATEWAY", "CMD_UNIVERSAL_MESSAGE", universalmessage))
    {
        return 0;
    }

    return 1;
}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:21,代码来源:GatewayConfig.cpp

示例10: strcasecmp

enum CWatchdog::Type CWatchdogMngr::GetType()
{
	char wtd[16]={0} ;
	CIniParser oIniParser;

	if ( !oIniParser.Load(INI_FILE) )
		throw CWatchdog::exception::exception("Unable to parse IniFile") ;

	if ( ! oIniParser.GetVar("GLOBAL","WATCH_DOG_TYPE", wtd, sizeof(wtd))
	||   ! strcasecmp(wtd,"internal") )
	{
		LOG( WTD "Using the internal watchdog") ;
		return CWatchdog::WTD_INTERNAL ;
	}

	if ( ! strcasecmp(wtd,"max6371") )
	{
		LOG( WTD "Using the max6371 watchdog") ;
		return CWatchdog::WTD_MAX6371 ;
	}
	return CWatchdog::WTD_INTERNAL ;
}
开发者ID:dndusdndus12,项目名称:ISA100.11a-Gateway-1,代码行数:22,代码来源:WatchdogMngr.cpp

示例11: WriteMinRespPreamblesNo

bool GatewayConfig::WriteMinRespPreamblesNo(uint8_t p_u8MinRespPreamblesNo)
{
    CIniParser gwVarConfig;
    if (!gwVarConfig.Load(FILE_PATH_GW_INFO_UNIV, "r+"))
    {
        LOG("------- NO CONFIG.INI FILE -------");
        return 0;
    }

    if (!gwVarConfig.FindGroup("WH_GATEWAY", true))
    {
        return 0;
    }

    int minRespPreamblesNo = p_u8MinRespPreamblesNo;

    if (!gwVarConfig.SetVar("WH_GATEWAY", "MIN_RESP_PREAMBLES_NO", minRespPreamblesNo))
    {
        return 0;
    }

    return 1;
}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:23,代码来源:GatewayConfig.cpp

示例12: WriteCmdTag

bool GatewayConfig::WriteCmdTag(char * tag)
{
    CIniParser gwVarConfig;
    if (!gwVarConfig.Load(FILE_PATH_GW_INFO_UNIV, "r+"))
    {
        LOG("-------NO CONFIG.INI FILE -------");
        return 0;
    }

    if (!gwVarConfig.FindGroup("WH_GATEWAY", true))
    {
        return 0;
    }

    else
    {
        if (!gwVarConfig.SetVar("WH_GATEWAY", "TAG", tag))
            return 0;

    }
    return 1;

}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:23,代码来源:GatewayConfig.cpp

示例13: WriteCmdMasterDescriptor

bool GatewayConfig::WriteCmdMasterDescriptor(char * masterDescriptor)
{
    CIniParser gwVarConfig;
    if (!gwVarConfig.Load(FILE_PATH_GW_INFO_UNIV, "r+"))
    {
        LOG("------- NO CONFIG.INI FILE -------");
        return 0;
    }

    if (!gwVarConfig.FindGroup("WH_GATEWAY", true))
    {
        return 0;
    }

    else
    {
        if (!gwVarConfig.SetVar("WH_GATEWAY", "MASTER_DESCRIPTOR", masterDescriptor))
            return 0;

    }
    return 1;

}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:23,代码来源:GatewayConfig.cpp

示例14: LoadConfig

int CWatchdogMngr::LoadConfig( )
{
	char wtd[16]={0} ;
	int divisor ;
	CIniParser oIniParser;
	if ( !oIniParser.Load(INI_FILE) )
		throw CWatchdog::exception::exception("Unable to parse IniFile") ;

	oIniParser.GetVar("GLOBAL","MODULES_WATCH_DOG", wtd, sizeof(wtd) ) ;

	if(  wtd[0]=='n' || wtd[0]=='N'
	  || wtd[0]=='f' || wtd[0]=='F'
	  || wtd[0]=='0'
	   )
	{
		if ( m_status&CFG_ENABLED )
		{
			m_status&=~CFG_ENABLED ;
			LOG("Disabling watchdog");
		}
	}
	else if ( ! (m_status&CFG_ENABLED) )
	{
		m_status|=CFG_ENABLED;
		LOG("Enabling watchdog");
	}
	// Set the PingDivisor
	if ( oIniParser.GetVar("GLOBAL","WATCH_DOG_DIVISOR", &divisor))
	{
		SetPingDivisor(divisor) ;
	}
	if ( ! oIniParser.GetVar("GLOBAL","FREEMEM_THRESHOLD", &m_nMemThreshold) )
	{
		m_nMemThreshold = 5*1024*1024 ;
	}
	if ( ! oIniParser.GetVar("GLOBAL","FREETMP_THRESHOLD", &m_nTmpThreshold) )
	{
		m_nTmpThreshold = 4*1024*1024 ;
	}
	return (m_status&CFG_ENABLED) ;
}
开发者ID:dndusdndus12,项目名称:ISA100.11a-Gateway-1,代码行数:41,代码来源:WatchdogMngr.cpp

示例15: WriteCmdMasterDate

bool GatewayConfig::WriteCmdMasterDate(WHartDate masterDate)
{
    CIniParser gwVarConfig;
    if (!gwVarConfig.Load(FILE_PATH_GW_INFO_UNIV, "r+"))
    {
        LOG("-------NO CONFIG.INI FILE -------");
        return 0;
    }

    if (!gwVarConfig.FindGroup("WH_GATEWAY", true))
    {
        return 0;
    }

    else
    {
        int date_day;
        int date_month;
        int date_year;

        date_day = (int) masterDate.day;
        date_month = (int) masterDate.month;
        date_year = (int) masterDate.year;

        if (!gwVarConfig.SetVar("WH_GATEWAY", "MASTER_DATE_DAY", date_day))
            return 0;

        if (!gwVarConfig.SetVar("WH_GATEWAY", "MASTER_DATE_MONTH", date_month))
            return 0;

        if (!gwVarConfig.SetVar("WH_GATEWAY", "MASTER_DATE_YEAR", date_year))
            return 0;
    }
    return 1;

}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:36,代码来源:GatewayConfig.cpp


注:本文中的CIniParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。