Beispiel #1
0
/**
 *  \brief Parse the xml definition of this widget setting the state of the
 *         object accordingly
 */
bool MythUIType::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    //FIXME add movement etc.

    if (element.tagName() == "position")
        SetPosition(parsePoint(element));
    else if (element.tagName() == "area")
    {
        SetArea(parseRect(element));
    }
    else if (element.tagName() == "minsize")
    {
        // Use parsePoint so percentages can be used
        if (element.hasAttribute("initiator"))
            m_Initiator = parseBool(element.attribute("initiator"));

        if (element.hasAttribute("vanish"))
            m_Vanish = parseBool(element.attribute("vanish"));

        SetMinSize(parsePoint(element));
    }
    else if (element.tagName() == "alpha")
    {
        m_Alpha = getFirstText(element).toInt();
        m_AlphaChangeMode = 0;
    }
    else if (element.tagName() == "alphapulse")
    {
        m_AlphaChangeMode = 2;
        m_AlphaMin = element.attribute("min", "0").toInt();
        m_Alpha = m_AlphaMax = element.attribute("max", "255").toInt();

        if (m_AlphaMax > 255)
            m_Alpha = m_AlphaMax = 255;

        if (m_AlphaMin < 0)
            m_AlphaMin = 0;

        m_AlphaChange = element.attribute("change", "5").toInt();
    }
    else if (element.tagName() == "focusorder")
    {
        int order = getFirstText(element).toInt();
        SetFocusOrder(order);
    }
    else if (element.tagName() == "loadondemand")
    {
        SetDeferLoad(parseBool(element));
    }
    else if (element.tagName() == "helptext")
    {
        m_helptext = getFirstText(element);
    }
    else
        return false;

    return true;
}
Beispiel #2
0
void Option::parse(int argc, char* argv[])
{
  if (argc == 1)
    return;

  for (int i = 1; i < argc; i++) {
    char* arg = argv[i];
    i++;
    if (strcmp(arg, "-v") == 0 || strcmp(arg, "--version") == 0) {
      printf("%s\n", VersionStr);
      printf("Written by Nakayama Shintaro\n");
      printf("Maintained by Pascal Malaise\n");
      exit(0);
    } else if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) {
      printf("Usage %s { [ <option> ] }\n", argv[0]);
      printf("<option> ::=\n");
      printf("  -s <positive> | --speed <positive>\n");
#ifdef SHAPE
      printf("  -r <boolean>  | --round-card <boolean>\n");
#endif
      printf("  -a <boolean>  | --animation <boolean>\n");
      printf("  -m <boolean>  | --ms-seed <boolean>\n");
      printf("  -p <boolean>  | --auto-play <boolean>\n");
      exit(0);
    } else if (strcmp(arg, "-s") == 0 || strcmp(arg, "--speed") == 0) {
      arg = argv[i];
      if (i == argc) goto ERRORI;
      _speedup = atoi(arg);
      if (0 > _speedup) goto ERRORI;
      continue;
    ERRORI:
      fprintf(stderr, "Positive integer must follow -s\n");
      exit (1);
    } else if (strcmp(arg, "-q") == 0 || strcmp(arg, "--query-window") == 0) {
      _queryWindow = parseBool(i, argc, argv);
#ifdef SHAPE
    } else if (strcmp(arg, "-r") == 0 || strcmp(arg, "--round-card") == 0) {
      _roundCard = parseBool(i, argc, argv);
#endif
    } else if (strcmp(arg, "-a") == 0 || strcmp(arg, "--animation") == 0) {
      _animation = parseBool(i, argc, argv);
    } else if (strcmp(arg, "-m") == 0 || strcmp(arg, "--ms-seed") == 0) {
      _msSeed = parseBool(i, argc, argv);
    } else if (strcmp(arg, "-p") == 0 || strcmp(arg, "--auto-play") == 0) {
      _autoPlay = parseBool(i, argc, argv);
    } else {
      fprintf(stderr, "Unknown option: %s\n", arg);
      exit (1);
    }
  }
}
Beispiel #3
0
void
EmsMessage::parseRCWWOpmodeMessage()
{
    parseBool(0, 1, EmsValue::EigenesProgrammAktiv, EmsValue::WW);
    parseBool(1, 1, EmsValue::EigenesProgrammAktiv, EmsValue::Zirkulation);

    parseEnum(2, EmsValue::Betriebsart, EmsValue::WW);
    parseEnum(3, EmsValue::Betriebsart, EmsValue::Zirkulation);

    parseBool(4, 1, EmsValue::Desinfektion, EmsValue::WW);
    parseEnum(5, EmsValue::DesinfektionTag, EmsValue::WW);
    parseInteger(6, 1, EmsValue::DesinfektionStunde, EmsValue::WW);
    parseNumeric(8, 1, 1, EmsValue::MaxTemp, EmsValue::WW);
    parseBool(9 ,1, EmsValue::EinmalLadungsLED, EmsValue::WW);
}
Beispiel #4
0
eResult ArchiverImpl::AutoAttach(unsigned int ulFlags)
{
	HRESULT hr = hrSuccess;
    m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "ArchiverImpl::AutoAttach() function entry");
	ArchiveStateCollectorPtr ptrArchiveStateCollector;
	ArchiveStateUpdaterPtr ptrArchiveStateUpdater;

	if (ulFlags != ArchiveManage::Writable && ulFlags != ArchiveManage::ReadOnly && ulFlags != 0) {
		hr = MAPI_E_INVALID_PARAMETER;
		goto exit;
	}

    m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "ArchiverImpl::AutoAttach() about to create collector");
	hr = ArchiveStateCollector::Create(m_ptrSession, m_lpLogger, &ptrArchiveStateCollector);
	if (hr != hrSuccess)
		goto exit;

    m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "ArchiverImpl::AutoAttach() about to get state updater");
	hr = ptrArchiveStateCollector->GetArchiveStateUpdater(&ptrArchiveStateUpdater);
	if (hr != hrSuccess)
		goto exit;

	if (ulFlags == 0) {
		if (parseBool(m_lpsConfig->GetSetting("auto_attach_writable")))
			ulFlags = ArchiveManage::Writable;
		else
			ulFlags = ArchiveManage::ReadOnly;
	}

    m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "ArchiverImpl::AutoAttach() about to call update all");
	hr = ptrArchiveStateUpdater->UpdateAll(ulFlags);

