MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / toUnderscoreCase

Function toUnderscoreCase

src/utilities/core/StringHelpers.cpp:36–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36std::string toUnderscoreCase(const std::string& s) {
37 // DLM: previous implementation
38 //std::string result = toLowerCamelCase(s);
39 //result = boost::regex_replace(result,boost::regex("(.)([A-Z])"),"$1_\\l$2");
40
41 std::string result = boost::replace_all_copy(s, "OpenStudio", "Openstudio");
42 boost::replace_all(result, "EnergyPlus", "Energyplus");
43
44 //http://stackoverflow.com/questions/1509915/converting-camel-case-to-underscore-case-in-ruby
45 // DLM: there is a to_underscore method in the BCL gem, this should be synchronized
46 result = boost::regex_replace(result, boost::regex("[^a-zA-Z0-9]"), " ");
47 result = boost::regex_replace(result, boost::regex("([\\-]+)"), "_");
48 result = boost::regex_replace(result, boost::regex("([\\s]+)"), "_");
49 result = boost::regex_replace(result, boost::regex("([A-Za-z])([0-9])"), "$1_$2");
50 result = boost::regex_replace(result, boost::regex("([0-9]+)([A-Za-z])"), "$1_$2");
51 result = boost::regex_replace(result, boost::regex("([A-Z]+)([A-Z][a-z])"), "$1_$2");
52 result = boost::regex_replace(result, boost::regex("([a-z])([A-Z])"), "$1_$2");
53 result = boost::regex_replace(result, boost::regex("([A-Z])"), "\\l$1");
54 return result;
55}
56
57// ETH@20110614 Implementation copied from IddFileFactoryData.cpp for use in Ruby script.
58std::string convertIddName(const std::string& s) {

Callers 7

cleanValueNameMethod · 0.85
updateMethod · 0.85
duplicate_measureMethod · 0.85
TESTFunction · 0.85
BCLMeasureMethod · 0.85
updateMeasureTestsMethod · 0.85
gatherReportsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68