DAS  3.0
Das Analysis System
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.

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