Changeset 4182
- Timestamp:
- Jun 16, 2022, 2:20:19 AM (8 weeks ago)
- Location:
- trunk/yat/utility
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/OptionVersion.cc
r4153 r4182 38 38 const std::string& version, 39 39 const std::string& copyright_year, 40 std::vector<std::string>authors,40 const std::vector<std::string>& authors, 41 41 const std::string& package, 42 42 std::string name, … … 48 48 { 49 49 std::ostringstream os; 50 print(os, authors_ );50 print(os, authors_, 14); 51 51 copyright_holder_ = os.str(); 52 52 … … 83 83 84 84 std::ostringstream os; 85 print(os, authors_ );85 print(os, authors_, 14); 86 86 if (os.str() != copyright_holder_) 87 std::cout << "\nWritten by " << os.str() << "\n"; 87 std::cout << "\nWritten by "; 88 print(os, authors_, 11); 89 std::cout << "\n"; 88 90 89 91 exit(EXIT_SUCCESS); … … 92 94 93 95 void OptionVersion::print(std::ostream& os, 94 const std::vector<std::string>& names) const 96 const std::vector<std::string>& names, 97 size_t offset) const 95 98 { 96 99 for (size_t i=0; i<names.size(); ++i) { 97 os << names[i];98 if (i+2 == names.size())99 os << " and ";100 else if (i+2 < names.size())101 os << ", ";100 if (i+1 == names.size()) 101 print(os, " and ", offset); 102 else if (i) 103 print(os, ", ", offset); 104 print(os, names[i], offset); 102 105 } 103 106 } 104 107 105 108 109 void OptionVersion::print(std::ostream& os, const std::string& str, 110 size_t& offset) const 111 { 112 if (offset + str.size() > 80) { 113 os << "\n"; 114 size_t skip = str.find_first_not_of(" "); 115 os << str.substr(skip); 116 offset = str.size() - skip; 117 } 118 else { 119 os << str; 120 offset += str.size(); 121 } 122 } 123 106 124 }}} // of namespace utility, yat, and theplu -
trunk/yat/utility/OptionVersion.h
r4153 r4182 71 71 const std::string& version, 72 72 const std::string& copyright_year, 73 std::vector<std::string>authors,73 const std::vector<std::string>& authors, 74 74 const std::string& package="", 75 75 std::string name="v,version", … … 107 107 std::string copyright_holder_; 108 108 std::string license_; 109 void print(std::ostream& os, const std::vector<std::string>&) const; 109 void print(std::ostream& os, const std::vector<std::string>&, 110 size_t offset) const; 111 void print(std::ostream& os, const std::string&, size_t& offset) const; 110 112 }; 111 113
Note: See TracChangeset
for help on using the changeset viewer.