DAS  3.0
Das Analysis System
Options.cc File Reference
#include <cstdlib>
#include <dlfcn.h>
#include <algorithm>
#include <filesystem>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <ranges>
#include <regex>
#include <string>
#include <system_error>
#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 "Options.h"
#include "colours.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.

96 {
97  if (flag) cout.setstate(ios_base::failbit);
98 }

◆ 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.

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