diff --git a/XdmfAttribute.cpp b/XdmfAttribute.cpp index 30e01512b3cc15997f2ae6c17c403b647b3fbf4d..c7bb5240f887815f8a956bef6124fe7bd04c8a3e 100644 --- a/XdmfAttribute.cpp +++ b/XdmfAttribute.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfAttributeType.hpp" @@ -56,7 +57,7 @@ std::map XdmfAttribute::getItemProperties() const { std::map attributeProperties; - attributeProperties["Name"] = mName; + attributeProperties.insert(std::make_pair("Name", mName)); mType->getProperties(attributeProperties); mCenter->getProperties(attributeProperties); return attributeProperties; @@ -82,7 +83,7 @@ XdmfAttribute::getType() const void XdmfAttribute::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); @@ -93,7 +94,9 @@ XdmfAttribute::populateItem(const std::map & itemPrope mName = name->second; } else { - XdmfError::message(XdmfError::FATAL,"'Name' not found in itemProperties in XdmfAttribute::populateItem"); + XdmfError::message(XdmfError::FATAL, + "'Name' not found in itemProperties in " + "XdmfAttribute::populateItem"); } mCenter = XdmfAttributeCenter::New(itemProperties); @@ -104,8 +107,8 @@ XdmfAttribute::populateItem(const std::map & itemPrope ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { this->swap(array); + break; } - // TODO: If multiple dataitems. } } diff --git a/XdmfAttribute.hpp b/XdmfAttribute.hpp index e9713145eeea346e127d81b82b98aaef868fa89c..761b878b09b3c16e89d6361846e8bad3e080a182 100644 --- a/XdmfAttribute.hpp +++ b/XdmfAttribute.hpp @@ -109,7 +109,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfAttributeCenter.cpp b/XdmfAttributeCenter.cpp index bb903be193ccb05268241bd3223c7901de480c76..4740268a0c2fc11ac5f7824240221953fe28a9ca 100644 --- a/XdmfAttributeCenter.cpp +++ b/XdmfAttributeCenter.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfAttributeCenter.hpp" #include "XdmfError.hpp" @@ -79,37 +80,38 @@ XdmfAttributeCenter::New(const std::map & itemProperti { std::map::const_iterator center = itemProperties.find("Center"); - if(center != itemProperties.end()) { - const std::string centerVal = center->second; - if(centerVal.compare("Grid") == 0) { - return Grid(); - } - else if(centerVal.compare("Cell") == 0) { - return Cell(); - } - else if(centerVal.compare("Face") == 0) { - return Face(); - } - else if(centerVal.compare("Edge") == 0) { - return Edge(); - } - else if(centerVal.compare("Node") == 0) { - return Node(); - } - else { - XdmfError::message(XdmfError::FATAL, - "Center not of 'Grid','Cell','Face','Edge','Node' " - "in XdmfAttributeCenter::New"); - } + if(center == itemProperties.end()) { + XdmfError::message(XdmfError::FATAL, + "'Center' not found in itemProperties in " + "XdmfAttributeCenter::New"); } + const std::string & centerVal = center->second; + + if(centerVal.compare("Node") == 0) { + return Node(); + } + else if(centerVal.compare("Cell") == 0) { + return Cell(); + } + else if(centerVal.compare("Grid") == 0) { + return Grid(); + } + else if(centerVal.compare("Face") == 0) { + return Face(); + } + else if(centerVal.compare("Edge") == 0) { + return Edge(); + } + XdmfError::message(XdmfError::FATAL, - "'Center' not found in itemProperties in " - "XdmfAttributeCenter::New"); + "Center not of 'Grid','Cell','Face','Edge','Node' " + "in XdmfAttributeCenter::New"); + return shared_ptr(); } void XdmfAttributeCenter::getProperties(std::map & collectedProperties) const { - collectedProperties["Center"] = mName; + collectedProperties.insert(std::make_pair("Center", mName)); } diff --git a/XdmfAttributeType.cpp b/XdmfAttributeType.cpp index 9fcdf35d8ca25c1865095a8e6f9f24a63a757f5f..14bb687e9b03a00d9d3f1ac01ea492420ea60fdc 100644 --- a/XdmfAttributeType.cpp +++ b/XdmfAttributeType.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfAttributeType.hpp" #include "XdmfError.hpp" @@ -98,44 +99,45 @@ XdmfAttributeType::New(const std::map & itemProperties if(type == itemProperties.end()) { type = itemProperties.find("AttributeType"); } - if(type != itemProperties.end()) { - const std::string typeVal = type->second; - if(typeVal.compare("None") == 0) { - return NoAttributeType(); - } - else if(typeVal.compare("Scalar") == 0) { - return Scalar(); - } - else if(typeVal.compare("Vector") == 0) { - return Vector(); - } - else if(typeVal.compare("Tensor") == 0) { - return Tensor(); - } - else if(typeVal.compare("Matrix") == 0) { - return Matrix(); - } - else if(typeVal.compare("Tensor6") == 0) { - return Tensor6(); - } - else if(typeVal.compare("GlobalId") == 0) { - return GlobalId(); - } - else { - XdmfError::message(XdmfError::FATAL, - "Type not of 'None','Scalar','Vector','Tensor', " - "'Matrix','Tensor6', or 'GlobalId' in " - "XdmfAttributeType::New"); - } + if(type == itemProperties.end()) { + XdmfError::message(XdmfError::FATAL, + "Neither 'Type' nor 'AttributeType' found in " + "itemProperties in XdmfAttributeType::New"); + } + const std::string & typeVal = type->second; + + if(typeVal.compare("Scalar") == 0) { + return Scalar(); + } + else if(typeVal.compare("Vector") == 0) { + return Vector(); + } + else if(typeVal.compare("Tensor") == 0) { + return Tensor(); + } + else if(typeVal.compare("Matrix") == 0) { + return Matrix(); } + else if(typeVal.compare("Tensor6") == 0) { + return Tensor6(); + } + else if(typeVal.compare("GlobalId") == 0) { + return GlobalId(); + } + else if(typeVal.compare("None") == 0) { + return NoAttributeType(); + } + XdmfError::message(XdmfError::FATAL, - "Neither 'Type' nor 'AttributeType' found in " - "itemProperties in XdmfAttributeType::New"); + "Type not of 'None','Scalar','Vector','Tensor', " + "'Matrix','Tensor6', or 'GlobalId' in " + "XdmfAttributeType::New"); + return shared_ptr(); } void XdmfAttributeType::getProperties(std::map & collectedProperties) const { - collectedProperties["Type"] = mName; + collectedProperties.insert(std::make_pair("Type", mName)); } diff --git a/XdmfCurvilinearGrid.cpp b/XdmfCurvilinearGrid.cpp index 1e7b572e8aff9b6ca65567cd7723ebb4ba0dd9b2..00e37a49a8caa419dfd2a9b2c66c1531c3e61093 100644 --- a/XdmfCurvilinearGrid.cpp +++ b/XdmfCurvilinearGrid.cpp @@ -244,7 +244,7 @@ XdmfCurvilinearGrid::getGeometry() void XdmfCurvilinearGrid::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfGrid::populateItem(itemProperties, childItems, reader); diff --git a/XdmfCurvilinearGrid.hpp b/XdmfCurvilinearGrid.hpp index 716b5545e1979ea0a466b95b2d759a79accb116d..dc4fb7299976cf12f9727f34c615ded3421ddddf 100644 --- a/XdmfCurvilinearGrid.hpp +++ b/XdmfCurvilinearGrid.hpp @@ -131,7 +131,7 @@ protected: void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfDomain.cpp b/XdmfDomain.cpp index a6f61c239fa494dee37a2372b8746ddd2b18c63c..d3af2cbabafb9c695eb07f335dcb9c300ce1b88f 100644 --- a/XdmfDomain.cpp +++ b/XdmfDomain.cpp @@ -81,7 +81,7 @@ XdmfDomain::getItemTag() const void XdmfDomain::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); diff --git a/XdmfDomain.hpp b/XdmfDomain.hpp index e08de7deceb32b46e734469ef7d9894843cb0c38..758cad830bd50e0b9ffbdb94a3c89abb4e171721 100644 --- a/XdmfDomain.hpp +++ b/XdmfDomain.hpp @@ -76,7 +76,7 @@ protected: XdmfDomain(); virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfGeometry.cpp b/XdmfGeometry.cpp index cefcc3c6b0b96f899a1cd8fa3be311911aeb49a3..e3e10f74d2b9c19622f7f2f8956acc1a58e43b3b 100644 --- a/XdmfGeometry.cpp +++ b/XdmfGeometry.cpp @@ -73,7 +73,7 @@ XdmfGeometry::getType() const void XdmfGeometry::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); @@ -84,8 +84,8 @@ XdmfGeometry::populateItem(const std::map & itemProper ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { this->swap(array); + break; } - // TODO: If multiple dataitems. } } diff --git a/XdmfGeometry.hpp b/XdmfGeometry.hpp index b3d73afb0dbd012f0c68ce9520f66af7a8ab5d5e..2bf69c02a7affd44fe7c9637148ac4425cb8cf00 100644 --- a/XdmfGeometry.hpp +++ b/XdmfGeometry.hpp @@ -84,7 +84,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfGeometryType.cpp b/XdmfGeometryType.cpp index 4df4f48dc4194a2ac089fcc5097275db9e917540..df4677a27396669300d830f900d63c0868fe3921 100644 --- a/XdmfGeometryType.cpp +++ b/XdmfGeometryType.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfGeometryType.hpp" #include "XdmfError.hpp" @@ -65,26 +66,26 @@ XdmfGeometryType::New(const std::map & itemProperties) if(type == itemProperties.end()) { type = itemProperties.find("GeometryType"); } + if(type == itemProperties.end()) { + XdmfError::message(XdmfError::FATAL, + "Neither 'Type' nor 'GeometryType' in itemProperties " + "in XdmfGeometryType::New"); + } + const std::string & typeVal = type->second; - if(type != itemProperties.end()) { - const std::string typeVal = type->second; - if(typeVal.compare("None") == 0) { - return NoGeometryType(); - } - else if(typeVal.compare("XYZ") == 0) { - return XYZ(); - } - else if(typeVal.compare("XY") == 0) { - return XY(); - } - else { - XdmfError::message(XdmfError::FATAL, "Type not 'None', 'XYZ', or 'XY' " - "in XdmfGeometryType::New"); - } + if(typeVal.compare("None") == 0) { + return NoGeometryType(); + } + else if(typeVal.compare("XYZ") == 0) { + return XYZ(); } - XdmfError::message(XdmfError::FATAL, - "Neither 'Type' nor 'GeometryType' in itemProperties in " - "XdmfGeometryType::New"); + else if(typeVal.compare("XY") == 0) { + return XY(); + } + + XdmfError::message(XdmfError::FATAL, "Type not 'None', 'XYZ', or 'XY' " + "in XdmfGeometryType::New"); + return shared_ptr(); } @@ -103,5 +104,5 @@ XdmfGeometryType::getName() const void XdmfGeometryType::getProperties(std::map & collectedProperties) const { - collectedProperties["Type"] = mName; + collectedProperties.insert(std::make_pair("Type", mName)); } diff --git a/XdmfGrid.cpp b/XdmfGrid.cpp index c4a0f2763605dabf1950fadb237b8cc0417bf0a3..1f5a2d5e5030c4576e0e34d31a869313114ccbdb 100644 --- a/XdmfGrid.cpp +++ b/XdmfGrid.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfAttribute.hpp" #include "XdmfGeometry.hpp" #include "XdmfGrid.hpp" @@ -59,7 +60,7 @@ std::map XdmfGrid::getItemProperties() const { std::map gridProperties; - gridProperties["Name"] = mName; + gridProperties.insert(std::make_pair("Name", mName)); return gridProperties; } @@ -96,7 +97,7 @@ XdmfGrid::getTopology() const void XdmfGrid::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); diff --git a/XdmfGrid.hpp b/XdmfGrid.hpp index 613aabde2a1a3c3d037561c8f56acc2efe471d2c..67f372ffc6aa121d3200557dfe50c6d324336ba2 100644 --- a/XdmfGrid.hpp +++ b/XdmfGrid.hpp @@ -130,7 +130,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); shared_ptr mGeometry; diff --git a/XdmfGridCollection.cpp b/XdmfGridCollection.cpp index a7970580ae089bec89528fc84f95e90778595927..92bac10442c9279e65b4ead4f88fd2077f68ee0a 100644 --- a/XdmfGridCollection.cpp +++ b/XdmfGridCollection.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfGeometry.hpp" #include "XdmfTopology.hpp" #include "XdmfGridCollection.hpp" @@ -51,7 +52,7 @@ XdmfGridCollection::getItemProperties() const { std::map collectionProperties = XdmfGrid::getItemProperties(); - collectionProperties["GridType"] = "Collection"; + collectionProperties.insert(std::make_pair("GridType", "Collection")); mType->getProperties(collectionProperties); return collectionProperties; } @@ -76,7 +77,7 @@ XdmfGridCollection::insert(const shared_ptr information) void XdmfGridCollection::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { mType = XdmfGridCollectionType::New(itemProperties); diff --git a/XdmfGridCollection.hpp b/XdmfGridCollection.hpp index b2a945ceb2e148c331bdc7a19f5458fcd0e3c8c1..d6af6d4191cb09fbeed629682e094bfcd7fc0f71 100644 --- a/XdmfGridCollection.hpp +++ b/XdmfGridCollection.hpp @@ -97,7 +97,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfGridCollectionType.cpp b/XdmfGridCollectionType.cpp index 3053b73ff1a7dba5cedb36d44bccfd71cab11c88..aee619c7fa5e553a6fb5cd2632e785a0df726c16 100644 --- a/XdmfGridCollectionType.cpp +++ b/XdmfGridCollectionType.cpp @@ -21,8 +21,9 @@ /* */ /*****************************************************************************/ -#include "XdmfGridCollectionType.hpp" +#include #include "XdmfError.hpp" +#include "XdmfGridCollectionType.hpp" // Supported XdmfGridCollectionTypes shared_ptr @@ -63,31 +64,32 @@ XdmfGridCollectionType::New(const std::map & itemPrope { std::map::const_iterator type = itemProperties.find("CollectionType"); - if(type != itemProperties.end()) { - const std::string typeVal = type->second; - if(typeVal.compare("None") == 0) { - return NoCollectionType(); - } - else if(typeVal.compare("Spatial") == 0) { - return Spatial(); - } - else if(typeVal.compare("Temporal") == 0) { - return Temporal(); - } - else { - XdmfError::message(XdmfError::FATAL, - "'CollectionType' not of 'None', 'Spatial', or " - "'Temporal' in XdmfGridCollectionType::New"); - } + if(type == itemProperties.end()) { + XdmfError::message(XdmfError::FATAL, + "'CollectionType' not in itemProperties in " + "XdmfGridCollectionType::New"); + } + + const std::string & typeVal = type->second; + if(typeVal.compare("None") == 0) { + return NoCollectionType(); } + else if(typeVal.compare("Spatial") == 0) { + return Spatial(); + } + else if(typeVal.compare("Temporal") == 0) { + return Temporal(); + } + XdmfError::message(XdmfError::FATAL, - "'CollectionType' not in itemProperties in " - "XdmfGridCollectionType::New"); + "'CollectionType' not of 'None', 'Spatial', or " + "'Temporal' in XdmfGridCollectionType::New"); + return shared_ptr(); } void XdmfGridCollectionType::getProperties(std::map & collectedProperties) const { - collectedProperties["CollectionType"] = mName; + collectedProperties.insert(std::make_pair("CollectionType", mName)); } diff --git a/XdmfItemFactory.cpp b/XdmfItemFactory.cpp index b0a7ff8c267b9601f7da7b4d9687d6db37e9ee90..f2d572edead6616bfaf49bd8a06ffb55a4963daa 100644 --- a/XdmfItemFactory.cpp +++ b/XdmfItemFactory.cpp @@ -80,13 +80,11 @@ XdmfItemFactory::createItem(const std::string & itemTag, } if(type != itemProperties.end()) { - const std::string typeVal = type->second; + const std::string & typeVal = type->second; if(typeVal.compare("ORIGIN_DXDY") == 0 || typeVal.compare("ORIGIN_DXDYDZ") == 0) { - shared_ptr origin = - shared_ptr(); - shared_ptr brickSize = - shared_ptr(); + shared_ptr origin = shared_ptr(); + shared_ptr brickSize = shared_ptr(); for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); diff --git a/XdmfMap.cpp b/XdmfMap.cpp index a81c18412ec9153335f591b4448c8a8ecaff3e76..dca203517a0d656fa3c75be0c2528e8b95866e3e 100644 --- a/XdmfMap.cpp +++ b/XdmfMap.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfAttribute.hpp" #include "XdmfError.hpp" #include "XdmfGridCollection.hpp" @@ -93,7 +94,7 @@ std::map XdmfMap::getItemProperties() const { std::map mapProperties; - mapProperties["Name"] = mName; + mapProperties.insert(std::make_pair("Name", mName)); return mapProperties; } @@ -142,7 +143,7 @@ bool XdmfMap::isInitialized() const void XdmfMap::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); diff --git a/XdmfMap.hpp b/XdmfMap.hpp index 9bc3c75a0ef37c2d49be031fcde15089e5fd6b31..6dbc3b4422ef435ca9d081152e8892331bc890e6 100644 --- a/XdmfMap.hpp +++ b/XdmfMap.hpp @@ -186,7 +186,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfRectilinearGrid.cpp b/XdmfRectilinearGrid.cpp index 97bb0e16b671af4d2ebb2726029ecc199af1befa..35a5e57187f1ceb997fa7938e8a930a22d761bf4 100644 --- a/XdmfRectilinearGrid.cpp +++ b/XdmfRectilinearGrid.cpp @@ -373,7 +373,7 @@ XdmfRectilinearGrid::getDimensions() const void XdmfRectilinearGrid::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfGrid::populateItem(itemProperties, childItems, reader); diff --git a/XdmfRectilinearGrid.hpp b/XdmfRectilinearGrid.hpp index 6cbb91d2b6c55ec7e51fceb80738257fa670e8f3..0f16769ec77a7377ac6c2159bc3cf185de2a649a 100644 --- a/XdmfRectilinearGrid.hpp +++ b/XdmfRectilinearGrid.hpp @@ -165,7 +165,7 @@ protected: XdmfRectilinearGrid(const std::vector > & axesCoordinates); void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfRegularGrid.cpp b/XdmfRegularGrid.cpp index e2d751888f539fb3374581ed5acb2985b841391c..cbecabc80b0db5bb246ef0c966ae228ff8d0ffd5 100644 --- a/XdmfRegularGrid.cpp +++ b/XdmfRegularGrid.cpp @@ -397,7 +397,7 @@ XdmfRegularGrid::getOrigin() const void XdmfRegularGrid::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfGrid::populateItem(itemProperties, childItems, reader); diff --git a/XdmfRegularGrid.hpp b/XdmfRegularGrid.hpp index 0f1e6d953516aca8eca88d223d5d5651f842fc84..288ba588fb0c1b68aaa6ed63e8f8a0ba78b173e6 100644 --- a/XdmfRegularGrid.hpp +++ b/XdmfRegularGrid.hpp @@ -188,7 +188,7 @@ protected: const shared_ptr origin); void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfSet.cpp b/XdmfSet.cpp index 77bb8cfc5cfeb0f6112d4bc99398d729fe22af0c..81ee9f2bde7bb9fc889beada007d374bd8b90fe9 100644 --- a/XdmfSet.cpp +++ b/XdmfSet.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfAttribute.hpp" #include "XdmfHDF5Controller.hpp" #include "XdmfSet.hpp" @@ -52,7 +53,7 @@ std::map XdmfSet::getItemProperties() const { std::map setProperties; - setProperties["Name"] = mName; + setProperties.insert(std::make_pair("Name", mName)); mType->getProperties(setProperties); return setProperties; } @@ -77,7 +78,7 @@ XdmfSet::getType() const void XdmfSet::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); diff --git a/XdmfSet.hpp b/XdmfSet.hpp index ab0d3e8819c03268cecd25f6bad34c6ee32d83ec..d1ca70259faee8234ebc64d14f2799f49d9b1a05 100644 --- a/XdmfSet.hpp +++ b/XdmfSet.hpp @@ -107,7 +107,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfSetType.cpp b/XdmfSetType.cpp index eb5894b0399a1a3ff573b57e06fe11c1268a6332..d19b119878d10565b563f93f4f5c9ef6e1f77863 100644 --- a/XdmfSetType.cpp +++ b/XdmfSetType.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfSetType.hpp" #include "XdmfError.hpp" @@ -77,37 +78,38 @@ XdmfSetType::New(const std::map & itemProperties) if(type == itemProperties.end()) { type = itemProperties.find("SetType"); } - if(type != itemProperties.end()) { - const std::string typeVal = type->second; - if(typeVal.compare("None") == 0) { - return NoSetType(); - } - else if(typeVal.compare("Node") == 0) { - return Node(); - } - else if(typeVal.compare("Cell") == 0) { - return Cell(); - } - else if(typeVal.compare("Face") == 0) { - return Face(); - } - else if(typeVal.compare("Edge") == 0) { - return Edge(); - } - else { - XdmfError::message(XdmfError::FATAL, - "Type not of 'None', 'Node', 'Cell', 'Face', or " - "'Edge' in XdmfSetType::New"); - } + if(type == itemProperties.end()) { + XdmfError::message(XdmfError::FATAL, + "Neither 'Type' nor 'SetType' found in itemProperties " + "in XdmfSetType::New"); + } + const std::string & typeVal = type->second; + + if(typeVal.compare("Node") == 0) { + return Node(); + } + else if(typeVal.compare("Cell") == 0) { + return Cell(); + } + else if(typeVal.compare("Face") == 0) { + return Face(); } + else if(typeVal.compare("Edge") == 0) { + return Edge(); + } + else if(typeVal.compare("None") == 0) { + return NoSetType(); + } + XdmfError::message(XdmfError::FATAL, - "Neither 'Type' nor 'SetType' found in itemProperties " - "in XdmfSetType::New"); + "Type not of 'None', 'Node', 'Cell', 'Face', or " + "'Edge' in XdmfSetType::New"); + return shared_ptr(); } void XdmfSetType::getProperties(std::map & collectedProperties) const { - collectedProperties["Type"] = this->mName; + collectedProperties.insert(std::make_pair("Type", mName)); } diff --git a/XdmfTime.cpp b/XdmfTime.cpp index 42243a1f113dd228a6d8a64bb625f8ce471ba755..3a3da402d7b03a71f26f4e22ce3988637dc7bd61 100644 --- a/XdmfTime.cpp +++ b/XdmfTime.cpp @@ -22,6 +22,7 @@ /*****************************************************************************/ #include +#include #include "XdmfTime.hpp" #include "XdmfError.hpp" @@ -49,7 +50,7 @@ XdmfTime::getItemProperties() const std::map timeProperties; std::stringstream value; value << mValue; - timeProperties["Value"] = value.str(); + timeProperties.insert(std::make_pair("Value", value.str())); return timeProperties; } @@ -67,7 +68,7 @@ XdmfTime::getValue() const void XdmfTime::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); @@ -77,7 +78,9 @@ XdmfTime::populateItem(const std::map & itemProperties mValue = atof(value->second.c_str()); } else { - XdmfError::message(XdmfError::FATAL, "'Value' not in itemProperties in XdmfTime::populateItem"); + XdmfError::message(XdmfError::FATAL, + "'Value' not in itemProperties in " + "XdmfTime::populateItem"); } } diff --git a/XdmfTime.hpp b/XdmfTime.hpp index 9e0058fa15b790ac2c536e4c1c85d2b06b88dc97..a79faccca78de075b3aa5b072a683e76b74f4c52 100644 --- a/XdmfTime.hpp +++ b/XdmfTime.hpp @@ -74,7 +74,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfTopology.cpp b/XdmfTopology.cpp index d413349e741f541ed559804f91493d6188f5c270..4ba5e65bef315f587f20b2aee0896c83d45fe58c 100644 --- a/XdmfTopology.cpp +++ b/XdmfTopology.cpp @@ -22,6 +22,7 @@ /*****************************************************************************/ #include +#include #include "XdmfError.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyType.hpp" @@ -58,7 +59,7 @@ XdmfTopology::getItemProperties() const if(mType->getCellType() != XdmfTopologyType::Structured) { std::stringstream numElements; numElements << this->getNumberElements(); - topologyProperties["Dimensions"] = numElements.str(); + topologyProperties.insert(std::make_pair("Dimensions", numElements.str())); } return topologyProperties; } @@ -116,7 +117,7 @@ XdmfTopology::getType() const void XdmfTopology::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); diff --git a/XdmfTopology.hpp b/XdmfTopology.hpp index d6c156edb453ae2926a853e18400c52b6d0c3c55..b970b8a20491aefcb24b95644d68845a1d7da410 100644 --- a/XdmfTopology.hpp +++ b/XdmfTopology.hpp @@ -99,7 +99,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/XdmfTopologyType.cpp b/XdmfTopologyType.cpp index bacd26bc416974657b3f13933cfdb7bee29055dd..e9b7c0349ec8b9d49c6089334b992a3811496f94 100644 --- a/XdmfTopologyType.cpp +++ b/XdmfTopologyType.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "XdmfError.hpp" #include "XdmfTopologyType.hpp" @@ -413,117 +414,118 @@ XdmfTopologyType::New(const std::map & itemProperties) if(type == itemProperties.end()) { type = itemProperties.find("TopologyType"); } + if(type == itemProperties.end()) { + XdmfError::message(XdmfError::FATAL, + "Neither 'Type' nor 'TopologyType' found in " + "itemProperties in XdmfTopologyType::New"); + } + std::string typeVal = type->second; + std::transform(typeVal.begin(), + typeVal.end(), + typeVal.begin(), + (int(*)(int))toupper); std::map::const_iterator nodesPerElement = itemProperties.find("NodesPerElement"); - if(type != itemProperties.end()) { - std::string typeVal = type->second; - std::transform(typeVal.begin(), - typeVal.end(), - typeVal.begin(), - (int(*)(int))toupper); - if(typeVal.compare("NOTOPOLOGY") == 0) { - return NoTopologyType(); - } - else if(typeVal.compare("POLYVERTEX") == 0) { - return Polyvertex(); - } - else if(typeVal.compare("POLYLINE") == 0) { - if(nodesPerElement != itemProperties.end()) { - return Polyline(atoi(nodesPerElement->second.c_str())); - } - XdmfError::message(XdmfError::FATAL, - "'NodesPerElement' not in itemProperties and type " - "'POLYLINE' selected in XdmfTopologyType::New"); + + if(typeVal.compare("NOTOPOLOGY") == 0) { + return NoTopologyType(); + } + else if(typeVal.compare("POLYVERTEX") == 0) { + return Polyvertex(); + } + else if(typeVal.compare("POLYLINE") == 0) { + if(nodesPerElement != itemProperties.end()) { + return Polyline(atoi(nodesPerElement->second.c_str())); } - else if(typeVal.compare("POLYGON") == 0) { - if(nodesPerElement != itemProperties.end()) { - return Polygon(atoi(nodesPerElement->second.c_str())); - } - XdmfError::message(XdmfError::FATAL, + XdmfError::message(XdmfError::FATAL, "'NodesPerElement' not in itemProperties and type " - "'POLYGON' selected in XdmfTopologyType::New"); - } - else if(typeVal.compare("TRIANGLE") == 0) { - return Triangle(); - } - else if(typeVal.compare("QUADRILATERAL") == 0) { - return Quadrilateral(); - } - else if(typeVal.compare("TETRAHEDRON") == 0) { - return Tetrahedron(); - } - else if(typeVal.compare("PYRAMID") == 0) { - return Pyramid(); - } - else if(typeVal.compare("WEDGE") == 0) { - return Wedge(); - } - else if(typeVal.compare("HEXAHEDRON") == 0) { - return Hexahedron(); - } - else if(typeVal.compare("EDGE_3") == 0) { - return Edge_3(); - } - else if(typeVal.compare("TRIANGLE_6") == 0) { - return Triangle_6(); - } - else if(typeVal.compare("QUADRILATERAL_8") == 0) { - return Quadrilateral_8(); - } - else if(typeVal.compare("TETRAHEDRON_10") == 0) { - return Tetrahedron_10(); - } - else if(typeVal.compare("PYRAMID_13") == 0) { - return Pyramid_13(); - } - else if(typeVal.compare("WEDGE_15") == 0) { - return Wedge_15(); - } - else if(typeVal.compare("HEXAHEDRON_20") == 0) { - return Hexahedron_20(); - } - else if(typeVal.compare("HEXAHEDRON_24") == 0) { - return Hexahedron_24(); - } - else if(typeVal.compare("HEXAHEDRON_27") == 0) { - return Hexahedron_27(); - } - else if(typeVal.compare("HEXAHEDRON_64") == 0) { - return Hexahedron_64(); - } - else if(typeVal.compare("HEXAHEDRON_125") == 0) { - return Hexahedron_125(); - } - else if(typeVal.compare("HEXAHEDRON_216") == 0) { - return Hexahedron_216(); - } - else if(typeVal.compare("HEXAHEDRON_343") == 0) { - return Hexahedron_343(); - } - else if(typeVal.compare("HEXAHEDRON_512") == 0) { - return Hexahedron_512(); - } - else if(typeVal.compare("HEXAHEDRON_729") == 0) { - return Hexahedron_729(); - } - else if(typeVal.compare("HEXAHEDRON_1000") == 0) { - return Hexahedron_1000(); - } - else if(typeVal.compare("HEXAHEDRON_1331") == 0) { - return Hexahedron_1331(); - } - else if(typeVal.compare("MIXED") == 0) { - return Mixed(); - } - else { - XdmfError::message(XdmfError::FATAL, - "Invalid Type selected in XdmfTopologyType::New"); + "'POLYLINE' selected in XdmfTopologyType::New"); + } + else if(typeVal.compare("POLYGON") == 0) { + if(nodesPerElement != itemProperties.end()) { + return Polygon(atoi(nodesPerElement->second.c_str())); } + XdmfError::message(XdmfError::FATAL, + "'NodesPerElement' not in itemProperties and type " + "'POLYGON' selected in XdmfTopologyType::New"); + } + else if(typeVal.compare("TRIANGLE") == 0) { + return Triangle(); + } + else if(typeVal.compare("QUADRILATERAL") == 0) { + return Quadrilateral(); + } + else if(typeVal.compare("TETRAHEDRON") == 0) { + return Tetrahedron(); + } + else if(typeVal.compare("PYRAMID") == 0) { + return Pyramid(); + } + else if(typeVal.compare("WEDGE") == 0) { + return Wedge(); + } + else if(typeVal.compare("HEXAHEDRON") == 0) { + return Hexahedron(); + } + else if(typeVal.compare("EDGE_3") == 0) { + return Edge_3(); + } + else if(typeVal.compare("TRIANGLE_6") == 0) { + return Triangle_6(); + } + else if(typeVal.compare("QUADRILATERAL_8") == 0) { + return Quadrilateral_8(); + } + else if(typeVal.compare("TETRAHEDRON_10") == 0) { + return Tetrahedron_10(); + } + else if(typeVal.compare("PYRAMID_13") == 0) { + return Pyramid_13(); } + else if(typeVal.compare("WEDGE_15") == 0) { + return Wedge_15(); + } + else if(typeVal.compare("HEXAHEDRON_20") == 0) { + return Hexahedron_20(); + } + else if(typeVal.compare("HEXAHEDRON_24") == 0) { + return Hexahedron_24(); + } + else if(typeVal.compare("HEXAHEDRON_27") == 0) { + return Hexahedron_27(); + } + else if(typeVal.compare("HEXAHEDRON_64") == 0) { + return Hexahedron_64(); + } + else if(typeVal.compare("HEXAHEDRON_125") == 0) { + return Hexahedron_125(); + } + else if(typeVal.compare("HEXAHEDRON_216") == 0) { + return Hexahedron_216(); + } + else if(typeVal.compare("HEXAHEDRON_343") == 0) { + return Hexahedron_343(); + } + else if(typeVal.compare("HEXAHEDRON_512") == 0) { + return Hexahedron_512(); + } + else if(typeVal.compare("HEXAHEDRON_729") == 0) { + return Hexahedron_729(); + } + else if(typeVal.compare("HEXAHEDRON_1000") == 0) { + return Hexahedron_1000(); + } + else if(typeVal.compare("HEXAHEDRON_1331") == 0) { + return Hexahedron_1331(); + } + else if(typeVal.compare("MIXED") == 0) { + return Mixed(); + } + XdmfError::message(XdmfError::FATAL, - "Neither 'Type' nor 'TopologyType' found in " - "itemProperties in XdmfTopologyType::New"); + "Invalid Type selected in XdmfTopologyType::New"); + return shared_ptr(); } @@ -566,10 +568,11 @@ XdmfTopologyType::getNodesPerElement() const void XdmfTopologyType::getProperties(std::map & collectedProperties) const { - collectedProperties["Type"] = this->getName(); + collectedProperties.insert(std::make_pair("Type", this->getName())); if(mName.compare("Polygon") == 0 || mName.compare("Polyline") == 0) { std::stringstream nodesPerElement; nodesPerElement << mNodesPerElement; - collectedProperties["NodesPerElement"] = nodesPerElement.str(); + collectedProperties.insert(std::make_pair("NodesPerElement", + nodesPerElement.str())); } } diff --git a/core/XdmfArray.cpp b/core/XdmfArray.cpp index 901392862741e9486312a04aa3a3aec896e9b929..7712e156eded78d10356e4eb0cdedfffcb0a743f 100644 --- a/core/XdmfArray.cpp +++ b/core/XdmfArray.cpp @@ -23,11 +23,11 @@ #include #include +#include #include "XdmfArray.hpp" #include "XdmfArrayType.hpp" #include "XdmfHDF5Controller.hpp" #include "XdmfHeavyDataController.hpp" -#include "XdmfSystemUtils.hpp" #include "XdmfVisitor.hpp" #include "XdmfError.hpp" @@ -575,7 +575,7 @@ XdmfArray::getDimensions() const std::string XdmfArray::getDimensionsString() const { - const std::vector & dimensions = this->getDimensions(); + const std::vector dimensions = this->getDimensions(); return GetValuesString(dimensions.size()).getValuesString(&dimensions[0], dimensions.size()); } @@ -598,14 +598,16 @@ XdmfArray::getItemProperties() const { std::map arrayProperties; if(mHeavyDataController) { - arrayProperties["Format"] = mHeavyDataController->getName(); + arrayProperties.insert(std::make_pair("Format", + mHeavyDataController->getName())); } else { - arrayProperties["Format"] = "XML"; + arrayProperties.insert(std::make_pair("Format", "XML")); } - arrayProperties["Dimensions"] = this->getDimensionsString(); + arrayProperties.insert(std::make_pair("Dimensions", + this->getDimensionsString())); if(mName.compare("") != 0) { - arrayProperties["Name"] = mName; + arrayProperties.insert(std::make_pair("Name", mName)); } shared_ptr type = this->getArrayType(); type->getProperties(arrayProperties); @@ -744,46 +746,64 @@ XdmfArray::internalizeArrayPointer() void XdmfArray::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); - std::string contentVal; const shared_ptr arrayType = XdmfArrayType::New(itemProperties); std::map::const_iterator content = itemProperties.find("Content"); - if(content != itemProperties.end()) { - contentVal = content->second; - } - else { + if(content == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Content' not found in itemProperties in " "XdmfArray::populateItem"); } + const std::string & contentVal = content->second; std::map::const_iterator dimensions = itemProperties.find("Dimensions"); - if(dimensions != itemProperties.end()) { - boost::tokenizer<> tokens(dimensions->second); - for(boost::tokenizer<>::const_iterator iter = tokens.begin(); - iter != tokens.end(); - ++iter) { - mDimensions.push_back(atoi((*iter).c_str())); - } - } - else { + if(dimensions == itemProperties.end()) { XdmfError::message(XdmfError::FATAL, "'Dimensions' not found in itemProperties in " "XdmfArray::populateItem"); } + + boost::tokenizer<> tokens(dimensions->second); + for(boost::tokenizer<>::const_iterator iter = tokens.begin(); + iter != tokens.end(); + ++iter) { + mDimensions.push_back(atoi((*iter).c_str())); + } std::map::const_iterator format = itemProperties.find("Format"); - if(format != itemProperties.end()) { - if(format->second.compare("HDF") == 0) { + if(format == itemProperties.end()) { + XdmfError::message(XdmfError::FATAL, + "'Format' not found in itemProperties in " + "XdmfArray::populateItem"); + } + const std::string & formatVal = format->second; + + if(formatVal.compare("HDF") == 0) { + size_t colonLocation = contentVal.find(":"); + if(colonLocation == std::string::npos) { + XdmfError::message(XdmfError::FATAL, + "':' not found in content in " + "XdmfArray::populateItem -- double check an HDF5 " + "data set is specified for the file"); + } + + std::string hdf5Path = contentVal.substr(0, colonLocation); + const std::string dataSetPath = + contentVal.substr(colonLocation + 1, + contentVal.size() - colonLocation - 1); + + // FIXME: for other OS (e.g. windows) + if(hdf5Path.size() > 0 && hdf5Path[0] != '/') { + // Dealing with a relative path for hdf5 location std::map::const_iterator xmlDir = itemProperties.find("XMLDir"); if(xmlDir == itemProperties.end()) { @@ -791,58 +811,38 @@ XdmfArray::populateItem(const std::map & itemPropertie "'XMLDir' not found in itemProperties in " "XdmfArray::populateItem"); } - size_t colonLocation = contentVal.find(":"); - if(colonLocation != std::string::npos) { - std::string hdf5Path = contentVal.substr(0, colonLocation); - std::string dataSetPath = - contentVal.substr(colonLocation + 1, - contentVal.size() - colonLocation - 1); - if(hdf5Path.compare(XdmfSystemUtils::getRealPath(hdf5Path)) != 0) { - // Dealing with a relative path for hdf5 location - std::stringstream newHDF5Path; - newHDF5Path << xmlDir->second << hdf5Path; - hdf5Path = newHDF5Path.str(); - } - mHeavyDataController = - XdmfHDF5Controller::New(hdf5Path, - dataSetPath, - arrayType, - std::vector(mDimensions.size(), - 0), - std::vector(mDimensions.size(), - 1), - mDimensions); - } - else { - XdmfError::message(XdmfError::FATAL, - "':' not found in content in " - "XdmfArray::populateItem -- double check an HDF5 " - "data set is specified for the file"); - } - } - else if(format->second.compare("XML") == 0) { - this->initialize(arrayType, - mDimensions); - unsigned int index = 0; - boost::char_separator sep(" \t\n"); - boost::tokenizer > tokens(contentVal, sep); - for(boost::tokenizer >::const_iterator - iter = tokens.begin(); - iter != tokens.end(); - ++iter, ++index) { - this->insert(index, atof((*iter).c_str())); - } + + std::stringstream newHDF5Path; + newHDF5Path << xmlDir->second << hdf5Path; + hdf5Path = newHDF5Path.str(); } - else { - XdmfError::message(XdmfError::FATAL, - "Neither 'HDF' nor 'XML' specified as 'Format' " - "in XdmfArray::populateItem"); + mHeavyDataController = + XdmfHDF5Controller::New(hdf5Path, + dataSetPath, + arrayType, + std::vector(mDimensions.size(), + 0), + std::vector(mDimensions.size(), + 1), + mDimensions); + } + else if(formatVal.compare("XML") == 0) { + this->initialize(arrayType, + mDimensions); + unsigned int index = 0; + boost::char_separator sep(" \t\n"); + boost::tokenizer > tokens(contentVal, sep); + for(boost::tokenizer >::const_iterator + iter = tokens.begin(); + iter != tokens.end(); + ++iter, ++index) { + this->insert(index, atof((*iter).c_str())); } } else { XdmfError::message(XdmfError::FATAL, - "'Format' not found in itemProperties in " - "XdmfArray::populateItem"); + "Neither 'HDF' nor 'XML' specified as 'Format' " + "in XdmfArray::populateItem"); } std::map::const_iterator name = diff --git a/core/XdmfArray.hpp b/core/XdmfArray.hpp index ed75aebbf64a4b474c09da01d4b41935d11557d9..e7ecddb8c3cf4c686621980defba4261fd65cc87 100644 --- a/core/XdmfArray.hpp +++ b/core/XdmfArray.hpp @@ -480,7 +480,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/core/XdmfArrayType.cpp b/core/XdmfArrayType.cpp index 22b661c8277f8d9480b347e00cddad0036bb83bb..e717a9e50672b54840d5b49c0f13462d727abced 100644 --- a/core/XdmfArrayType.cpp +++ b/core/XdmfArrayType.cpp @@ -22,6 +22,7 @@ /*****************************************************************************/ #include +#include #include "XdmfArrayType.hpp" #include "XdmfError.hpp" @@ -115,54 +116,54 @@ XdmfArrayType::New(const std::map & itemProperties) if(type == itemProperties.end()) { type = itemProperties.find("NumberType"); } + if(type == itemProperties.end()) { + XdmfError::message(XdmfError::FATAL, + "Type unset because neither 'DataType' nor " + "'NumberType' found in itemProperties in " + "XdmfArrayType::New"); + } + const std::string & typeVal = type->second; + std::map::const_iterator precision = itemProperties.find("Precision"); - if(type != itemProperties.end()) { - const std::string typeVal = type->second; - unsigned int precisionVal = 0; - if(precision != itemProperties.end()) { - precisionVal = atoi(precision->second.c_str()); - } - if(typeVal.compare("None") == 0) { - return Uninitialized(); - } - else if(typeVal.compare("Char") == 0) { - return Int8(); - } - else if(typeVal.compare("Short") == 0) { - return Int16(); - } - else if(typeVal.compare("Int") == 0 && precisionVal == 8) { - return Int64(); - } - else if(typeVal.compare("Int") == 0) { - return Int32(); - } - else if(typeVal.compare("Float") == 0 && precisionVal == 8) { + const unsigned int precisionVal = + (precision == itemProperties.end()) ? 0 : atoi(precision->second.c_str()); + + if(typeVal.compare("Float") == 0) { + if(precisionVal == 8) { return Float64(); } - else if(typeVal.compare("Float") == 0) { - return Float32(); - } - else if(typeVal.compare("UChar") == 0) { - return UInt8(); - } - else if(typeVal.compare("UShort") == 0) { - return UInt16(); - } - else if(typeVal.compare("UInt") == 0) { - return UInt32(); - } - else { - XdmfError::message(XdmfError::FATAL, - "Type not one of accepted values: " + typeVal + - " in XdmfArrayType::New"); + return Float32(); + } + else if(typeVal.compare("Int") == 0) { + if(precisionVal == 8) { + return Int64(); } + return Int32(); + } + else if(typeVal.compare("Char") == 0) { + return Int8(); + } + else if(typeVal.compare("Short") == 0) { + return Int16(); } + else if(typeVal.compare("UChar") == 0) { + return UInt8(); + } + else if(typeVal.compare("UShort") == 0) { + return UInt16(); + } + else if(typeVal.compare("UInt") == 0) { + return UInt32(); + } + else if(typeVal.compare("None") == 0) { + return Uninitialized(); + } + XdmfError::message(XdmfError::FATAL, - "Type unset because neither 'DataType' nor " - "'NumberType' found in itemProperties in " - "XdmfArrayType::New"); + "Type not one of accepted values: " + typeVal + + " in XdmfArrayType::New"); + return shared_ptr(); } @@ -181,8 +182,8 @@ XdmfArrayType::getName() const void XdmfArrayType::getProperties(std::map & collectedProperties) const { - collectedProperties["DataType"] = mName; + collectedProperties.insert(std::make_pair("DataType", mName)); std::stringstream precision; precision << mPrecision; - collectedProperties["Precision"] = precision.str(); + collectedProperties.insert(std::make_pair("Precision", precision.str())); } diff --git a/core/XdmfCoreReader.cpp b/core/XdmfCoreReader.cpp index 78d6553b2285a5e25619af4fd2b12a7056814e85..e17e42e34e4a94445ccab101fe53c53fac3aa090 100644 --- a/core/XdmfCoreReader.cpp +++ b/core/XdmfCoreReader.cpp @@ -27,13 +27,13 @@ #include #include #include +#include +#include "XdmfArray.hpp" #include "XdmfCoreItemFactory.hpp" #include "XdmfCoreReader.hpp" +#include "XdmfError.hpp" #include "XdmfItem.hpp" #include "XdmfSystemUtils.hpp" -#include "XdmfError.hpp" - -#include /** * PIMPL @@ -101,6 +101,7 @@ public: " in XdmfCoreReader::XdmfCoreReaderImpl::parse"); } + mDocuments.insert(std::make_pair((char*)mDocument->URL, mDocument)); mXPathContext = xmlXPtrNewContext(mDocument, NULL, NULL); mXPathMap.clear(); } @@ -196,37 +197,40 @@ public: std::map itemProperties; xmlNodePtr childNode = currNode->children; - while(childNode != NULL) { - if(childNode->type == XML_TEXT_NODE && childNode->content) { - const char * content = (char*)childNode->content; - - // determine if content is whitespace - const size_t contentSize = std::strlen(content); - bool whitespace = true; - - for(size_t i=0; iname) == 0) { + while(childNode != NULL) { + if(childNode->type == XML_TEXT_NODE && childNode->content) { + const char * content = (char*)childNode->content; + + // determine if content is whitespace + bool whitespace = true; + + const char * contentPtr = content; + while(contentPtr != NULL) { + if(!isspace(*contentPtr++)) { + whitespace = false; + break; + } + } + + if(!whitespace) { + itemProperties.insert(std::make_pair("Content", content)); + itemProperties.insert(std::make_pair("XMLDir", mXMLDir)); break; } } - - if(!whitespace) { - itemProperties["Content"] = content; - itemProperties["XMLDir"] = mXMLDir; - break; - } + childNode = childNode->next; } - childNode = childNode->next; } + xmlAttrPtr currAttribute = currNode->properties; while(currAttribute != NULL) { - itemProperties[(const char *)currAttribute->name] = - (const char *)currAttribute->children->content; + itemProperties.insert(std::make_pair((char *)currAttribute->name, + (char *)currAttribute->children->content)); currAttribute = currAttribute->next; } - std::vector > childItems = + const std::vector > childItems = this->read(currNode->children); shared_ptr newItem = mItemFactory->createItem((const char *)currNode->name, @@ -240,7 +244,7 @@ public: newItem->populateItem(itemProperties, childItems, mCoreReader); myItems.push_back(newItem); - mXPathMap[currNode] = newItem; + mXPathMap.insert(std::make_pair(currNode, newItem)); } } @@ -262,7 +266,6 @@ public: std::map mDocuments; const XdmfCoreReader * const mCoreReader; const shared_ptr mItemFactory; - const std::string mRootItemTag; std::string mXMLDir; xmlXPathContextPtr mXPathContext; std::map > mXPathMap; diff --git a/core/XdmfHeavyDataController.cpp b/core/XdmfHeavyDataController.cpp index 1e2c48d8c17df2c1a2b4cc331f0f3b1bcd713697..345c5152b26336ae3699d1dfd79a6e860b07553e 100644 --- a/core/XdmfHeavyDataController.cpp +++ b/core/XdmfHeavyDataController.cpp @@ -32,7 +32,7 @@ XdmfHeavyDataController::XdmfHeavyDataController(const std::string & filePath, const std::vector & dimensions) : mDataSetPath(dataSetPath), mDimensions(dimensions), - mFilePath(XdmfSystemUtils::getRealPath(filePath)), + mFilePath(filePath), mType(type) { } diff --git a/core/XdmfInformation.cpp b/core/XdmfInformation.cpp index 424a310cc7a0706e4c851ec2543cd2def94c6dbc..c4e421510253e30e49d8c185a794c3a925ae21d4 100644 --- a/core/XdmfInformation.cpp +++ b/core/XdmfInformation.cpp @@ -21,6 +21,7 @@ /* */ /*****************************************************************************/ +#include #include "XdmfArray.hpp" #include "XdmfError.hpp" #include "XdmfInformation.hpp" @@ -59,8 +60,8 @@ std::map XdmfInformation::getItemProperties() const { std::map informationProperties; - informationProperties["Name"] = mKey; - informationProperties["Value"] = mValue; + informationProperties.insert(std::make_pair("Name", mKey)); + informationProperties.insert(std::make_pair("Value", mValue)); return informationProperties; } @@ -84,7 +85,7 @@ XdmfInformation::getValue() const void XdmfInformation::populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); diff --git a/core/XdmfInformation.hpp b/core/XdmfInformation.hpp index dc37476a7731c09760be5184e69f84b0382227ca..eb733baa4f5a51aeb9cf1f1d27622b0cb27baf51 100644 --- a/core/XdmfInformation.hpp +++ b/core/XdmfInformation.hpp @@ -111,7 +111,7 @@ protected: virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/core/XdmfItem.cpp b/core/XdmfItem.cpp index c3b38d4b867af24701b511a51a319a65be0b0904..6cba7d5d1ba1521417bf20b23ef03f0284bc515f 100644 --- a/core/XdmfItem.cpp +++ b/core/XdmfItem.cpp @@ -36,7 +36,7 @@ XdmfItem::~XdmfItem() void XdmfItem::populateItem(const std::map &, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const) { for(std::vector >::const_iterator iter = diff --git a/core/XdmfItem.hpp b/core/XdmfItem.hpp index 40d4dc0b2402dbc831be1c3b0526983bd8b782c8..0e48dfafee5067b1e819f9ec5bf7d700a819a590 100644 --- a/core/XdmfItem.hpp +++ b/core/XdmfItem.hpp @@ -239,7 +239,7 @@ protected: */ virtual void populateItem(const std::map & itemProperties, - std::vector > & childItems, + const std::vector > & childItems, const XdmfCoreReader * const reader); private: diff --git a/core/XdmfWriter.cpp b/core/XdmfWriter.cpp index be1fca48ec83c9f20594279306ad325dbc771d48..3dafea787e16b2b04b4a480f7a05ceb3b7d5742f 100644 --- a/core/XdmfWriter.cpp +++ b/core/XdmfWriter.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "XdmfArray.hpp" #include "XdmfHeavyDataWriter.hpp" #include "XdmfHDF5Controller.hpp" @@ -259,7 +260,8 @@ XdmfWriter::visit(XdmfArray & array, } mImpl->mDepth++; - bool isSubclassed = array.getItemTag().compare(XdmfArray::ItemTag) != 0; + const bool isSubclassed = + array.getItemTag().compare(XdmfArray::ItemTag) != 0; if(isSubclassed) { this->visit(dynamic_cast(array), visitor); @@ -284,7 +286,7 @@ XdmfWriter::visit(XdmfArray & array, array.getHeavyDataController()->getFilePath(); size_t index = heavyDataPath.find_last_of("/\\"); if(index != std::string::npos) { - std::string heavyDataDir = heavyDataPath.substr(0, index + 1); + const std::string heavyDataDir = heavyDataPath.substr(0, index + 1); if(mImpl->mXMLFilePath.find(heavyDataDir) == 0) { heavyDataPath = heavyDataPath.substr(heavyDataDir.size(), @@ -347,7 +349,7 @@ XdmfWriter::visit(XdmfItem & item, if(mImpl->mWriteXPaths) { mImpl->mXPathCount++; - std::string parentXPathString = mImpl->mXPathString; + const std::string parentXPathString = mImpl->mXPathString; std::stringstream newXPathString; newXPathString << mImpl->mXPathString << "/" << mImpl->mXPathCount; @@ -374,16 +376,18 @@ XdmfWriter::visit(XdmfItem & item, NULL); std::stringstream xPathProp; xPathProp << "element(/1" << mImpl->mXPathString << ")"; - mImpl->mXPath[&item] = xPathProp.str(); + mImpl->mXPath.insert(std::make_pair(&item, xPathProp.str())); const std::map & itemProperties = item.getItemProperties(); for(std::map::const_iterator iter = itemProperties.begin(); iter != itemProperties.end(); ++iter) { - xmlNewProp(mImpl->mXMLCurrentNode, (xmlChar*)iter->first.c_str(), (xmlChar*)iter->second.c_str()); + xmlNewProp(mImpl->mXMLCurrentNode, + (xmlChar*)iter->first.c_str(), + (xmlChar*)iter->second.c_str()); } - unsigned int parentCount = mImpl->mXPathCount; + const unsigned int parentCount = mImpl->mXPathCount; mImpl->mXPathCount = 0; item.traverse(visitor); mImpl->mXPathCount = parentCount; diff --git a/core/tests/Cxx/TestXdmfHDF5Controller.cpp b/core/tests/Cxx/TestXdmfHDF5Controller.cpp index c8773365a92b8b336370558e40fbb842ec18f986..46689a84cfe4640fae0b13753d860bfa5368d6f9 100644 --- a/core/tests/Cxx/TestXdmfHDF5Controller.cpp +++ b/core/tests/Cxx/TestXdmfHDF5Controller.cpp @@ -13,7 +13,6 @@ int main(int, char **) std::vector(1, 1), std::vector(1, 10)); assert(controller->getDataSetPath().compare("/foo/data1") == 0); - assert(controller->getFilePath().compare(XdmfSystemUtils::getRealPath("output.h5")) == 0); assert(controller->getSize() == 10); assert(controller->getType() == XdmfArrayType::Int8()); diff --git a/utils/XdmfPartitioner.cpp b/utils/XdmfPartitioner.cpp index 8108fe4cf2eb1cf92eca64e151b749ed4e8023cd..3753a163139b59891aba552591bdb6326e02993c 100644 --- a/utils/XdmfPartitioner.cpp +++ b/utils/XdmfPartitioner.cpp @@ -868,7 +868,7 @@ int main(int argc, char* argv[]) std::string inputFileName = ""; std::string outputFileName = ""; - unsigned int numPartitions; + unsigned int numPartitions = 0; XdmfPartitioner::MetisScheme metisScheme = XdmfPartitioner::DUAL_GRAPH; bool unpartition = false;