Skip to content
Snippets Groups Projects
Commit 47dbbc7f authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #8968: yaml: avoid C-style pointer casts

parent b3eaf79d
Branches
Tags
No related merge requests found
......@@ -266,7 +266,7 @@ void YamlEmitter::serializeShortcutPreference(MappingNode *map)
void YamlEmitter::addMappingItem(int mappingid, std::string key, YamlNode *node)
{
if (node->getType() == SCALAR) {
ScalarNode *sclr = (ScalarNode *) node;
ScalarNode *sclr = static_cast<ScalarNode *>(node);
int temp1;
if ((temp1 = yaml_document_add_scalar(&document_, NULL, (yaml_char_t *) key.c_str(), -1, YAML_PLAIN_SCALAR_STYLE)) == 0)
......@@ -280,7 +280,7 @@ void YamlEmitter::addMappingItem(int mappingid, std::string key, YamlNode *node)
throw YamlEmitterException("Could not append mapping pair to mapping");
} else if (node->getType() == MAPPING) {
MappingNode *map = (MappingNode *) node;
MappingNode *map = static_cast<MappingNode *>(node);
int temp1;
if ((temp1 = yaml_document_add_scalar(&document_, NULL, (yaml_char_t *) key.c_str(), -1, YAML_PLAIN_SCALAR_STYLE)) == 0)
......
......@@ -123,7 +123,7 @@ YamlNode *MappingNode::getValue(const std::string &key)
void MappingNode::getValue(const std::string &key, bool *b)
{
ScalarNode *node = (ScalarNode*)getValue(key);
ScalarNode *node = static_cast<ScalarNode*>(getValue(key));
if (!node)
return;
......@@ -134,18 +134,16 @@ void MappingNode::getValue(const std::string &key, bool *b)
void MappingNode::getValue(const std::string &key, int *i)
{
ScalarNode *node = (ScalarNode*)getValue(key);
ScalarNode *node = static_cast<ScalarNode*>(getValue(key));
if (!node)
return;
const std::string &v = node->getValue();
*i = atoi(v.c_str());
*i = atoi(node->getValue().c_str());
}
void MappingNode::getValue(const std::string &key, std::string *v)
{
ScalarNode *node = (ScalarNode*)getValue(key);
ScalarNode *node = static_cast<ScalarNode*>(getValue(key));
if (!node)
return;
......
......@@ -70,7 +70,7 @@ class YamlNode {
};
class YamlDocument : YamlNode {
class YamlDocument : public YamlNode {
public:
YamlDocument(YamlNode* top=NULL) : YamlNode(DOCUMENT, top), doc() {}
......
......@@ -227,13 +227,13 @@ void YamlParser::processDocument()
for (; (eventIndex_ < eventNumber_) and (events_[eventIndex_].type != YAML_DOCUMENT_END_EVENT); ++eventIndex_) {
switch (events_[eventIndex_].type) {
case YAML_SCALAR_EVENT:
processScalar((YamlNode *) doc_);
processScalar(doc_);
break;
case YAML_SEQUENCE_START_EVENT:
processSequence((YamlNode *) doc_);
processSequence(doc_);
break;
case YAML_MAPPING_START_EVENT:
processMapping((YamlNode *) doc_);
processMapping(doc_);
break;
default:
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment