OpenMS
ConsoleUtils.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/DATASTRUCTURES/ListUtils.h> // for StringList definition
12 
13 #include <limits>
14 
15 namespace OpenMS
16 {
17 
25  class OPENMS_DLLAPI ConsoleUtils
26  {
27  private:
30 
31  public:
33  ConsoleUtils(const ConsoleUtils&) = delete;
34 
36  void operator=(ConsoleUtils const&) = delete;
37 
39  static const ConsoleUtils& getInstance();
40 
54  static StringList breakStringList(const String& input, const Size indentation, const Size max_lines, const Size first_line_prefill = 0);
55 
57  static String breakString(const String& input, const Size indentation, const Size max_lines, const Size first_line_prefill = 0);
58 
60  int getConsoleWidth() const
61  {
62  return console_width_;
63  }
64 
65  friend struct ConsoleWidthTest;
66 
67  private:
69  int console_width_ = std::numeric_limits<int>::max();
70 
73 
75  StringList breakString_(const String& input, const Size indentation, const Size max_lines, Size first_line_prefill) const;
76  };
77 
78 } // namespace OpenMS
79 
Definition: ConsoleUtils.h:26
static String breakString(const String &input, const Size indentation, const Size max_lines, const Size first_line_prefill=0)
same as breakStringList(), but concatenates the result using ' ' for convenience
void operator=(ConsoleUtils const &)=delete
Assignment operator (deleted)
static StringList breakStringList(const String &input, const Size indentation, const Size max_lines, const Size first_line_prefill=0)
static const ConsoleUtils & getInstance()
returns the singleton – the only instanciation of this class
StringList breakString_(const String &input, const Size indentation, const Size max_lines, Size first_line_prefill) const
returns a console friendly version of input
int getConsoleWidth() const
width of the console (or INTMAX on internal error)
Definition: ConsoleUtils.h:60
ConsoleUtils()
C'tor (private) – use ConsoleUtils::getInstance()
ConsoleUtils(const ConsoleUtils &)=delete
Copy C'tor (deleted)
int readConsoleSize_()
read console settings for output shaping
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19