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


C++ ConfigValue类代码示例

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


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

示例1: GetwstringValueFromConfig

bool ConfigWrapper::GetwstringValueFromConfig( const wstring& strKey, wstring& strValue )
{
	if ( NUMBER_ZERO == strKey.compare( NULL_STRING ))
	{
		return false;
	}

	if ( NULL == m_pConfigManager )
	{
		return false;
	}

	ConfigValue* pSingleNode = NULL;
//	pSingleNode = m_pConfigManager->SelectSingleNode( strKey );

	TCHAR szNodeValue[MAX_VALUE_LENGTH];

	DWORD dwReturnSize = pSingleNode->GetValue( szNodeValue );
	strValue = szNodeValue;

	if ( NULL != pSingleNode )
	{
		delete pSingleNode;
		pSingleNode = NULL;
	}

	return true;
}
开发者ID:qdaxb,项目名称:gameengine,代码行数:28,代码来源:ConfigWrapper.cpp

示例2: throw

ConfigMap* ConfigMapParser::map() throw(PARSEEXCEPTION_THROW)
{
  expect(T::CMT_CBL);
  ConfigMap* cm = new ConfigMap();
  std::string* currComments = 0;
  if(token.type == T::CMT_COMMENT)
    currComments = comments();
  try
  {
    while(token.type == T::CMT_KEY)
    {
      std::string key = token.value;
      nextToken();
      try
      {
        expect(T::CMT_EQ);
        if(prefixValue(token))
        {
          ConfigValue* cv = value();
          if(currComments)
            cv->setComment(*currComments);
          try
          {
            (*cm)[key] = *cv;
          }
          catch(invalid_key& ik)
          {
            P_ERROR(ik.what());
          }
          delete cv;
        }
        else
        {
          P_ERROR("Expected begin of a value (`{`, `[` or VALUE), got `" + T::type2str(token.type) + "`");
        }
      }
      catch(ParseException)
      {
        if(currComments) delete currComments;
        throw;
      }
      expect(T::CMT_SEMICOLON);
    }
    expect(T::CMT_CBR);

    if(currComments)
      delete currComments;
    currComments = 0;
    if(token.type == T::CMT_COMMENT)
      currComments = comments();
  }
  catch(ParseException)
  {
    delete cm;
    if(currComments) delete currComments;
    throw;
  }
  if(currComments) delete currComments;
  return cm;
}
开发者ID:MisterSquishy,项目名称:nbites,代码行数:60,代码来源:ConfigMapParser.cpp

示例3: SkipSpaces

bool json::Reader::ParseArray(ConfigValue& value)
{
	value.SetEmptyArray();
	
	_cur++; // Skip '['
	SkipSpaces();
	if(*_cur == ']')
	{
		_cur++;
		return true;
	}
	while(1)
	{
		ConfigValue& elem = value.Append();
		
		if(!ParseValue(elem))
			return false;
		
		SkipSpaces();

		char c = *_cur;
		if(c == ',') // Separator between elements (Optional)
		{
			_cur++;
			continue;
		}
		if(c == ']') // End of array
		{
			_cur++;
			break;
		}
	}
	return true;
}
开发者ID:simeks,项目名称:m7017e-lab,代码行数:34,代码来源:json.cpp

示例4: type

void QuickConfig::syncProperties(QObject *object)
{
	const QMetaObject * const base = object == this ? &staticMetaObject : &QObject::staticMetaObject;
	const QMetaObject * const actual = object->metaObject();

	int propertiesCount = actual->propertyCount();
	for (int index = base->propertyCount(); index < propertiesCount; ++index) {
		QMetaProperty property = actual->property(index);
		QVariant defaultValue = property.read(object);
		QMetaType type(property.userType());

		if (type.flags() & QMetaType::PointerToQObject) {
			QObject *subObject = defaultValue.value<QObject *>();
			if (!subObject) {
				qWarning() << "QuickConfig: null value at" << this << ", property:" << property.name();
				continue;
			}
			m_config.beginGroup(QLatin1String(property.name()));
			syncProperties(subObject);
			m_config.endGroup();
			continue;
		}

		ConfigValue<QVariant> actualValue = m_config.value(QLatin1String(property.name()), defaultValue);
		property.write(object, actualValue.value());

		// Store actualValue as it's destruction will drop onChange listener
		new QuickConfigListener(m_path, m_group, property, object, actualValue, this);

		actualValue.onChange(object, [object, property, defaultValue] (const QVariant &value) {
			property.write(object, value.isValid() ? value : defaultValue);
		});
	}
}
开发者ID:CyberSys,项目名称:qutim,代码行数:34,代码来源:quickconfig.cpp

示例5: _find

void SimpleConfig::setString(const std::string &section, const std::string &key, const std::string &value) {
	ConfigValue *v = _find(section, key);
	if (v) {
		v->setValue(value);
	} else {
		_addValue(section, key, value);
	}
	m_modified = true;
	if (m_autosave) save();
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例6: throw

int ConfigMapParser::file(ConfigMap* configMap) throw(PARSEEXCEPTION_THROW)
{
  size_t size = configMap->length();
  std::string* currComments = 0;
  if(token.type == T::CMT_COMMENT)
    currComments = comments();
  while(token.type == T::CMT_KEY)
  {
    size_t keyLine = token.line;
    size_t keyColumn = token.column;
    std::string key = token.value;
    nextToken();
    try
    {
      expect(T::CMT_EQ);
      if(prefixValue(token))
      {
        ConfigValue* cv = value();
        if(currComments)
          cv->setComment(*currComments);
        try
        {
          (*configMap)[key] = *cv;
        }
        catch(invalid_key& ik)
        {
          std::cout<<"[EXCEPTION ERROR ] ConfigMapParser.cpp 1"<<std::endl;
          throw ParseException(keyLine, keyColumn, ik.what());
        }
        delete cv;
      }
      else
      {
        P_ERROR("Expected begin of a value (`{`, `[` or VALUE), got `" + T::type2str(token.type) + "`");
      }
    }
    catch(ParseException)
    {
      if(currComments) delete currComments;
      throw;
    }
    expect(T::CMT_SEMICOLON);

    if(currComments)
      delete currComments;
    currComments = 0;
    if(token.type == T::CMT_COMMENT)
      currComments = comments();
  }
  expect(T::CMT_EOF);
  if(currComments) delete currComments;
  return configMap->length() - size;
}
开发者ID:coryalini,项目名称:nbites,代码行数:53,代码来源:ConfigMapParser.cpp

示例7: if

bool json::Reader::ParseNumber(ConfigValue& value)
{
	bool integer = true; // Number is either integer or float
	for(const char* c = _cur; c != _end; ++c)
	{
		if((*c >= '0' && *c <= '9') || ((*c == '-' || *c == '+') && (c == _cur))) // Allow a negative sign at the start for integers
			continue;
		else if(*c == '.' || *c == 'e' || *c == 'E' || *c == '+') 
		{
			integer = false;
			break;
		}
		else
			break;
	}
	if(!integer)
		return ParseDouble(value);


	bool negative = (*_cur == '-');
	if(negative)
		_cur++;

	uint64_t number = 0;
	while(_cur != _end)
	{
		if(*_cur >= '0' && *_cur <= '9')
		{
			uint32_t digit = *_cur - '0';
			number = number * 10 + digit;
			_cur++;
		}
		else
			break;
	}
	if(negative)
	{
		value.SetInt(-int64_t(number));
	}
	else if(number <= INT64_MAX)
	{
		value.SetInt(int64_t(number));
	}
	else
	{
		value.SetUInt(number);
	}

	return true;
}
开发者ID:simeks,项目名称:m7017e-lab,代码行数:50,代码来源:json.cpp

示例8:

bool json::Reader::ParseDouble(ConfigValue& value)
{
	char* number_end;
	double number = std::strtod(_cur, &number_end);
	value.SetDouble(number);
	_cur = number_end;
	return true;
}
开发者ID:simeks,项目名称:m7017e-lab,代码行数:8,代码来源:json.cpp

示例9: GetValue

bool FlatConfigFile::GetValue(size_t nIndex, ConfigValue & xValue) const
{
	if(nIndex >= 0 && nIndex < m_xDataArray.size()) {
		xValue.Load(m_xDataArray.at(nIndex).c_str());
		return true;
	}
	return false;
}
开发者ID:ueverything,项目名称:share,代码行数:8,代码来源:config_file.cpp

示例10: GetAllNodeInfoFromConfig

int ConfigWrapper::GetAllNodeInfoFromConfig( map<wstring, wstring>& mapOperator )
{
	ConfigValue* pConfigValue = NULL;

//	pConfigValue = m_pConfigManager->SelectNodes();
	if ( NULL != pConfigValue )
	{
		pConfigValue->GetOperatorMap( mapOperator );

		delete pConfigValue;
		pConfigValue = NULL;
	}
	else
	{
		return ERROR_NEWPOINTER_FAILED;
	}

	return RETURN_SUCCESS;
}
开发者ID:qdaxb,项目名称:gameengine,代码行数:19,代码来源:ConfigWrapper.cpp

示例11: shift_parameter

// Output a ConfigValue from the specified ConfigSource to the stream
void Configurator::config_get_command( string parameters, StreamOutput* stream ){
    string source = shift_parameter(parameters);
    string setting = shift_parameter(parameters);
    if (setting == "") { // output live setting
        setting = source;
        source = "";
        vector<uint16_t> setting_checksums = get_checksums( setting );
        ConfigValue* cv = this->kernel->config->value(setting_checksums);
        string value = "";
        if(cv->found){ value = cv->as_string(); }
        stream->printf( "live: %s is set to %s\r\n", setting.c_str(), value.c_str() );
    } else { // output setting from specified source
        uint16_t source_checksum = get_checksum( source );
        vector<uint16_t> setting_checksums = get_checksums( setting );
        for(int i=0; i < this->kernel->config->config_sources.size(); i++){
            if( this->kernel->config->config_sources[i]->is_named(source_checksum) ){
                string value = this->kernel->config->config_sources[i]->read(setting_checksums);
                stream->printf( "%s: %s is set to %s\r\n", source.c_str(), setting.c_str(), value.c_str() );
                break;
            }
        }
    }
}
开发者ID:CNCBASHER,项目名称:Smoothie,代码行数:24,代码来源:Configurator.cpp

示例12: shift_parameter

// Output a ConfigValue from the specified ConfigSource to the stream
void Configurator::config_get_command( string parameters, StreamOutput *stream )
{
    string source = shift_parameter(parameters);
    string setting = shift_parameter(parameters);
    if (setting == "") { // output settings from the config-cache
        setting = source;
        source = "";
        uint16_t setting_checksums[3];
        get_checksums(setting_checksums, setting );
        THEKERNEL->config->config_cache_load(); // need to load config cache first as it is unloaded after booting
        ConfigValue *cv = THEKERNEL->config->value(setting_checksums);
        if(cv != NULL && cv->found) {
            string value = cv->as_string();
            stream->printf( "cached: %s is set to %s\r\n", setting.c_str(), value.c_str() );
        } else {
            stream->printf( "cached: %s is not in config\r\n", setting.c_str());
        }
        THEKERNEL->config->config_cache_clear();

    } else { // output setting from specified source by parsing the config file
        uint16_t source_checksum = get_checksum( source );
        uint16_t setting_checksums[3];
        get_checksums(setting_checksums, setting );
        for(unsigned int i = 0; i < THEKERNEL->config->config_sources.size(); i++) {
            if( THEKERNEL->config->config_sources[i]->is_named(source_checksum) ) {
                string value = THEKERNEL->config->config_sources[i]->read(setting_checksums);
                if(value.empty()) {
                    stream->printf( "%s: %s is not in config\r\n", source.c_str(), setting.c_str() );
                } else {
                    stream->printf( "%s: %s is set to %s\r\n", source.c_str(), setting.c_str(), value.c_str() );
                }
                break;
            }
        }
    }
}
开发者ID:2thetop,项目名称:Smoothieware,代码行数:37,代码来源:Configurator.cpp

示例13: delSection

// This is a rather ugly and slow way to delete a section.  It can leave stray
// comments in the middle of sections, but will remove the section entirely,
// even if it is multiply declared.  This whole function was a bit of an
// afterthought, since it isn't very likely to be used in the application this
// class was written for.  Sorry to all the purists out there.  :-(
void SimpleConfig::delSection(std::string const &section_name) {
	ConfigDictionary::iterator i = m_last.find(section_name);
	if (i != m_last.end()) {
		ElementList rebuild;
		ElementList::iterator at;
		bool blank = false;
		for (at = m_elements.begin(); at != m_elements.end(); at++) {
			ConfigSection *section = dynamic_cast<ConfigSection *>(*at);
			if (section && section->getName() == section_name) {
				delete *at;
				continue;
			}
			ConfigValue *value = dynamic_cast<ConfigValue *>(*at);
			if (value && value->getSection() == section_name) {
				std::string index = _hash_index(section_name, value->getKey());
				ConfigDictionary::iterator i = m_dict.find(index);
				if (i != m_dict.end()) m_dict.erase(i);
				delete *at;
				continue;
			}
			ConfigComment *comment = dynamic_cast<ConfigComment *>(*at);
			if (comment && comment->getComment() == "") {
				if (blank) {
					delete *at;
					continue;
				}
				blank = true;
			} else blank = false;
			rebuild.push_back(*at);
		}
		m_elements = rebuild;
		m_modified = true;
		if (m_autosave) save();
		m_last.erase(i);
	}
}
开发者ID:,项目名称:,代码行数:41,代码来源:

示例14: ParseObject

bool json::Reader::ParseValue(ConfigValue& value)
{
	SkipSpaces();
	bool b = true;
	char c = *_cur;
	switch(c)
	{
	case '{':
		b = ParseObject(value);
		break;
	case '[':
		b = ParseArray(value);
		break;
	case '"':
		{
			std::string str;
			b = ParseString(str);
			if(b)
				value.SetString(str.c_str());
			else
				Error("Failed to parse string");
		}
		break;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case '-':
		b = ParseNumber(value);
		break;
	case 't': // true
		if(*(++_cur) != 'r' || *(++_cur) != 'u' || *(++_cur) != 'e')
		{
			Error("Expected \"true\"");
			return false;
		}
		++_cur;
		value.SetBool(true);
		break;
	case 'f': // false
		if(*(++_cur) != 'a' || *(++_cur) != 'l' || *(++_cur) != 's' || *(++_cur) != 'e')
		{
			Error("Expected \"false\"");
			return false;
		}
		++_cur;
		value.SetBool(false);
		break;
	case 'n': // null
		if(*(++_cur) != 'u' || *(++_cur) != 'l' || *(++_cur) != 'l')
		{
			Error("Expected \"null\"");
			return false;
		}
		++_cur;
		value.SetNull();
		break;
	default:
		b = false;
	};
	return b;
}
开发者ID:simeks,项目名称:m7017e-lab,代码行数:68,代码来源:json.cpp

示例15: switch

void json::Writer::WriteValue(const ConfigValue& node, std::stringstream& out)
{
	switch(node.Type())
	{
	case ConfigValue::NULL_VALUE:
		out << "null";
		break;
	case ConfigValue::BOOL:
		out << node.AsBool();
		break;
	case ConfigValue::INTEGER:
		out << node.AsInt64();
		break;
	case ConfigValue::UINTEGER:
		out << node.AsUInt64();
		break;
	case ConfigValue::FLOAT:
		out << node.AsDouble();
		break;
	case ConfigValue::STRING:
		out << "\"";
		json_internal::WriteString(node.AsString(), out);
		out << "\"";
		break;
	case ConfigValue::ARRAY:
		{
			out << "[";

			_ilevel++;
			int size = node.Size(); 
			for(int i = 0; i < size; ++i)
			{
				if(i != 0)
					out << ",";

				if(_format)
				{
					out << "\n";
					json_internal::WriteTabs(_ilevel, out);
				}
				WriteValue(node[i], out);
			}
			if(_format)
				out << "\n";
			_ilevel--;
			if(_format)
				json_internal::WriteTabs(_ilevel, out);
			out << "]";
		}
		break;
	case ConfigValue::OBJECT:
		{
			out << "{";
			_ilevel++;
			ConfigValue::ConstIterator it, end;
			it = node.Begin(); end = node.End();
			for( ; it != end; ++it)
			{
				if(it != node.Begin())
					out << ",";

				if(_format)
				{
					out << "\n";
					json_internal::WriteTabs(_ilevel, out);
				}
				out << "\"";
				json_internal::WriteString(it->first.c_str(), out);
				out << "\": ";
				WriteValue(it->second, out);
			}
			if(_format)
				out << "\n";
			_ilevel--;
			if(_format)
				json_internal::WriteTabs(_ilevel, out);
			out << "}";
		}
		break;
	};
}
开发者ID:simeks,项目名称:m7017e-lab,代码行数:81,代码来源:json.cpp


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