exit:
	return MAPIErrorToArchiveError(hr);
}
Beispiel #5
0
// FREE OPERATORS
JsonEntity* JsonParser::fromString( const std::string& rawJson )
{
    for( int i=0; i < rawJson.length(); i++ )
    {
      if( rawJson[i] == '[' )
      {
        i = parseArray( rawJson, i );
      }
      else if( rawJson[i] == 't' || rawJson[i] == 'f' )
      {
        i = parseBool( rawJson, i );
      }
      else if( rawJson[i] == '{' )
      {
        i = parseObject( rawJson, i );
      }
      else if( rawJson[i] == '-' || ( rawJson[i] >= '0' && rawJson[i] <= '9' ) )
      {
        i = parseNumber( rawJson, i );
      }
      else if( rawJson[i] == '"' )
      {
        i = parseString( rawJson, i );
      }
    }
}
Beispiel #6
0
bool getAttrib(const TiXmlElement* XMLNode, const gkString& attrib, bool& value)
{
	if (!XMLNode || !XMLNode->Attribute(attrib)) return false;

	value = parseBool(XMLNode->Attribute(attrib.c_str()));
	return true;
}
Beispiel #7
0
static void add(Setting_t type, Update_t update, const char* key, const char* val)
{
    Setting* const s = malloc(sizeof(Setting));

    s->type = type;
    s->update = update;

    switch(type) {
        case INT: {
            s->value[0].integer = atoi(val);
            s->value[1].integer = s->value[0].integer;
        } break;

        case BOOL: {
            s->value[0].boolean = parseBool(val);
            s->value[1].boolean = s->value[0].boolean;
        } break;

        case STR: {
            strncpy(s->value[0].string, val, sizeof(s->value[0].string) - 1);
            s->value[0].string[sizeof(s->value[0].string) - 1] = '\0';
            strcpy(s->value[1].string, s->value[0].string);
        } break;
    }

    a_strhash_add(settings, key, s);
}
bool ConfigReader::getBool(const std::string theSection,
	const std::string theName, const bool theDefault) const
{
	bool anResult = theDefault;

	// Check if theSection really exists
	std::map<const std::string, typeNameValue*>::const_iterator iter;
	iter = mSections.find(theSection);
	if (iter != mSections.end())
	{
		// Try to obtain the name, value pair
		typeNameValue* anMap = iter->second;
		if (NULL != anMap)
		{
			typeNameValueIter iterNameValue;
			iterNameValue = anMap->find(theName);
			if (iterNameValue != anMap->end())
			{
				anResult = parseBool(iterNameValue->second, theDefault);
			}
		}
	}

	// Return the result found or theDefault assigned above
	return anResult;
}
Beispiel #9
0
bool Properties::getBool(const std::string& key, bool defaultValue,
						 bool terse) const
{
    bool result;  
    const_iterator iter = find(key);

    if (iter == end()) {
        if (terse) {
	    Log::log(logID, Log::LOG_MAX_DEBUG,
	         "No value specified for key %s, using default value.", 
			key.c_str());
        }
	result = defaultValue;
    } else {
	try {
	    result = parseBool(key, iter->second);
        } catch (...) {
            if (terse) {
	        Log::log(logID, Log::LOG_MAX_DEBUG,
		  "Invalid value specified for key %s, using default value.", 
		      key.c_str());
            }
            result = defaultValue;
	}
    }

    return result;
}
bool ConfigReader::getBool(const std::string theSection,
    const std::string theName, const bool theDefault) const
{
    bool anResult = theDefault;

    // Comprueba si la sección existe
    std::map<const std::string, typeNameValue*>::const_iterator iter;
    iter = this->sections.find(theSection);
    if (iter != this->sections.end())
    {
        // Intenta obtener el par <clave, valor>
        typeNameValue* anMap = iter->second;
        if (NULL != anMap)
        {
            typeNameValueIter iterNameValue;
            iterNameValue = anMap->find(theName);
            if (iterNameValue != anMap->end())
            {
                anResult = parseBool(iterNameValue->second, theDefault);
            }
        }
    }

    // Devuelve el resultado encontrado o el valor de theDefault
    return anResult;
}
Beispiel #11
0
static void set(const char* key, const char* val, bool respect)
{
    Setting* const s = a_strhash_get(settings, key);

    if(s == NULL) {
        a_error("Setting '%s' does not exist", key);
        return;
    } else if(respect
        && (s->update == SET_FROZEN || (s->update == SET_ONCE && frozen))) {
        a_error("Setting '%s' is frozen", key);
        return;
    }

    switch(s->type) {
        case INT: {
            s->value[1].integer = s->value[0].integer;
            s->value[0].integer = atoi(val);
        } break;

        case BOOL: {
            s->value[1].boolean = s->value[0].boolean;
            s->value[0].boolean = parseBool(val);
        } break;

        case STR: {
            strcpy(s->value[1].string, s->value[0].string);
            strncpy(s->value[0].string, val, sizeof(s->value[0].string) - 1);
        } break;
    }

    if(s->update == SET_ONCE) {
        s->update = SET_FROZEN;
    }
}
Beispiel #12
0
void
EmsMessage::parseRCHKOpmodeMessage(EmsValue::SubType subtype)
{
    parseEnum(0, EmsValue::HeizArt, subtype);
    parseNumeric(1, 1, 2, EmsValue::NachtTemp, subtype);
    parseNumeric(2, 1, 2, EmsValue::TagTemp, subtype);
    parseNumeric(3, 1, 2, EmsValue::UrlaubTemp, subtype);
    parseNumeric(4, 1, 2, EmsValue::RaumEinfluss, subtype);
    parseNumeric(6, 1, 2, EmsValue::RaumOffset, subtype);
    parseEnum(7, EmsValue::Betriebsart, subtype);
    parseNumeric(16, 1, 1, EmsValue::MinTemp, subtype);
    parseNumeric(35, 1, 1, EmsValue::MaxTemp, subtype);
    parseBool(19, 1, EmsValue::SchaltzeitOptimierung, subtype);
    parseNumeric(22, 1, 1, EmsValue::SchwelleSommerWinter, subtype);
    parseNumeric(23, 1, 1, EmsValue::FrostSchutzTemp, subtype);
    parseEnum(25, EmsValue::RegelungsArt, subtype);
    parseEnum(28, EmsValue::Frostschutz, subtype);
    parseEnum(32, EmsValue::HeizSystem, subtype);
    parseEnum(33, EmsValue::FuehrungsGroesse, subtype);
    parseNumeric(36, 1, 1, EmsValue::AuslegungsTemp, subtype);
    parseNumeric(37, 1, 2, EmsValue::RaumUebersteuerTemp, subtype);
    parseNumeric(38, 1, 1, EmsValue::AbsenkungsAbbruchTemp, subtype);
    parseNumeric(39, 1, 1, EmsValue::AbsenkungsSchwellenTemp, subtype);
    parseNumeric(40, 1, 1, EmsValue::UrlaubAbsenkungsSchwellenTemp, subtype);
    parseEnum(41, EmsValue::UrlaubAbsenkungsArt, subtype);
}
Beispiel #13
0
void
EmsMessage::parseRCSystemParameterMessage()
{
    parseNumeric(5, 1, 1, EmsValue::MinTemp, EmsValue::Aussen);
    parseEnum(6, EmsValue::GebaeudeArt, EmsValue::None);
    parseBool(21, 1, EmsValue::ATDaempfung, EmsValue::None);
}
Beispiel #14
0
void
EmsMessage::parseWMTemp1Message()
{
    parseNumeric(0, 2, 10, EmsValue::IstTemp, EmsValue::HK1);

    /* Byte 2 = 0 -> Pumpe aus, 100 = 0x64 -> Pumpe an */
    parseBool(2, 2, EmsValue::PumpeAktiv, EmsValue::HK1);
}
Beispiel #15
0
bool getValue(const TiXmlElement* XMLNode, bool& value)
{
	if (!XMLNode || !XMLNode->GetText()) 
		return false;
	
	value = parseBool(XMLNode->GetText());
	return true;
}
Beispiel #16
0
bool
CJString::
toBoolean() const
{
  COptBool b = parseBool(text_);

  return b.getValue(false);
}
Beispiel #17
0
void
EmsMessage::parseUBAParameterWWMessage()
{
    parseBool(1, 0, EmsValue::KesselSchalter, EmsValue::WW);
    parseNumeric(2, 1, 1, EmsValue::SetTemp, EmsValue::WW);
    parseNumeric(8, 1, 1, EmsValue::DesinfektionsTemp, EmsValue::WW);
    parseEnum(7,EmsValue::Schaltpunkte, EmsValue::Zirkulation);
}
bool ConfigManager::getBool(const String &key, const String &domName) const {
	String value(get(key, domName));
	bool val;
	if (parseBool(value, val))
		return val;

	error("ConfigManager::getBool(%s,%s): '%s' is not a valid bool",
	      key.c_str(), domName.c_str(), value.c_str());
}
Beispiel #19
0
/*
 * Throws 
 *	std::invalid_argument if a value for key is not found.
 *	std::domain_error if value does not have a boolean value of  
 *	    "true", "yes", "on", "false", "no", "off", all case insensitive.
 */
bool Properties::getBool(const std::string& key) const
{
    const_iterator iter = find(key);

    if (iter == end()) {
        throw std::invalid_argument(key + " not found");
    }
    return parseBool(key, iter->second);
}
Beispiel #20
0
bool AbstractConfiguration::getBool(const std::string& key) const
{
	Mutex::ScopedLock lock(_mutex);

	std::string value;
	if (getRaw(key, value))
		return parseBool(internalExpand(value));
	else
		throw NotFoundException(key);
}
Beispiel #21
0
void
EmsMessage::parseMMTempMessage()
{
    parseNumeric(0, 1, 1, EmsValue::SollTemp, EmsValue::HK2);
    parseNumeric(1, 2, 10, EmsValue::IstTemp, EmsValue::HK2);
    parseNumeric(3, 1, 1, EmsValue::Mischersteuerung, EmsValue::None);

    /* Byte 3 = 0 -> Pumpe aus, 100 = 0x64 -> Pumpe an */
    parseBool(3, 2, EmsValue::PumpeAktiv, EmsValue::HK2);
}
Beispiel #22
0
bool AbstractConfiguration::getBool(const std::string& key, bool defaultValue) const
{
	Mutex::ScopedLock lock(_mutex);

	std::string value;
	if (getRaw(key, value))
		return parseBool(internalExpand(value));
	else
		return defaultValue;
}
  bool Configuration::getBool(const String &key) const {
    ASSERT(!key.empty());
    if(key.empty())
      throw IllegalArgumentException("Property key is not valid");

    String value;
    if (getUnparsedString(key, value))
      return parseBool(value);

    throw NoSuchPropertyException("Property not found: " + key);
  }
  bool Configuration::getBool(const String &key, const bool defaultValue) const {
    ASSERT(!key.empty());
    if(key.empty())
      throw IllegalArgumentException("Property key is not valid");

    String value;
    if (getUnparsedString(key, value))
      return parseBool(value);

    return defaultValue;
  }
