Пример #1
0
void FarHrcSettings::UpdatePrototype(xercesc::DOMElement* elem, bool userValue)
{
  const XMLCh* tagProtoAttrParamName = L"name";
  const XMLCh* tagParam = L"param";
  const XMLCh* tagParamAttrParamName = L"name";
  const XMLCh* tagParamAttrParamValue = L"value";
  const XMLCh* tagParamAttrParamDescription = L"description";
  const XMLCh* typeName = elem->getAttribute(tagProtoAttrParamName);
  if (typeName == nullptr) {
    return;
  }
  HRCParser* hrcParser = parserFactory->getHRCParser();
  DString typenamed = DString(typeName);
  FileTypeImpl* type = static_cast<FileTypeImpl*>(hrcParser->getFileType(&typenamed));
  if (type == nullptr) {
    return;
  }

  for (xercesc::DOMNode* node = elem->getFirstChild(); node != nullptr; node = node->getNextSibling()) {
    if (node->getNodeType() == xercesc::DOMNode::ELEMENT_NODE) {
      xercesc::DOMElement* subelem = static_cast<xercesc::DOMElement*>(node);
      if (xercesc::XMLString::equals(subelem->getNodeName(), tagParam)) {
        const XMLCh* name = subelem->getAttribute(tagParamAttrParamName);
        const XMLCh* value = subelem->getAttribute(tagParamAttrParamValue);
        const XMLCh* descr = subelem->getAttribute(tagParamAttrParamDescription);

        if (*name == '\0' || *value == '\0') {
          continue;
        }

        if (type->getParamValue(DString(name)) == nullptr) {
          type->addParam(new SString(DString(name)));
        }
        if (descr != nullptr) {
          type->setParamDescription(DString(name), new SString(DString(descr)));
        }
        if (userValue) {
          type->setParamValue(DString(name), new SString(DString(value)));
        } else {
          delete type->getParamDefaultValue(DString(name));
          type->setParamDefaultValue(DString(name), new SString(DString(value)));
        }
      }
    }
  }
}
Пример #2
0
void FarHrcSettings::readProfileFromRegistry()
{
  HRCParser* hrcParser = parserFactory->getHRCParser();

  SettingsControl ColorerSettings;
  size_t hrc_subkey;
  hrc_subkey = ColorerSettings.rGetSubKey(0, HrcSettings);
  FarSettingsEnum fse;
  fse.StructSize = sizeof(FarSettingsEnum);
  // enum all the sections in HrcSettings
  if (ColorerSettings.rEnum(hrc_subkey, &fse)) {
    for (size_t i = 0; i < fse.Count; i++) {
      if (fse.Items[i].Type == FST_SUBKEY) {
        //check whether we have such a scheme
        DString named = DString(fse.Items[i].Name);
        FileTypeImpl* type = static_cast<FileTypeImpl*>(hrcParser->getFileType(&named));
        if (type) {
          // enum all params in the section
          size_t type_subkey;
          type_subkey = ColorerSettings.rGetSubKey(hrc_subkey, fse.Items[i].Name);
          FarSettingsEnum type_fse;
          type_fse.StructSize = sizeof(FarSettingsEnum);
          if (ColorerSettings.rEnum(type_subkey, &type_fse)) {
            for (size_t j = 0; j < type_fse.Count; j++) {
              if (type_fse.Items[j].Type == FST_STRING) {
                DString name_fse= DString(type_fse.Items[j].Name);
                if (type->getParamValue(name_fse) == nullptr) {
                  type->addParam(&name_fse);
                }
                const wchar_t* p = ColorerSettings.Get(type_subkey, type_fse.Items[j].Name, static_cast<wchar_t*>(nullptr));
                if (p) {
                  type->setParamValue(DString(type_fse.Items[j].Name), &DString(p));
                }
              }
            }
          }
        }
      }
    }
  }
}
Пример #3
0
void FarHrcSettings::UpdatePrototype(Element *elem, bool userValue)
{
  const String *typeName = elem->getAttribute(DString("name"));
  if (typeName == null){
    return;
  }
  HRCParser *hrcParser = parserFactory->getHRCParser();
  FileTypeImpl *type = (FileTypeImpl *)hrcParser->getFileType(typeName);
  if (type== null){
    return;
  };
  for(Node *content = elem->getFirstChild(); content != null; content = content->getNextSibling()){
    if (*content->getNodeName() == "param"){
      const String *name = ((Element*)content)->getAttribute(DString("name"));
      const String *value = ((Element*)content)->getAttribute(DString("value"));
      const String *descr = ((Element*)content)->getAttribute(DString("description"));
      if (name == null || value == null){
        continue;
      };

      if (type->getParamValue(SString(name))==null){
        type->addParam(name);
      }
      if (descr != null){
        type->setParamDescription(SString(name), descr);
      }
      if (userValue){
        delete type->getParamNotDefaultValue(DString(name));
        type->setParamValue(SString(name), value);
      }
      else{
        delete type->getParamDefaultValue(DString(name));
        type->setParamDefaultValue(SString(name), value);
      }
    };
  };
}