14 theCommandLineUsage(commandLineUsage)
21 return &theApplicationUsage;
86 unsigned int maxNumCharsInOptions = 0;
87 ossimApplicationUsage::UsageMap::const_iterator citr;
92 maxNumCharsInOptions =
ossim::max(maxNumCharsInOptions,(
unsigned int)citr->first.length());
95 unsigned int fullWidth = widthOfOutput;
96 unsigned int optionPos = 2;
97 unsigned int explanationPos = 2+maxNumCharsInOptions+2;
98 unsigned int explanationWidth = fullWidth-explanationPos;
106 line.
assign(fullWidth,
' ');
107 line.
replace(optionPos,citr->first.length(),citr->first);
110 std::string::size_type pos = 0;
111 std::string::size_type offset = 0;
112 bool firstInLine =
true;
113 while (pos<explanation.
length())
115 if (firstInLine) offset = 0;
118 while (pos<explanation.
length() && *(explanation.
begin()+pos)==
' ')
120 if (firstInLine) ++offset;
128 std::string::size_type slashn_pos = explanation.
find(
'\n',pos);
130 unsigned int extraSkip = 0;
131 bool concatinated =
false;
132 if (slashn_pos!=std::string::npos)
134 if (slashn_pos<pos+width)
136 width = slashn_pos-pos;
140 else if (slashn_pos==pos+width)
147 if (pos+width<explanation.
length())
152 *(explanation.
begin()+(pos+width))!=
' ' &&
153 *(explanation.
begin()+(pos+width))!=
'\n') --width;
159 width = explanationWidth-1;
164 line.
replace(explanationPos+offset,explanationWidth, explanation, pos, width);
166 if (concatinated) { str += line; str +=
"-\n"; }
167 else { str += line; str +=
"\n"; }
170 line.
assign(fullWidth,
' ');
172 pos += width+extraSkip;
184 output << str << std::endl;
198 bool needspace =
false;
202 output <<
"Options:"<<std::endl;
209 if (needspace) output << std::endl;
210 output <<
"Environmental Variables:"<<std::endl;
void write(std::ostream &output, const UsageMap &um, unsigned int widthOfOutput=80)
void addCommandLineOption(const ossimString &option, const ossimString &explanation)
const UsageMap & getEnvironmentalVariables() const
const ossimString & getApplicationName() const
const UsageMap & getCommandLineOptions() const
UsageMap theEnvironmentalVariables
static ossimApplicationUsage * instance()
ossimString theCommandLineUsage
void setCommandLineUsage(const ossimString &explanation)
void getFormatedString(ossimString &str, const UsageMap &um, unsigned int widthOfOutput=80)
ossimString theApplicationName
const ossimString & getDescription() const
std::string::size_type length() const
std::string::size_type size() const
std::string::iterator begin()
void setApplicationName(const ossimString &name)
const ossimString & getCommandLineUsage() const
ossimString theDescription
void addUsageExplanation(Type type, const ossimString &option, const ossimString &explanation)
void setDescription(const ossimString &desc)
std::string & replace(std::string::size_type pos, std::string::size_type n, const std::string &s)
Replaces a substring of *this with the string s.
void addEnvironmentalVariable(const ossimString &option, const ossimString &explanation)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
std::map< ossimString, ossimString, ossimStringLtstr > UsageMap
UsageMap theCommandLineOptions
std::string & assign(std::string::size_type n, char c)
Erases the existing characters and replaces them by n copies of c.
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
std::basic_ostream< char > ostream
Base class for char output streams.