Beispiel #25
0
void
EmsMessage::parseUBAMonitorFastMessage()
{
    parseNumeric(0, 1, 1, EmsValue::SollTemp, EmsValue::Kessel);
    parseNumeric(1, 2, 10, EmsValue::IstTemp, EmsValue::Kessel);
    parseNumeric(11, 2, 10, EmsValue::IstTemp, EmsValue::WW);
    parseNumeric(13, 2, 10, EmsValue::IstTemp, EmsValue::Ruecklauf);
    parseNumeric(3, 1, 1, EmsValue::SollModulation, EmsValue::Brenner);
    parseNumeric(4, 1, 1, EmsValue::IstModulation, EmsValue::Brenner);
    parseNumeric(15, 2, 10, EmsValue::Flammenstrom, EmsValue::None);
    parseNumeric(17, 1, 10, EmsValue::Systemdruck, EmsValue::None);

    if (canAccess(18, 2)) {
	std::ostringstream ss;
	ss << m_data[18] << m_data[19];
	m_valueHandler(EmsValue(EmsValue::ServiceCode, EmsValue::None, ss.str()));
    }
    if (canAccess(20, 2)) {
	std::ostringstream ss;
	ss << std::dec << (m_data[20] << 8 | m_data[21]);
	m_valueHandler(EmsValue(EmsValue::FehlerCode, EmsValue::None, ss.str()));
    }

    parseBool(7, 0, EmsValue::FlammeAktiv, EmsValue::None);
    parseBool(7, 2, EmsValue::BrennerAktiv, EmsValue::None);
    parseBool(7, 3, EmsValue::ZuendungAktiv, EmsValue::None);
    parseBool(7, 5, EmsValue::PumpeAktiv, EmsValue::Kessel);
    parseBool(7, 6, EmsValue::DreiWegeVentilAufWW, EmsValue::None);
    parseBool(7, 7, EmsValue::ZirkulationAktiv, EmsValue::None);
}
Beispiel #26
0
void
EmsMessage::parseUBAParametersMessage()
{
    parseBool(0, 1, EmsValue::KesselSchalter, EmsValue::Kessel);
    parseNumeric(1, 1, 1, EmsValue::SetTemp, EmsValue::Kessel);
    parseNumeric(2, 1, 1, EmsValue::MaxModulation, EmsValue::Brenner);
    parseNumeric(3, 1, 1, EmsValue::MinModulation, EmsValue::Brenner);
    parseNumeric(4, 1, 1, EmsValue::AusschaltHysterese, EmsValue::Kessel);
    parseNumeric(5, 1, 1, EmsValue::EinschaltHysterese, EmsValue::Kessel);
    parseInteger(6, 1, EmsValue::AntipendelZeit, EmsValue::None);
    parseInteger(8, 1, EmsValue::NachlaufZeit, EmsValue::KesselPumpe);
    parseNumeric(9, 1, 1, EmsValue::MaxModulation, EmsValue::KesselPumpe);
    parseNumeric(10, 1, 1, EmsValue::MinModulation, EmsValue::KesselPumpe);
}
Beispiel #27
0
bool MythUIStateType::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    QMap<QString, QString> dependsMap;
    if (element.tagName() == "showempty")
        m_ShowEmpty = parseBool(element);
    else if (element.tagName() == "state")
    {
        QString name = element.attribute("name", "");
        QString type = element.attribute("type", "");

        QString statename;

        if (!type.isEmpty())
            statename = type;
        else
            statename = name;

        element.setAttribute("name", statename);

        MythUIGroup *uitype = dynamic_cast<MythUIGroup *>
                              (ParseUIType(filename, element, "group", this, NULL, showWarnings, dependsMap));

        if (!type.isEmpty())
        {
            StateType stype = None;

            if (type == "off")
                stype = Off;
            else if (type == "half")
                stype = Half;
            else if (type == "full")
                stype = Full;

            if (uitype && !m_ObjectsByState.contains((int)stype))
                AddObject(stype, uitype);
        }
        else if (!name.isEmpty())
        {
            if (uitype && !m_ObjectsByName.contains(name))
                AddObject(name, uitype);
        }
    }
    else
    {
        return MythUIType::ParseElement(filename, element, showWarnings);
    }

    return true;
}
Beispiel #28
0
void
EmsMessage::parseUBAMonitorWWMessage()
{
    parseNumeric(0, 1, 1, EmsValue::SollTemp, EmsValue::WW);
    parseNumeric(1, 2, 10, EmsValue::IstTemp, EmsValue::WW);
    parseInteger(10, 3, EmsValue::WarmwasserbereitungsZeit, EmsValue::None);
    parseInteger(13, 3, EmsValue::WarmwasserBereitungen, EmsValue::None);

    parseBool(5, 0, EmsValue::Tagbetrieb, EmsValue::WW);
    parseBool(5, 1, EmsValue::EinmalLadungAktiv, EmsValue::WW);
    parseBool(5, 2, EmsValue::DesinfektionAktiv, EmsValue::WW);
    parseBool(5, 3, EmsValue::WarmwasserBereitung, EmsValue::None);
    parseBool(5, 4, EmsValue::NachladungAktiv, EmsValue::WW);
    parseBool(5, 5, EmsValue::WarmwasserTempOK, EmsValue::None);
    parseBool(7, 0, EmsValue::Tagbetrieb, EmsValue::Zirkulation);
    parseBool(7, 2, EmsValue::ZirkulationAktiv, EmsValue::None);

    parseEnum(8, EmsValue::WWSystemType, EmsValue::None);
}
Beispiel #29
0
bool testParseBool(void) {
  if(!parseBool("true")) {
    printf("'true' is not true\n");
    return false;
  }

  if(!parseBool("True")) {
    printf("'True' is not true\n");
    return false;
  }

  if(!parseBool("TRUE")) {
    printf("'TRUE' is not true\n");
    return false;
  }
  
  if(parseBool("false")) {
    printf("'false' is not false\n");
    return false;
  }

  if(parseBool("blort")) {
    printf("'blort' is not false\n");
    return false;
  }

  if(parseBool("")) {
    printf("'' is not false\n");
    return false;
  }

  if(parseBool(NULL)) {
    printf("NULL is not false\n");
    return false;
  }

  if(parseBool(0)) {
    printf("0 is not false\n");
    return false;
  }
  
  return true;
}
Beispiel #30
0
bool MythUIStateType::ParseElement(QDomElement &element)
{
    if (element.tagName() == "showempty")
        m_ShowEmpty = parseBool(element);
    else if (element.tagName() == "state")
    {
        QString name = element.attribute("name", "").lower();
        QString type = element.attribute("type", "").lower();

        MythUIType *uitype = ParseChildren(element, this);

        if (!type.isEmpty())
        {
            StateType stype = None;
            if (type == "off")
                stype = Off;
            else if (type == "half")
                stype = Half;
            else if (type == "full")
                stype = Full;

            if (uitype && m_ObjectsByState.contains((int)stype))
            {
                delete m_ObjectsByState[(int)stype];
                m_ObjectsByState.erase((int)stype);
            }
            AddObject(stype, uitype);
        }
        else if (!name.isEmpty())
        {
            if (uitype && m_ObjectsByName.contains(name))
            {
                delete m_ObjectsByName[name];
                m_ObjectsByName.erase(name);
            }
            AddObject(name, uitype);
        }
    }
    else
        return MythUIType::ParseElement(element);

    return true;
}