51 const std::string key = attrs.
get<std::string>(
SUMO_ATTR_KEY,
nullptr, parsedOk);
55 if ((SumoBaseObjectParent ==
nullptr) || (SumoBaseObjectParent->getTag() ==
SUMO_TAG_ROOTFILE)) {
56 writeError(
TL(
"Parameters must be defined within an object"));
58 writeError(
TL(
"Parameters cannot be defined within another parameter."));
59 }
else if ((SumoBaseObjectParent->getTag() !=
SUMO_TAG_NOTHING) && parsedOk) {
61 const std::string parentTagStr =
toString(SumoBaseObjectParent->getTag());
66 writeError(
TLF(
"Error parsing key from % generic parameter. Key cannot be empty", parentTagStr));
68 writeError(
TLF(
"Error parsing key from % generic parameter. Key contains invalid characters", parentTagStr));
70 WRITE_DEBUG(
"Inserting generic parameter '" + key +
"|" + value +
"' into " + parentTagStr);
72 SumoBaseObjectParent->addParameter(key, value);
80 if (parentTags.size() > 0) {
82 for (
auto it = parentTags.begin(); it != parentTags.end(); it++) {
84 if ((it+1) != parentTags.end()) {
85 if ((it+2) != parentTags.end()) {
88 tagsStr.append(
" or ");
94 if (parent ==
nullptr) {
95 ok =
writeError(
TLF(
"'%' must be defined within the definition of a %.",
toString(currentTag), tagsStr));
96 }
else if ((parent->
getTag() !=
SUMO_TAG_NOTHING) && std::find(parentTags.begin(), parentTags.end(), parent->
getTag()) == parentTags.end()) {
98 ok =
writeError(
TLF(
"'%' must be defined within the definition of a '%' (found % '%').",
toString(currentTag), tagsStr,
101 ok =
writeError(
TLF(
"'%' must be defined within the definition of a '%' (found %).",
toString(currentTag), tagsStr,
111 for (
const auto& vTypeID : vTypeIDs) {
113 return writeError(
TLF(
"Could not build % with ID '%' in netedit; '%' ist not a valid vType ID.",
toString(tag),
id, vTypeID));
130 return writeError(
TLF(
"Could not build % with ID '%' in netedit; Attribute % must be greather than zero.",
toString(tag),
id,
toString(attribute)));
189 return writeError(
TLF(
"Could not build % with ID '%' in netedit; ID contains invalid characters.",
toString(tag), value));
201 return writeError(
TLF(
"Could not build % with ID '%' in netedit; detector ID contains invalid characters.",
toString(tag), value));
213 return writeError(
TLF(
"Could not build % with ID '%' in netedit; ID contains invalid characters.",
toString(tag), value));
230 return writeError(
TLF(
"Could not build % with ID '%' in netedit; Invalid position over lane.",
toString(tag),
id));
236 return writeError(
TLF(
"Could not build % with ID '%' in netedit; Found another % with the same ID.",
toString(tag),
id,
toString(checkedTag)));
242 return writeError(
TLF(
"Could not build % with ID '%' in netedit; List of lanes isn't valid.",
toString(tag),
id));
248 return writeError(
TLF(
"Could not build % with ID '%' in netedit; Distinct number of distribution values and probabilities.",
toString(tag),
id));
254 return writeError(
TLF(
"Could not build % with ID '%' in netedit; % parent with ID '%' doesn't exist.",
toString(tag),
id,
toString(parentTag), parentID));
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_ROOTFILE
root file
@ SUMO_TAG_PARAM
parameter associated to a certain key
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool writeErrorInvalidDistribution(const SumoXMLTag tag, const std::string &id)
write error "invalid distribution"
virtual ~CommonHandler()
Destructor.
void checkParsedParent(const SumoXMLTag currentTag, const std::vector< SumoXMLTag > &parentTags, bool &ok)
bool writeError(const std::string &error)
write error and enable error creating element
bool myErrorCreatingElement
flag for mark if a element wasn't created
CommonHandler()
Constructor.
bool checkValidDetectorID(const SumoXMLTag tag, const std::string &value)
check if the given detector ID is valid
bool writeErrorInvalidParent(const SumoXMLTag tag, const std::string &id, const SumoXMLTag parentTag, const std::string &parentID)
write error "invalid parent element" giving ids of current and parent element
bool checkListOfVehicleTypes(const SumoXMLTag tag, const std::string &id, const std::vector< std::string > &vTypeIDs)
check list of IDs
void parseParameters(const SUMOSAXAttributes &attrs)
parse generic parameters
bool writeErrorDuplicated(const SumoXMLTag tag, const std::string &id, const SumoXMLTag checkedTag)
write error "duplicated additional"
bool checkValidAdditionalID(const SumoXMLTag tag, const std::string &value)
check if the given additional ID is valid
bool checkFileName(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute, const std::string &value)
check if the given filename is valid
bool writeErrorInvalidPosition(const SumoXMLTag tag, const std::string &id)
write error "invalid position"
CommonXMLStructure myCommonXMLStructure
common XML Structure
bool writeErrorInvalidLanes(const SumoXMLTag tag, const std::string &id)
write error "invalid list of lanes"
bool checkNegative(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute, const int value, const bool canBeZero)
check if the given int value is NOT negative
bool checkValidDemandElementID(const SumoXMLTag tag, const std::string &value)
check if the given demand elmement ID is valid
bool isErrorCreatingElement() const
get flag for mark if a element wasn't created
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
SumoXMLTag getTag() const
get XML myTag
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
CommonXMLStructure::SumoBaseObject * getCurrentSumoBaseObject() const
get current editedSumoBaseObject
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
static bool isValidDetectorID(const std::string &value)
whether the given string is a valid id for an detector
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter