advgetopt 2.0.49
Parse complex command line arguments and configuration files in C++.
Namespaces | Functions | Variables
utils.cpp File Reference

Implementation of utility functions. More...

#include "advgetopt/utils.h"
#include "advgetopt/exception.h"
#include <snapdev/glob_to_list.h>
#include <snapdev/isatty.h>
#include <snapdev/not_used.h>
#include <snapdev/trim_string.h>
#include <cppthread/guard.h>
#include <cppthread/mutex.h>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <snapdev/poison.h>
Include dependency graph for utils.cpp:

Go to the source code of this file.

Namespaces

namespace  advgetopt
 The advgetopt environment to parse command line options.
 
namespace  advgetopt::anonymous_namespace{utils.cpp}
 

Functions

std::string advgetopt::breakup_line (std::string line, size_t const option_width, size_t const line_width)
 Breakup a string on multiple lines.
 
std::string advgetopt::default_group_name (std::string const &filename, char const *group_name, char const *project_name, int priority)
 Generate the default filename (the ".../50-...")
 
std::string advgetopt::escape_shell_argument (std::string const &arg)
 Escape special characters from a shell argument.
 
std::string advgetopt::format_usage_string (std::string const &argument, std::string const &help, size_t const option_width, size_t const line_width)
 Format a help string to make it fit on a given width.
 
cppthread::mutex & advgetopt::get_global_mutex ()
 Get a global mutex.
 
size_t advgetopt::get_screen_height ()
 Retrieve the height of your console.
 
size_t advgetopt::get_screen_width ()
 Retrieve the width of one line in your console.
 
std::string advgetopt::handle_user_directory (std::string const &filename)
 Replace a starting ~/... with the contents of the $HOME variable.
 
string_list_t advgetopt::insert_group_name (std::string const &filename, char const *group_name, char const *project_name, bool add_default_on_empty)
 Insert the group (or project) name in the filename.
 
bool advgetopt::is_false (std::string s)
 Check whether a value represents "false".
 
bool advgetopt::is_true (std::string s)
 Check whether a value represents "true".
 
void advgetopt::less (std::basic_ostream< char > &out, std::string const &data)
 Print out a string to the console or use less.
 
std::string advgetopt::option_with_dashes (std::string const &s)
 Convert the _ found in a string to - instead.
 
std::string advgetopt::option_with_underscores (std::string const &s)
 Converts an option back to using underscores.
 
std::string advgetopt::quote (std::string const &s, char open, char close)
 The converse of unquote.
 
std::string advgetopt::sanitizer_details ()
 Generate a string describing whether we're using the sanitizer.
 
void advgetopt::split_string (std::string const &str, string_list_t &result, string_list_t const &separators)
 Split a string in sub-strings separated by separators.
 
std::string advgetopt::unquote (std::string const &s, std::string const &pairs)
 Remove single (') or double (") quotes from a string.
 

Variables

constexpr char constadvgetopt::anonymous_namespace{utils.cpp}::g_empty_string = "\"\""
 
constexpr char constadvgetopt::anonymous_namespace{utils.cpp}::g_escaped_single_quotes = "'\\''"
 
cppthread::mutex * advgetopt::anonymous_namespace{utils.cpp}::g_mutex
 The configuration file mutex.
 
constexpr char constadvgetopt::anonymous_namespace{utils.cpp}::g_simple_characters = "+-./0123456789=ABCEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz_"
 
constexpr char const advgetopt::anonymous_namespace{utils.cpp}::g_single_quote = '\''
 

Detailed Description

This file includes various utility functions that are not specifically attached to a class.

Definition in file utils.cpp.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.