From 34cb672075ec216f394ee1caed8400db398bf090 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 7 Aug 2021 10:40:43 +0200 Subject: [PATCH] string literals --- src/examples/IfcAdvancedHouse.cpp | 4 +++- src/examples/IfcOpenHouse.cpp | 35 ++++++++++++++++--------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/examples/IfcAdvancedHouse.cpp b/src/examples/IfcAdvancedHouse.cpp index fcb0d74450..9ea485851f 100644 --- a/src/examples/IfcAdvancedHouse.cpp +++ b/src/examples/IfcAdvancedHouse.cpp @@ -55,6 +55,8 @@ #include #endif +using namespace std::string_literals; + // The creation of Nurbs-surface for the IfcSite mesh, to be implemented lateron void createGroundShape(TopoDS_Shape& shape); @@ -71,7 +73,7 @@ int main() { // Lateron changing the name of the IfcProject can be done by obtaining a reference to the // project, which has been created automatically. - file.getSingle()->setName("IfcOpenHouse"); + file.getSingle()->setName("IfcOpenHouse"s); // To demonstrate the ability to serialize arbitrary opencascade solids a building envelope is // constructed by applying boolean operations. Naturally, in IFC, building elements should be diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index 99f9d046e4..b9b9eca190 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -50,8 +50,9 @@ #include #endif +using namespace std::string_literals; + // Some convenience typedefs and definitions. -typedef std::string S; typedef IfcParse::IfcGlobalId guid; typedef std::pair XY; boost::none_t const null = boost::none; @@ -70,7 +71,7 @@ int main() { IfcSchema::IfcWallStandardCase* south_wall = new IfcSchema::IfcWallStandardCase( guid(), // GlobalId 0, // OwnerHistory - S("South wall"), // Name + "South wall"s, // Name null, // Description null, // ObjectType 0, // ObjectPlacement @@ -87,7 +88,7 @@ int main() { // Lateron changing the name of the IfcProject can be done by obtaining a reference to the // project, which has been created automatically. - file.getSingle()->setName("IfcOpenHouse"); + file.getSingle()->setName("IfcOpenHouse"s); // An IfcOwnerHistory has been initialized as well, which should be assigned to the wall. south_wall->setOwnerHistory(file.getSingle()); @@ -111,7 +112,7 @@ int main() { // Now create a footing for the wall to rest on. IfcSchema::IfcFooting* footing = new IfcSchema::IfcFooting(guid(), file.getSingle(), - S("Footing"), null, null, 0, 0, null, IfcSchema::IfcFootingTypeEnum::IfcFootingType_STRIP_FOOTING); + "Footing"s, null, null, 0, 0, null, IfcSchema::IfcFootingTypeEnum::IfcFootingType_STRIP_FOOTING); file.addBuildingProduct(footing); @@ -154,7 +155,7 @@ int main() { file.addEntity(new IfcSchema::IfcRelVoidsElement(guid(), file.getSingle(), null, null, south_wall, south_opening)); // Create a roof element that will consist of two slabs: - IfcSchema::IfcRoof* roof = new IfcSchema::IfcRoof(guid(), file.getSingle(), S("Roof"), null, null, + IfcSchema::IfcRoof* roof = new IfcSchema::IfcRoof(guid(), file.getSingle(), "Roof"s, null, null, file.addLocalPlacement(storey_placement), 0, null, IfcSchema::IfcRoofTypeEnum::IfcRoofType_GABLE_ROOF); // The roof geometry is slanted 45 degrees by specifying a direction for the box extrusion @@ -163,7 +164,7 @@ int main() { file.addTriplet(0, -sqrt(0.5), sqrt(0.5))); // CV-2x3-144: Roofs are aggregates and shall have at least one contained element and no own geometry - IfcSchema::IfcSlab* south_roof_part = new IfcSchema::IfcSlab(guid(), file.getSingle(), S("South roof"), + IfcSchema::IfcSlab* south_roof_part = new IfcSchema::IfcSlab(guid(), file.getSingle(), "South roof"s, null, null, 0, 0, null, IfcSchema::IfcSlabTypeEnum::IfcSlabType_ROOF); // The geometry is instantiated by using IfcMappedItems. This way geometry definitions can @@ -174,7 +175,7 @@ int main() { // The same roof geometry is re-used on the north side of the roof, by inverting the X-axis of // the local placement the roof is rotated 180 degrees around the Z-axis - IfcSchema::IfcSlab* north_roof_part = new IfcSchema::IfcSlab(guid(), file.getSingle(), S("North roof"), + IfcSchema::IfcSlab* north_roof_part = new IfcSchema::IfcSlab(guid(), file.getSingle(), "North roof"s, null, null, 0, 0, null, IfcSchema::IfcSlabTypeEnum::IfcSlabType_ROOF); north_roof_part->setOwnerHistory(file.getSingle()); north_roof_part->setRepresentation(file.addMappedItem(roof_rep)); @@ -194,7 +195,7 @@ int main() { setSurfaceColour(file, roof_rep, 0.24, 0.08, 0.04); // Copy the south wall to the north - IfcSchema::IfcWallStandardCase* north_wall = new IfcSchema::IfcWallStandardCase(guid(), file.getSingle(), S("North wall"), + IfcSchema::IfcWallStandardCase* north_wall = new IfcSchema::IfcWallStandardCase(guid(), file.getSingle(), "North wall"s, null, null, file.addLocalPlacement(storey_placement, 0, 5000, 0), file.addAxisBox(10000, 360, 3000), null #ifdef USE_IFC4 , IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD @@ -227,7 +228,7 @@ int main() { // Now create a wall on the east of the building, again starting with just a box shape IfcSchema::IfcWallStandardCase* east_wall = new IfcSchema::IfcWallStandardCase(guid(), file.getSingle(), - S("East wall"), null, null, file.addLocalPlacement(storey_placement, 4820, 2500, 0, 0, 0, 1, 0, 1, 0), clipped_wall_body_reps[0], null + "East wall"s, null, null, file.addLocalPlacement(storey_placement, 4820, 2500, 0, 0, 0, 1, 0, 1, 0), clipped_wall_body_reps[0], null #ifdef USE_IFC4 , IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD #endif @@ -236,7 +237,7 @@ int main() { // The east wall is copied to the west location of the house IfcSchema::IfcWallStandardCase* west_wall = new IfcSchema::IfcWallStandardCase(guid(), file.getSingle(), - S("West wall"), null, null, file.addLocalPlacement(storey_placement, -4820, 2500, 0, 0, 0, 1, 0, -1, 0), clipped_wall_body_reps[1], null + "West wall"s, null, null, file.addLocalPlacement(storey_placement, -4820, 2500, 0, 0, 0, 1, 0, -1, 0), clipped_wall_body_reps[1], null #ifdef USE_IFC4 , IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD #endif @@ -275,7 +276,7 @@ int main() { IfcSchema::IfcProperty::list::ptr properties(new IfcSchema::IfcProperty::list); properties->push(new IfcSchema::IfcPropertySingleValue("TotalArea", null, new IfcSchema::IfcAreaMeasure(site_area), 0)); - IfcSchema::IfcPropertySet* pset = new IfcSchema::IfcPropertySet(guid(), file.getSingle(), S("Pset_SiteCommon"), null, properties); + IfcSchema::IfcPropertySet* pset = new IfcSchema::IfcPropertySet(guid(), file.getSingle(), "Pset_SiteCommon"s, null, properties); #ifdef USE_IFC4 IfcSchema::IfcObjectDefinition::list::ptr related_objs(new IfcSchema::IfcObjectDefinition::list); #else @@ -315,11 +316,11 @@ int main() { , null #endif ); - IfcSchema::IfcMaterialLayer::list::ptr layers (new IfcTemplatedEntityList()); + IfcSchema::IfcMaterialLayer::list::ptr layers (new aggregate_of()); layers->push(layer); IfcSchema::IfcMaterialLayerSet* layer_set = new IfcSchema::IfcMaterialLayerSet( layers, - S("Wall") + "Wall"s #ifdef USE_IFC4 , null #endif @@ -397,7 +398,7 @@ int main() { IfcSchema::IfcShapeRepresentation* door_body = 0; for (IfcSchema::IfcRepresentation::list::it i = door_representations->begin(); i != door_representations->end(); ++i) { IfcSchema::IfcRepresentation* rep = *i; - if (rep->declaration().is(IfcSchema::IfcShapeRepresentation::Class()) && rep->RepresentationIdentifier() == "Body") { + if (rep->declaration().is(IfcSchema::IfcShapeRepresentation::Class()) && rep->RepresentationIdentifier().get_value_or("") == "Body") { door_body = (IfcSchema::IfcShapeRepresentation*) rep; } } @@ -408,7 +409,7 @@ int main() { setSurfaceColour(file, door->Representation(), 0.9, 0.9, 0.9); file.addEntity(new IfcSchema::IfcRelFillsElement(guid(), file.getSingle(), null, null, door_opening, door)); - IfcSchema::IfcDoorStyle* door_style = new IfcSchema::IfcDoorStyle(guid(), file.getSingle(), S("Door type"), null, null, null, null, null, + IfcSchema::IfcDoorStyle* door_style = new IfcSchema::IfcDoorStyle(guid(), file.getSingle(), "Door type"s, null, null, null, null, null, IfcSchema::IfcDoorStyleOperationEnum::IfcDoorStyleOperation_SINGLE_SWING_LEFT, IfcSchema::IfcDoorStyleConstructionEnum::IfcDoorStyleConstruction_WOOD, false, false); file.addRelatedObject(door_style, door); @@ -470,11 +471,11 @@ int main() { file.addBuildingProduct(window); // Initialize a list of parts for the window to be composed of - IfcSchema::IfcObjectDefinition::list::ptr window_parts(new IfcTemplatedEntityList()); + IfcSchema::IfcObjectDefinition::list::ptr window_parts(new aggregate_of()); // The placements for the beams are not shared across the different windows because every // beam is placed relative to its parent window entity. - IfcSchema::IfcLocalPlacement::list::ptr frame_placements (new IfcTemplatedEntityList()); + IfcSchema::IfcLocalPlacement::list::ptr frame_placements (new aggregate_of()); frame_placements->push(file.addLocalPlacement(storey_placement, 930,45)); frame_placements->push(file.addLocalPlacement(storey_placement, 930, 45, 1510)); frame_placements->push(file.addLocalPlacement(storey_placement, -885+930, 45, 90));