Darwin  1.0
Event loop based prototype framework
Options.cc File Reference
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <regex>
#include <system_error>
#include <filesystem>
#include <string>
#include <numeric>
#include <boost/algorithm/string.hpp>
#include <boost/version.hpp>
#include <boost/program_options.hpp>
#include <boost/exception/all.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include "colours.h"
#include "Options.h"
#include "version.h"
+ Include dependency graph for Options.cc:

Functions

void set_mute (bool flag)
 
string wrap_paragraph (const string &text)
 

Function Documentation

◆ set_mute()

void set_mute ( bool  flag)

Function used by Boost::PO to disable standard error.

94 {
95  if (flag) cout.setstate(ios_base::failbit);
96 }

◆ wrap_paragraph()

string wrap_paragraph ( const string &  text)

Wraps a given paragraph to fit within the same number of characters as the standard helper message from Boost Program Options.

149 {
150  if (text.size() == 0) return text;
151 
152  vector<string> paragraphs;
153  al::split(paragraphs, text, al::is_any_of("\n"));
154 
155  string wrapped;
156  for (auto const& paragraph: paragraphs) {
157  vector<string> words;
158  al::split(words, paragraph, al::is_any_of(" \t"), al::token_compress_on);
159 
160  string line;
161  for (auto const& word: words) {
162  size_t s = line.size() + word.size();
163  static const size_t sMax = po::options_description::m_default_line_length;
164 
165  if (s > sMax) {
166  line.pop_back();
167  wrapped += line;
168  wrapped += '\n';
169  line.clear();
170  }
171 
172  line += word;
173  line += ' ';
174  }
175  line.pop_back();
176  wrapped += line + '\n';
177  }
178 
179  return wrapped;
180 }
Darwin::Tools::split
@ split
activate -k and -j to define slice
Definition: Options.h:26