2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-01-25 13:56:53 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
|
|
|
|
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
|
|
|
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2012-06-10 16:50:54 +00:00
|
|
|
*/
|
|
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#pragma once
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2025-03-25 01:26:29 +00:00
|
|
|
#include <string>
|
2014-03-21 08:32:36 +00:00
|
|
|
|
2025-01-06 00:55:07 +00:00
|
|
|
//! std::string utilities
|
2014-03-21 08:32:36 +00:00
|
|
|
/*!
|
|
|
|
|
Provides functions for string manipulation.
|
|
|
|
|
*/
|
2025-06-19 21:47:35 +00:00
|
|
|
namespace deskflow::string {
|
2014-03-21 08:32:36 +00:00
|
|
|
|
|
|
|
|
//! Format positional arguments
|
|
|
|
|
/*!
|
|
|
|
|
Format a string using positional arguments. fmt has literal
|
|
|
|
|
characters and conversion specifications introduced by `\%':
|
|
|
|
|
- \%\% -- literal `\%'
|
|
|
|
|
- \%{n} -- positional element n, n a positive integer, {} are literal
|
|
|
|
|
|
|
|
|
|
All arguments in the variable list are const char*. Positional
|
|
|
|
|
elements are indexed from 1.
|
|
|
|
|
*/
|
2025-01-06 00:55:07 +00:00
|
|
|
std::string format(const char *fmt, ...);
|
2014-03-21 08:32:36 +00:00
|
|
|
|
|
|
|
|
//! Format positional arguments
|
|
|
|
|
/*!
|
|
|
|
|
Same as format() except takes va_list.
|
|
|
|
|
*/
|
2025-01-06 00:55:07 +00:00
|
|
|
std::string vformat(const char *fmt, va_list);
|
2014-03-21 08:32:36 +00:00
|
|
|
|
|
|
|
|
//! Print a string using sprintf-style formatting
|
|
|
|
|
/*!
|
2014-11-11 13:51:47 +00:00
|
|
|
Equivalent to sprintf() except the result is returned as a String.
|
2014-03-21 08:32:36 +00:00
|
|
|
*/
|
2025-01-06 00:55:07 +00:00
|
|
|
std::string sprintf(const char *fmt, ...);
|
2014-03-21 08:32:36 +00:00
|
|
|
|
|
|
|
|
//! Case-insensitive comparisons
|
|
|
|
|
/*!
|
|
|
|
|
This class provides case-insensitve comparison functions.
|
|
|
|
|
*/
|
2024-10-17 18:04:35 +00:00
|
|
|
class CaselessCmp
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
public:
|
|
|
|
|
//! Same as less()
|
2025-01-06 00:55:07 +00:00
|
|
|
bool operator()(const std::string &a, const std::string &b) const;
|
2014-03-21 08:32:36 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
//! Returns true iff \c a is lexicographically less than \c b
|
2025-05-22 00:31:48 +00:00
|
|
|
static bool less(const std::string_view &a, const std::string_view &b);
|
2014-03-21 08:32:36 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
//! Returns true iff \c a is lexicographically equal to \c b
|
2025-01-06 00:55:07 +00:00
|
|
|
static bool equal(const std::string &a, const std::string &b);
|
2014-03-21 08:32:36 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
//! Returns true iff \c a is lexicographically less than \c b
|
2025-01-06 00:55:07 +00:00
|
|
|
static bool cmpLess(const std::string::value_type &a, const std::string::value_type &b);
|
2014-03-21 08:32:36 +00:00
|
|
|
};
|
|
|
|
|
|
2025-06-19 21:47:35 +00:00
|
|
|
} // namespace deskflow::string
|