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

Method print

src/measure/OSArgument.cpp:885–940  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

883 }
884
885 std::string OSArgument::print() const {
886 std::stringstream ss;
887
888 // name
889 ss << name();
890 if (!displayName().empty()) {
891 ss << " (" << displayName() << ")";
892 }
893 ss << '\n';
894
895 // type and required
896 ss << type().valueName() << ", ";
897 if (required()) {
898 ss << "Required";
899 } else {
900 ss << "Optional";
901 }
902 ss << '\n';
903
904 // value
905 ss << "Value: ";
906 if (hasValue()) {
907 ss << printValue(false) << " ";
908 }
909 if (hasDefaultValue()) {
910 ss << "(" << printDefaultValue() << ")";
911 }
912 ss << '\n';
913
914 if (m_type.value() == OSArgumentType::Choice) {
915 ss << "Choices:" << '\n';
916 const int dnn = m_choiceDisplayNames.size();
917 for (int i = 0, n = m_choices.size(); i < n; ++i) {
918 ss << " " << m_choices[i];
919 if ((i < dnn) && (!m_choiceDisplayNames[i].empty())) {
920 ss << " (" << m_choiceDisplayNames[i] << ")";
921 }
922 ss << '\n';
923 }
924 }
925
926 if (hasDomain()) {
927 ss << m_domainType.valueName() << " Domain: ";
928 if (m_domainType == OSDomainType::Interval) {
929 OS_ASSERT(m_domain.size() == 2u);
930 ss << "[" << printOSArgumentVariant(m_domain[0]) << ", " << printOSArgumentVariant(m_domain[1]) << "]" << '\n';
931 } else {
932 ss << '\n';
933 for (const OSArgumentVariant& value : m_domain) {
934 ss << " " << printOSArgumentVariant(value) << '\n';
935 }
936 }
937 }
938
939 return ss.str();
940 }
941
942 std::string OSArgument::printValue(bool printDefault) const {

Callers 1

OSArgument.cppFile · 0.45

Calls 7

nameClass · 0.85
valueNameMethod · 0.80
typeFunction · 0.50
emptyMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected