Example #1
0
int
GNEAttributeCarrier::getHigherNumberOfAttributes() {
    int higherNumber = 0;
    for(std::vector<SumoXMLTag>::const_iterator i = allowedTags().begin(); i != allowedTags().end(); i++) {
        if((int)allowedAttributes(*i).size() > higherNumber) {
            higherNumber = (int)allowedAttributes(*i).size();
        }
    }
    return higherNumber;
}
Example #2
0
bool
GNEAttributeCarrier::isBool(SumoXMLAttr attr) {
    // Iterate over additional tags
    for(std::vector<SumoXMLTag>::const_iterator i = allowedTags().begin(); i != allowedTags().end(); i++) {
        // Obtain choices
        std::vector<std::string> choices = discreteChoices(*i, attr);
        // CHeck if choices are exactly "true" and "false"
        if ((choices.size() == 2) && (choices.at(0) == "true") && (choices.at(1) == "false")) {
            return true;
        }
    }
    return false;
}
Example #3
0
save::State
Consumer::endGame(TagSet const& tags)
{
	unsigned dataOffset = m_strm.tellp();

	encodeTextSection();
	encodeDataSection(engines());
	encodeTags(tags, allowedTags(), allowExtraTags());

	ByteStream::set(m_strm.base() + m_streamPos, uint24_t(dataOffset));
	m_stream.provide();

	return m_codec.addGame(m_stream, tags, *this);
}
Example #4
0
save::State
Consumer::endGame(TagSet const& tags)
{
	TagSet const* tagSet = &tags;
	TagSet* myTags = 0;

	if (m_text.tellp() > 0 && m_lastCommentPos == plyCount() && !tags.contains(tag::Termination))
	{
		result::ID result = result::fromString(tags.value(tag::Result));

		if (result == result::White || result == result::Black)
		{
			Byte const* s = m_text.data() + m_text.tellp() - 1;

			while (s > m_text.base() && s[-1])
				--s;

			if (	::strcasecmp(reinterpret_cast<char const*>(s), "time") == 0
				|| ::strcasecmp(reinterpret_cast<char const*>(s), "time/") == 0
				|| ::strcasecmp(reinterpret_cast<char const*>(s), "time!") == 0
				|| ::strcasecmp(reinterpret_cast<char const*>(s), "time forfeit") == 0)
			{
				myTags = new TagSet(tags);
				myTags->set(tag::Termination, termination::toString(termination::TimeForfeit));
				tagSet = myTags;
			}
		}
	}

	unsigned dataOffset = m_strm.tellp();

	encodeTextSection();
	encodeDataSection(engines());
	encodeTags(*tagSet, allowedTags(), allowExtraTags());
	ByteStream::set(m_strm.base() + m_streamPos, uint24_t(dataOffset));

	m_stream.provide();
	save::State state = m_codec.addGame(m_stream, *tagSet, *this);

	if (myTags)
		delete myTags;

	return state;
}