swift
Loading...
Searching...
No Matches
swift::misc Namespace Reference

Free functions in swift::misc. More...

Namespaces

namespace  shared_state
 Utilities for sharing state between multiple objects.
namespace  settings
 Classes related to configuration settings.
namespace  Iterators
 Iterator classes for the containers.
namespace  GeoPosition
 Position handling as geo locations and coordinates systems.
namespace  predicates
 Functor classes for evaluating predicate calculus expressions.
namespace  mixin
 Mixin classes which implement common operations for value classes.
namespace  test
 Generate data for testing purposes.

Classes

class  CApplicationInfo
 Description of a swift application. More...
class  CApplicationInfoList
 List of swift application descriptions. More...
class  CAtomicFile
 A subclass of QFile which writes to a temporary file while it is open, then renames the file when it is closed, so that it overwrites the target file as a single, atomic transaction. More...
class  CCacheSettingsUtils
 Utils for copying cache and settings content. More...
class  QOrderedSet
 Needed for compatibility with C++ standard algorithms which expect ordered sets. More...
class  CCollection
 Generic ordered container with value semantics. More...
class  CCompressUtils
 Compress utilities. More...
class  CConnectionGuard
 List of QMetaObject::Connection. More...
class  CContainerHelper
 Class providing static helper methods for different containers. More...
class  CContainerBase
 Base class for CCollection and CSequence adding mutating operations and CValueObject facility on top of CRangeBase. More...
class  CCountry
 Color. More...
class  CCountryList
 Value object encapsulating a list of countries. More...
class  CCrashHandler
 Crash handler. More...
class  CCrashInfo
 Crash info. More...
class  CDataCacheRevision
 Encapsulates metastate about how the version of the cache in memory compares to the one on disk. More...
class  CDataCacheSerializer
 Worker which performs (de)serialization on behalf of CDataCache, in a separate thread so that the main thread is not blocked by (de)serialization of large objects. More...
class  CDataCache
 Singleton derived class of CValueCache, for core dynamic data. More...
class  CData
 Class template for accessing a specific value in the CDataCache. More...
class  CDataReadOnly
 Class template for read-only access to a specific value in the CDataCache. More...
struct  TDataTrait
 Base class for traits to be used as template argument to swift::misc::CData. More...
class  CDBusServer
 Custom DBusServer. More...
class  CDBusUtils
 Utils for UNIT tests / samples. More...
class  CDictionary
 Associative container with value semantics, chooses a sensible default implementation container type. More...
class  CDigestSignal
 Receive 1..n signals, collect them over time, and resend afer n milliseconds. More...
class  CDirectories
 Directories (swift data directories). More...
class  CDirectoryUtils
 Utility class for directory operations. More...
class  CEventLoop
 Utility class which blocks until a signal is emitted or timeout reached. More...
class  CFileLogger
 Class to write log messages to file. More...
class  CFileUtils
 Utility class for file operations. More...
class  CGenericDBusInterface
 Used for hand written interface based on virtual methods. More...
class  CIcon
 Value object for icons. An icon is stored in the global icon repository and identified by its index. It contains no(!) pyhsical data for the icon itself. More...
class  CIconList
 Icon list (swift standard icons). More...
class  CIcons
 Standard icons. More...
class  CIdentifiable
 Base class with a member CIdentifier to be inherited by a class which has an identity in the environment of modular distributed swift processes. More...
class  CIdentifier
 Value object encapsulating information identifying a component of a modular distributed swift process (core, GUI, audio). More...
class  CIdentifierList
 Value object encapsulating a list of object identifiers. More...
struct  TBaseOf
 If T has a member typedef base_type, this trait will obtain it, otherwise void. More...
struct  TMetaBaseOf
 It T has a member typedef base_type which is a registered metatype, this trait will obtain it, otherwise void. More...
struct  TIndexBaseOf
 If T has a member typedef base_type which has a member propertyByIndex, this trait will obtain it, otherwise void. More...
class  CJsonException
 Thrown when a convertFromJson method encounters an unrecoverable error in JSON data. More...
class  CJsonScope
 Pseudo-RAII pattern that tracks the current JSON value being converted. More...
class  LockFree
 Lock-free wrapper for synchronizing multi-threaded access to an object. More...
class  LockFreeReader
 Return value of LockFree::read(). More...
class  LockFreeUniqueWriter
 Return value of LockFree::uniqueWrite(). More...
class  LockFreeMulti
 Compose multiple LockFreeReader or LockFreeUniqueWriter instances. More...
class  CLogCategories
 Predefined special log categories. More...
class  CLogCategory
 A log category is an arbitrary string tag which can be attached to log messages. More...
class  CLogCategoryList
 A sequence of log categories. More...
class  CLogHandler
 Class for subscribing to log messages. More...
class  CLogPatternHandler
 A class for subscribing to log messages which match particular patterns. More...
class  CLogSubscriber
 A helper class for subscribing to log messages matching a particular pattern, with the ability to change the pattern at runtime. More...
class  CLogHistory
 Records all log messages to a list that persists for the lifetime of the application. More...
class  CLogHistorySource
 Allows distributed insertion of log messages into a central CLogHistory. More...
class  CLogHistoryReplica
 Allows distributed access to the log messages of a central CLogHistory. More...
class  CLogMessage
 Class for emitting a log message. More...
class  CLogPattern
 Value class for matching log messages based on their categories. More...
class  CMacOSMicrophoneAccess
 Wrapper around MacOS 10.14 AVCaptureDevice AVCaptureDevice authorization. More...
class  CMapBuilder
 Build a QMap more efficiently when calling insert() in a for loop. More...
class  CMemoTable
 A data memoization pattern useful for compressing JSON representations of containers. More...
struct  CMemoHelper
 Helper class for memoizing members of a value object. More...
struct  CExplicitLatin1String
 Simple literal type containing a single QLatin1String. More...
struct  MetaFlags
 Type wrapper for passing MetaFlag to CMetaMember::has. More...
struct  CMetaMember
 Literal aggregate type representing attributes of one member of a value class. More...
struct  CMetaMemberList
 Literal aggregate type representing attributes of the members of a value class. More...
class  CMetaClass
 Base class for meta classes. More...
class  CMetaClassIntrospector
 An introspector for a metaclass. More...
class  LosslessTag
 Tag type signifying overloaded marshalling methods that preserve data at the expense of size. More...
class  CNameVariantPair
 Value / variant pair. More...
class  CNameVariantPairList
 Value object encapsulating a list of name/variant pairs. More...
class  CObfuscation
 Utility class to obfuscate strings in the source code to make them unreadable. More...
class  Optional
 Own implementation of std::optional. More...
class  IOrderable
 Entity with order attribute (can be manually ordered in views). More...
class  IOrderableList
 List of orderable IOrderable objects. More...
class  CPixmap
 Pixmap which can be transferred via DBus. More...
class  CPlatform
 Platform (i.e. More...
class  CPlatformSet
 Value object for a set of platforms. More...
class  CProcessCtrl
 Wrapper around QProcess with additional features. More...
class  CProcessInfo
 Value class identifying a process, with a PID and a name. More...
class  CPromise
 A promise-based interface to QFuture, similar to std::promise for std::future. More...
class  CPromise< void >
 Specialization of CPromise for void futures. More...
class  CPropertyIndex
 Property index. More...
class  CPropertyIndexList
 Value object encapsulating a list of property indexes. More...
class  CPropertyIndexRef
 Non-owning reference to a CPropertyIndex with a subset of its features. More...
class  CPropertyIndexVariantMap
 Specialized value object compliant map for variants, based on indexes. More...
class  IProvider
 Base class for providers. More...
class  IProviderAware
 Base class of provider aware classes. More...
class  CRange
 A range is a conceptual container which does not contain any elements of its own, but is constructed from a begin iterator and an end iterator of another container. More...
class  CRangeBase
 Any container class with begin and end iterators can inherit from this CRTP class to gain some useful algorithms as member functions. More...
class  CRgbColor
 Color. More...
class  CSequence
 Generic sequential container with value semantics. More...
class  CSetBuilder
 Build a QSet more efficiently when calling insert() in a for loop. More...
class  CSettingsCache
 Singleton derived class of CValueCache, for settings. More...
class  CSetting
 Class template for accessing a specific value in the CSettingsCache. More...
class  CSettingReadOnly
 Class template for accessing a specific value in the CSettingsCache. More...
struct  TSettingTrait
 Base class for traits to be used as template argument to swift::misc::CSetting. More...
class  CSimpleCommandParser
 Utility methods for simple line parsing used with the command line. More...
class  CSlot
 Callable wrapper for a member function with function signature F. More...
class  CSlot< R(Args...)>
 Callable wrapper for a member function with function signature R(Args...). More...
class  CStatusException
 Throwable exception class containing a CStatusMessage. More...
class  CStrongStringView
 Special-purpose string class used by CMessageBase. More...
class  CMessageBase
 Base class for CStatusMessage and CLogMessage. More...
class  CStatusMessage
 Streamable status message, e.g. More...
class  CStatusMessageList
 Status messages, e.g. from Core -> GUI. More...
struct  TString
 Stringification traits class. More...
class  CSwiftDirectories
 Locations of important directories for swift files. More...
class  CThreadedTimer
 Thread-safe timer class. More...
class  CThreadUtils
 Utility class for threaded operations. More...
class  ITimestampBased
 Entity with timestamp. More...
class  ITimestampWithOffsetBased
 Entity with timestamp. More...
struct  MillisecondsMinMaxMean
 Milliseconds minimum/maximum/mean. More...
class  ITimestampObjectList
 List of objects with timestamp. Such objects should implement. More...
class  ITimestampWithOffsetObjectList
 List of objects with timestamp and offset. Such objects should implement. More...
class  CTokenBucket
 Token bucket algorithm. More...
struct  TParameter
 Trait to detect properties of function parameter types. More...
struct  THasToQString
 Trait to detect whether T contains a member function toQString. More...
struct  THasPushBack
 Trait which is true if the expression a.push_back(v) is valid when a and v are instances of T and T::value_type. More...
struct  THasGetLogCategories
 Trait to detect whether a class T has a static member function named getLogCategories. More...
struct  TModelsQHashKey
 Trait to detect whether a class T can be used as a key in a QHash. More...
struct  TModelsQMapKey
 Trait to detect whether a class T can be used as a key in a QMap. More...
struct  THasCompare
 Trait which is true if the expression compare(a, b) is valid when a and b are instances of T and U. More...
struct  THasComparePropertyByIndex
 Trait which is true if the expression a.compareByPropertyIndex(b, i) is valid when a and b are instances of T, and i is an instance of CPropertyIndexRef. More...
struct  THasPropertyByIndex
 Trait which is true if the expression a.propertyByIndex(i) is valid with a is an instance of T and i is an instance of CPropertyIndexRef. More...
struct  TIsEqualityComparable
 Trait which is true if the expression a == b is valid when a and b are instances of T and U. More...
struct  THasMarshallMethods
 Trait which is true if T has methods marshallToDbus and unmarshallFromDbus. More...
struct  TIsQPrivateSignal
 Trait that detects if a type is QPrivateSignal. More...
class  CValueCachePacket
 Value class used for signalling changed values in the cache. More...
class  CValueCache
 Manages a map of { QString, CVariant } pairs, which can be distributed among multiple processes. More...
class  CCached
 Provides access to one of the values stored in a CValueCache. More...
class  CEmpty
 Default base class for CValueObject. More...
class  CValueObject
 Mix of the most commonly used mixin classes. More...
class  CVariant
 Wrapper around QVariant which provides transparent access to CValueObject methods of the contained object if it is registered with swift::misc::registerMetaValueType. More...
class  CVariantList
 Value object encapsulating a list of variants. More...
class  CVariantMap
 Map of { QString, CVariant } pairs. More...
class  CWinDllUtils
 Functions dealing with Windows DLLs. More...
class  CRegularThread
 Just a subclass of QThread whose destructor waits for the thread to finish. More...
class  CWorkerBase
 Base class for CWorker and CContinuousWorker. More...
class  CWorker
 Class for doing some arbitrary parcel of work in its own thread. More...
class  CContinuousWorker
 Base class for a long-lived worker object which lives in its own thread. More...
class  CSampleUtils
 Utils for sample programms. More...
class  CTestValueObject
 Test value object. More...

Typedefs

template<typename K, typename V>
using TDefaultAssociativeType
 Trait to select the appropriate default associative container type depending on what the key type supports.
template<class T>
using TBaseOfT = typename TBaseOf<T>::type
 Alias for typename TBaseOf<T>::type.
template<class T>
using TMetaBaseOfT = typename TMetaBaseOf<T>::type
 Alias for typename TMetaBaseOf<T>::type.
template<class T>
using TIndexBaseOfT = typename TIndexBaseOf<T>::type
 Alias for typename TIndexBaseOf<T>::type.

Enumerations

enum  MetaFlag {
  DisabledForComparison = 1 << 0 , DisabledForMarshalling = 1 << 1 , DisabledForDebugging = 1 << 2 , DisabledForHashing = 1 << 3 ,
  DisabledForJson = 1 << 4 , CaseInsensitiveComparison = 1 << 5 , LosslessMarshalling = 1 << 6 , RequiredForJson = 1 << 7
}
 Metadata flags attached to members of a meta class. More...
enum  StatusSeverity { SeverityDebug , SeverityInfo , SeverityWarning , SeverityError }
 Status severities. More...
enum class  ParameterPassBy { Value , ConstRef }
 Whether an input parameter type should be passed by value or by const reference. More...

Functions

template<typename I, typename J>
auto removeIfIn (I begin1, I end1, J begin2, J end2)
 Removes those elements in range 1 that appear also in range 2 leaving only those that do not appear in range 2.
template<typename ForwardIt, typename OutputIt, typename Generator>
void copyRandomElements (ForwardIt in, ForwardIt end, OutputIt out, int n, Generator &&rng)
 Use the random number generator rng to choose n elements from the range [in,end) and copy them to out.
template<typename ForwardIt, typename OutputIt>
void copyRandomElements (ForwardIt in, ForwardIt end, OutputIt out, int n)
 Randomly choose n elements from the range [in,end) and copy them to out.
template<typename ForwardIt, typename OutputIt, typename Generator>
void copySampleElements (ForwardIt in, ForwardIt end, OutputIt out, int n, Generator &&rng)
 Split the range [in,end) into n equal chunks and use the random number generator rng to choose one element from each.
template<typename ForwardIt, typename OutputIt>
void copySampleElements (ForwardIt in, ForwardIt end, OutputIt out, int n)
 Split the range [in,end) into n equal chunks and randomly choose one element from each.
template<typename I, typename F>
void topologicalSort (I begin, I end, F comparator)
 Topological sorting algorithm.
template<typename C, typename T, typename F>
void topologicallySortedInsert (C &container, T &&value, F comparator)
 Insert an element into a sequential container while preserving the topological ordering of the container.
template<typename T, typename F>
void tupleForEachPair (T &&tuple, F &&visitor)
 Invoke a visitor function on each pair of elements of a tuple in order.
int getProcessCpuTimeMs ()
 Get the time in milliseconds that the CPU has spent executing the current process.
int getThreadCpuTimeMs ()
 Get the time in milliseconds that the CPU has spent executing the current thread.
template<class Key, class Value>
QMap< Key, Value > & implementationOf (QMap< Key, Value > &dict)
 Identity function for API consistency with CDictionary::implementationOf.
template<class Key, class Value>
const QMap< Key, Value > & implementationOf (const QMap< Key, Value > &dict)
 Identity function for API consistency with CDictionary::implementationOf.
template<class Map1, class Map2, class F>
void forEachIntersection (const Map1 &map1, const Map2 &map2, F functor)
 Call a functor for each {key,value1,value2} triple in the keywise intersection of two maps.
QString applicationName ()
 Get application name.
QString logFileName ()
 Get log file name.
QString toHtmTable (const QStringList &values, int columns)
 Values as HTML table.
QString asHyperlink (const QString &url, const QString &text="")
 As hyperlink.
SWIFT_MISC_EXPORT bool pixmapToPngByteArray (const QPixmap &pixmap, QByteArray &array)
 Pixmap to PNG byte array.
SWIFT_MISC_EXPORT QPixmap pngByteArrayToPixmap (const QByteArray &array)
 Pixmap from PNG byte array.
SWIFT_MISC_EXPORT bool pngByteArrayToPixmapRef (const QByteArray &array, QPixmap &pixmap)
 Pixmap from PNG byte array.
SWIFT_MISC_EXPORT QString pixmapToPngHexString (const QPixmap &pixmap)
 Pixmap as HEX string (for PNG image).
SWIFT_MISC_EXPORT QPixmap pngHexStringToPixmap (const QString &hexString)
 Hex encoded pixmap string to Pixmap.
SWIFT_MISC_EXPORT bool pngHexStringToPixmapRef (const QString &hexString, QPixmap &pixmap)
 Hex encoded pixmap string to Pixmap.
SWIFT_MISC_EXPORT QPixmap iconToPixmap (const QIcon &icon)
 Icon to pixmap.
template<typename... Ts>
LockFreeMulti< LockFreeReader, const Ts... > multiRead (const LockFree< Ts > &...vs)
 Return a callable object for reading from multiple LockFree instances simultaneously.
template<typename... Ts>
LockFreeMulti< LockFreeUniqueWriter, Ts... > multiUniqueWrite (LockFree< Ts > &...vs)
 Return a callable object for writing to multiple LockFree instances simultaneously.
template<quint64 A, quint64 B>
constexpr MetaFlags< A|B > operator| (MetaFlags< A >, MetaFlags< B >)
 Compile-time union of MetaFlags.
template<quint64 A, quint64 B>
constexpr MetaFlags< A &B > operator& (MetaFlags< A >, MetaFlags< B >)
 Compile-time intersection of MetaFlags.
template<typename T>
constexpr auto introspect ()
 Obtain the CMetaClassIntrospector for the metaclass of T.
void displayAllUserMetatypesTypes (QTextStream &out)
 Display all user metatypes.
QString getAllUserMetatypesTypes (const QString &separator="\n")
 Get all user metatypes.
QString className (const QObject *object)
 Class name as from QMetaObject::className with namespace.
QString classNameShort (const QObject *object)
 Class name as from QMetaObject::className without namespace.
size_t heapSizeOf (const QMetaType &)
 Q_CC_MSVC.
size_t heapSizeOf (const QMetaObject &objectType)
 Real heap size of an object.
template<typename T>
void swap (Optional< T > &a, Optional< T > &b) noexcept(std::is_nothrow_swappable_v< T >)
 Efficient swap for two Optional objects.
bool startDetachedWithConsoleWindow (const QString &program, const QStringList &arguments)
template<typename T, typename F>
void doAfter (QFuture< T > future, QObject *context, F &&func)
 Connect a slot or function to be invoked in the given context when a QFuture is finished.
template<typename F>
void doAfter (QFuture< void > future, QObject *context, F &&func)
 Connect a slot or function to be invoked in the given context when a void QFuture is finished.
template<class I, class I2>
auto makeRange (I begin, I2 end) -> CRange< I >
 Returns a CRange constructed from begin and end iterators of deduced types.
template<class T>
auto makeConstRange (const T &container) -> CRange< decltype(container.cbegin())>
 Returns a const CRange constructed from the cbegin and cend iterators of the given container.
template<class T>
void makeKeysRange (const T &&container)=delete
 Keys range for a temporary would be unsafe.
template<class T>
void makePairsRange (const T &&container)=delete
 Pairs range for a temporary would be unsafe.
void registerMetadata ()
 Register all relevant metadata in Misc.
template<typename T, typename U, typename F, typename G>
QMetaObject::Connection connectOnce (T *sender, F signal, U *receiver, G &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 Wrapper around QObject::connect which disconnects after the signal has been emitted once.
template<typename T, typename F, typename G>
QMetaObject::Connection connectOnce (T *sender, F signal, G &&slot)
 Wrapper around QObject::connect which disconnects after the signal has been emitted once.
QStringList getStackTrace ()
 Returns a stack trace of the current thread of execution as a list of function names.
QStringList getStackTraceAlways ()
 Returns a stack trace of the current thread of execution as a list of function names.
template<class F>
QString removeChars (const QString &s, F predicate)
 Return a string with characters removed that match the given predicate.
QString removeIfInString (const QString &string, const QString &inString)
 Remove if in string.
QString removeIfNotInString (const QString &string, const QString &inString)
 Remove if NOT in string.
QString removeLineBreakAndTab (const QString &s)
 Remove line breaks and tabs.
SWIFT_MISC_EXPORT QString removeDateTimeSeparators (const QString &s)
 Remove the typical separators such as "-", " ".
template<class F>
bool containsChar (const QString &s, F predicate)
 True if any character in the string matches the given predicate.
bool containsLineBreakOrTab (const QString &s)
 Contains a line break or tab.
template<class F>
int indexOfChar (const QString &s, F predicate)
 Index of first character in the string matching the given predicate, or -1 if not found.
SWIFT_MISC_EXPORT qsizetype nthIndexOf (const QString &string, QChar ch, int nth=1, Qt::CaseSensitivity cs=Qt::CaseInsensitive)
 nth index of ch
template<class F>
QList< QStringView > splitStringRefs (const QString &s, F predicate)
 Split a string into multiple strings, using a predicate function to identify the split points.
SWIFT_MISC_EXPORT QList< QStringView > splitLinesRefs (const QString &s)
 Split a string into multiple lines. Blank lines are skipped.
template<class F>
void splitStringRefs (const QString &&, F)=delete
 It would be risky to call splitStringRefs with an rvalue, so forbid it.
void splitLinesRefs (const QString &&)=delete
 It would be risky to call splitLinesRefs with an rvalue, so forbid it.
template<class F>
QStringList splitString (const QString &s, F predicate)
 Split a string into multiple strings, using a predicate function to identify the split points.
SWIFT_MISC_EXPORT QStringList splitLines (const QString &s)
 Split a string into multiple lines. Blank lines are skipped.
SWIFT_MISC_EXPORT QByteArray utfToPercentEncoding (const QString &s, const QByteArray &allow={}, char percent='%')
 Extended percent encoding supporting UTF-16.
SWIFT_MISC_EXPORT QString utfFromPercentEncoding (const QByteArray &ba, char percent='%')
 Reverse utfFromPercentEncoding.
template<class K, class V>
QString qmapToString (const QMap< K, V > &map)
 A map converted to string.
SWIFT_MISC_EXPORT QMap< QString, QString > parseIniValues (const QString &data)
 Obtain ini file like values, e.g. foo=bar.
bool is09 (const QChar &c)
 Is 0-9 char, isDigit allows a bunch of more characters.
bool is09OrSeparator (const QChar &c)
 Is 0-9, or ","/";".
const QString & safeAt (const QStringList &stringList, int index)
 Safe "at" function, returns empty string if index does not exists.
bool isDigitsOnlyString (const QString &testString)
 String with digits only.
bool is09OnlyString (const QString &testString)
 String with 0-9 only.
bool is09OrSeparatorOnlyString (const QString &testString)
 String with 0-9/separator only.
QString digitOnlyString (const QString &string)
 String only with digits.
QString char09OnlyString (const QString &string)
 String only with 0-9.
QString char09OrSeparatorOnlyString (const QString &string)
 String only with 0-9, or separator.
QString asciiOnlyString (const QString &string)
 String only with ASCII values.
SWIFT_MISC_EXPORT QString inApostrophes (const QString &in, bool ignoreEmpty=false)
 Return string in apostrophes.
SWIFT_MISC_EXPORT QString inQuotes (const QString &in, bool ignoreEmpty=false)
 Return string in quotes.
SWIFT_MISC_EXPORT bool hasBalancedQuotes (const QString &in, char quote='"')
 Has balanced quotes.
SWIFT_MISC_EXPORT QString removeSurroundingApostrophes (const QString &in)
 Remove surrounding apostrophes 'foo' -> foo.
SWIFT_MISC_EXPORT QString removeSurroundingQuotes (const QString &in)
 Remove surrounding quotes "foo" -> foo.
SWIFT_MISC_EXPORT const QString & boolToOnOff (bool v)
 Bool to on/off.
SWIFT_MISC_EXPORT const QString & boolToYesNo (bool v)
 Bool to yes/no.
SWIFT_MISC_EXPORT const QString & boolToTrueFalse (bool v)
 Bool to true/false.
SWIFT_MISC_EXPORT const QString & boolToEnabledDisabled (bool v)
 Bool to enabled/disabled.
SWIFT_MISC_EXPORT const QString & boolToNullNotNull (bool isNull)
 Bool isNull to null/no null.
SWIFT_MISC_EXPORT bool stringToBool (const QString &boolString)
 Convert string to bool.
SWIFT_MISC_EXPORT int fuzzyShortStringComparision (const QString &str1, const QString &str2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 Fuzzy compare for short strings (like ICAO designators).
SWIFT_MISC_EXPORT QString intToHex (int value, int digits=2)
 Int to hex value.
SWIFT_MISC_EXPORT QString dotToLocaleDecimalPoint (QString &input)
 Replace dot '.' by locale decimal point.
SWIFT_MISC_EXPORT QString dotToLocaleDecimalPoint (const QString &input)
 Replace dot '.' by locale decimal point.
SWIFT_MISC_EXPORT QString stripDesignatorFromCompleterString (const QString &candidate)
 Strip a designator from a combined string.
SWIFT_MISC_EXPORT QString simplifyAccents (const QString &candidate)
 Remove accents / diacritic marks from a string.
SWIFT_MISC_EXPORT QString simplifyByDecomposition (const QString &candidate)
 Remove accents / diacritic marks from a string by doing a Unicode decomposition and removing mark characters.
SWIFT_MISC_EXPORT bool caseInsensitiveStringCompare (const QString &c1, const QString &c2)
 Case insensitive string compare.
SWIFT_MISC_EXPORT bool stringCompare (const QString &c1, const QString &c2, Qt::CaseSensitivity cs)
 String compare.
SWIFT_MISC_EXPORT QString simplifyNameForSearch (const QString &name)
 Get a simplified upper case name for searching by removing all characters except A-Z.
SWIFT_MISC_EXPORT QString withQuestionMark (const QString &question)
 Add a question mark at the end if not existing.
SWIFT_MISC_EXPORT QDateTime fromStringUtc (const QString &dateTimeString, const QString &format)
 Same as QDateTime::fromString but QDateTime will be set to UTC.
SWIFT_MISC_EXPORT QDateTime fromStringUtc (const QString &dateTimeString, Qt::DateFormat format=Qt::TextDate)
 Same as QDateTime::fromString but QDateTime will be set to UTC.
SWIFT_MISC_EXPORT QDateTime fromStringUtc (const QString &dateTimeString, const QLocale &locale, QLocale::FormatType format)
 Same as QDateTime::fromString but QDateTime will be set to UTC.
SWIFT_MISC_EXPORT QDateTime parseMultipleDateTimeFormats (const QString &dateTimeString)
 Parse multiple date time formats.
SWIFT_MISC_EXPORT QDateTime parseDateTimeStringOptimized (const QString &dateTimeString)
 Parse yyyyMMddHHmmsszzz strings optimized.
SWIFT_MISC_EXPORT QString joinStringSet (const QSet< QString > &set, const QString &separator)
 Convert string to bool.
SWIFT_MISC_EXPORT QString removeComments (const QString &in, bool removeSlash, bool removeDoubleSlash)
 Remove comments such as /‍** **‍/ or //.
SWIFT_MISC_EXPORT bool containsAny (const QString &testString, const QStringList &any, Qt::CaseSensitivity cs)
 Contains any string of the list?
SWIFT_MISC_EXPORT double parseFraction (const QString &fraction, double failDefault=std::numeric_limits< double >::quiet_NaN())
 Parse a fraction like 2/3.
SWIFT_MISC_EXPORT QString cleanNumber (const QString &number)
 Remove leading 0, trailing 0, " ", and "." from a number.
template<typename F>
auto singleShot (int msec, QObject *target, F &&task)
 Starts a single-shot timer which will call a task in the thread of the given object when it times out.
SWIFT_MISC_EXPORT void setMockCacheRootDirectory (const QString &path)
 Overwrite the default root directory for cache and settings, for testing purposes.
template<typename T>
void registerMetaValueType ()
 This registers the value type T with the swift::misc:: meta type system, making it available for use with the extended feature set of swift::misc::CVariant.
size_t qHash (const std::string &key, uint seed)
 std::string qHash
template<typename T>
T::const_iterator begin (const LockFreeReader< T > &reader)
 Non-member begin() and end() for so LockFree containers can be used in ranged for loops.
template<typename T>
T::const_iterator end (const LockFreeReader< T > &reader)
 Non-member begin() and end() for so LockFree containers can be used in ranged for loops.
template<typename T>
T::iterator begin (const LockFreeUniqueWriter< T > &writer)
 Non-member begin() and end() for so LockFree containers can be used in ranged for loops.
template<typename T>
T::iterator end (const LockFreeUniqueWriter< T > &writer)
 Non-member begin() and end() for so LockFree containers can be used in ranged for loops.
template<typename T>
T::const_iterator begin (const LockFreeReader< T > &&)=delete
 Deleted overloads of begin() and end() for rvalue readers and writers.
template<typename T>
T::const_iterator end (const LockFreeReader< T > &&)=delete
 Deleted overloads of begin() and end() for rvalue readers and writers.
template<typename T>
T::iterator begin (const LockFreeUniqueWriter< T > &&)=delete
 Deleted overloads of begin() and end() for rvalue readers and writers.
template<typename T>
T::iterator end (const LockFreeUniqueWriter< T > &&)=delete
 Deleted overloads of begin() and end() for rvalue readers and writers.
template<class I>
QDebug operator<< (QDebug d, const CRange< I > &range)
 Streaming operators for CRange to qDebug.
template<class I>
QNoDebug operator<< (QNoDebug d, const CRange< I > &)
 Streaming operators for CRange to qDebug.
template<class T>
auto makeRange (T &container) -> CRange< decltype(container.begin())>
 Returns a CRange constructed from the begin and end iterators of the given container.
template<class T>
auto makeRange (const T &container) -> CRange< decltype(container.begin())>
 Returns a CRange constructed from the begin and end iterators of the given container.
template<class T>
auto makeKeysRange (const T &container)
 Returns a const CRange for iterating over the keys of a Qt associative container.
template<class T>
void makeKeysRange (T &container)
 Returns a const CRange for iterating over the keys of a Qt associative container.
template<class T>
auto makePairsRange (const T &container)
 Returns a const CRange for iterating over the keys and values of a Qt associative container.
template<class T>
auto makePairsRange (T &container)
 Returns a const CRange for iterating over the keys and values of a Qt associative container.

Variables

template<typename T>
constexpr bool THasMetaBaseV = QMetaTypeId<typename TBaseOf<T>::type>::Defined
 True if T has a member typedef base_type which is a registered metatype.

Detailed Description

Free functions in swift::misc.

Register metadata.

Base and utility classes available in all other projects.

Typedef Documentation

◆ TBaseOfT

template<class T>
using swift::misc::TBaseOfT = typename TBaseOf<T>::type

Alias for typename TBaseOf<T>::type.

Definition at line 72 of file inheritancetraits.h.

◆ TDefaultAssociativeType

template<typename K, typename V>
using swift::misc::TDefaultAssociativeType
Initial value:
typename private_ns::TAssociativityTraits<TModelsQHashKey<K>::value,
TModelsQMapKey<K>::value>::template DefaultType<K, V>
Trait to detect whether a class T can be used as a key in a QMap.
Definition typetraits.h:109

Trait to select the appropriate default associative container type depending on what the key type supports.

Definition at line 68 of file dictionary.h.

◆ TIndexBaseOfT

template<class T>
using swift::misc::TIndexBaseOfT = typename TIndexBaseOf<T>::type

Alias for typename TIndexBaseOf<T>::type.

Definition at line 84 of file inheritancetraits.h.

◆ TMetaBaseOfT

template<class T>
using swift::misc::TMetaBaseOfT = typename TMetaBaseOf<T>::type

Alias for typename TMetaBaseOf<T>::type.

Definition at line 78 of file inheritancetraits.h.

Enumeration Type Documentation

◆ ParameterPassBy

enum class swift::misc::ParameterPassBy
strong

Whether an input parameter type should be passed by value or by const reference.

Definition at line 35 of file typetraits.h.

◆ StatusSeverity

Status severities.

Definition at line 34 of file statusmessage.h.

Function Documentation

◆ applicationName()

QString swift::misc::applicationName ( )

Get application name.

Definition at line 24 of file filelogger.cpp.

◆ asciiOnlyString()

QString swift::misc::asciiOnlyString ( const QString & string)
inline

String only with ASCII values.

Definition at line 212 of file stringutils.h.

◆ asHyperlink()

SWIFT_MISC_EXPORT QString swift::misc::asHyperlink ( const QString & url,
const QString & text )

As hyperlink.

Definition at line 34 of file htmlutils.cpp.

◆ begin() [1/4]

template<typename T>
T::const_iterator swift::misc::begin ( const LockFreeReader< T > && )
delete

Deleted overloads of begin() and end() for rvalue readers and writers.

Attempting to call begin() or end() on an rvalue reader or writer would be a common source of mistakes.

◆ begin() [2/4]

template<typename T>
T::const_iterator swift::misc::begin ( const LockFreeReader< T > & reader)

Non-member begin() and end() for so LockFree containers can be used in ranged for loops.

Definition at line 258 of file lockfree.h.

◆ begin() [3/4]

template<typename T>
T::iterator swift::misc::begin ( const LockFreeUniqueWriter< T > && )
delete

Deleted overloads of begin() and end() for rvalue readers and writers.

Attempting to call begin() or end() on an rvalue reader or writer would be a common source of mistakes.

◆ begin() [4/4]

template<typename T>
T::iterator swift::misc::begin ( const LockFreeUniqueWriter< T > & writer)

Non-member begin() and end() for so LockFree containers can be used in ranged for loops.

Definition at line 270 of file lockfree.h.

◆ char09OnlyString()

QString swift::misc::char09OnlyString ( const QString & string)
inline

String only with 0-9.

Definition at line 200 of file stringutils.h.

◆ char09OrSeparatorOnlyString()

QString swift::misc::char09OrSeparatorOnlyString ( const QString & string)
inline

String only with 0-9, or separator.

Definition at line 206 of file stringutils.h.

◆ className()

SWIFT_MISC_EXPORT QString swift::misc::className ( const QObject * object)

Class name as from QMetaObject::className with namespace.

Definition at line 45 of file metadatautils.cpp.

◆ classNameShort()

SWIFT_MISC_EXPORT QString swift::misc::classNameShort ( const QObject * object)

Class name as from QMetaObject::className without namespace.

Definition at line 54 of file metadatautils.cpp.

◆ connectOnce() [1/2]

template<typename T, typename F, typename G>
QMetaObject::Connection swift::misc::connectOnce ( T * sender,
F signal,
G && slot )

Wrapper around QObject::connect which disconnects after the signal has been emitted once.

Note
Slot has no context, so will always be a direct connection, slot will be called in sender's thread.

Definition at line 52 of file slot.h.

◆ connectOnce() [2/2]

template<typename T, typename U, typename F, typename G>
QMetaObject::Connection swift::misc::connectOnce ( T * sender,
F signal,
U * receiver,
G && slot,
Qt::ConnectionType type = Qt::AutoConnection )

Wrapper around QObject::connect which disconnects after the signal has been emitted once.

Definition at line 27 of file slot.h.

◆ containsChar()

template<class F>
bool swift::misc::containsChar ( const QString & s,
F predicate )

True if any character in the string matches the given predicate.

Definition at line 64 of file stringutils.h.

◆ containsLineBreakOrTab()

bool swift::misc::containsLineBreakOrTab ( const QString & s)
inline

Contains a line break or tab.

Definition at line 70 of file stringutils.h.

◆ copyRandomElements() [1/2]

template<typename ForwardIt, typename OutputIt>
void swift::misc::copyRandomElements ( ForwardIt in,
ForwardIt end,
OutputIt out,
int n )

Randomly choose n elements from the range [in,end) and copy them to out.

Definition at line 79 of file algorithm.h.

◆ copyRandomElements() [2/2]

template<typename ForwardIt, typename OutputIt, typename Generator>
void swift::misc::copyRandomElements ( ForwardIt in,
ForwardIt end,
OutputIt out,
int n,
Generator && rng )

Use the random number generator rng to choose n elements from the range [in,end) and copy them to out.

Definition at line 63 of file algorithm.h.

◆ copySampleElements() [1/2]

template<typename ForwardIt, typename OutputIt>
void swift::misc::copySampleElements ( ForwardIt in,
ForwardIt end,
OutputIt out,
int n )

Split the range [in,end) into n equal chunks and randomly choose one element from each.

Definition at line 105 of file algorithm.h.

◆ copySampleElements() [2/2]

template<typename ForwardIt, typename OutputIt, typename Generator>
void swift::misc::copySampleElements ( ForwardIt in,
ForwardIt end,
OutputIt out,
int n,
Generator && rng )

Split the range [in,end) into n equal chunks and use the random number generator rng to choose one element from each.

Definition at line 89 of file algorithm.h.

◆ digitOnlyString()

QString swift::misc::digitOnlyString ( const QString & string)
inline

String only with digits.

Definition at line 194 of file stringutils.h.

◆ displayAllUserMetatypesTypes()

SWIFT_MISC_EXPORT void swift::misc::displayAllUserMetatypesTypes ( QTextStream & out)

Display all user metatypes.

Remarks
Used in order to debug code, do not remove

Definition at line 13 of file metadatautils.cpp.

◆ doAfter() [1/2]

template<typename T, typename F>
void swift::misc::doAfter ( QFuture< T > future,
QObject * context,
F && func )

Connect a slot or function to be invoked in the given context when a QFuture is finished.

Definition at line 68 of file promise.h.

◆ doAfter() [2/2]

template<typename F>
void swift::misc::doAfter ( QFuture< void > future,
QObject * context,
F && func )

Connect a slot or function to be invoked in the given context when a void QFuture is finished.

Definition at line 77 of file promise.h.

◆ end() [1/4]

template<typename T>
T::const_iterator swift::misc::end ( const LockFreeReader< T > && )
delete

Deleted overloads of begin() and end() for rvalue readers and writers.

Attempting to call begin() or end() on an rvalue reader or writer would be a common source of mistakes.

◆ end() [2/4]

template<typename T>
T::const_iterator swift::misc::end ( const LockFreeReader< T > & reader)

Non-member begin() and end() for so LockFree containers can be used in ranged for loops.

Definition at line 264 of file lockfree.h.

◆ end() [3/4]

template<typename T>
T::iterator swift::misc::end ( const LockFreeUniqueWriter< T > && )
delete

Deleted overloads of begin() and end() for rvalue readers and writers.

Attempting to call begin() or end() on an rvalue reader or writer would be a common source of mistakes.

◆ end() [4/4]

template<typename T>
T::iterator swift::misc::end ( const LockFreeUniqueWriter< T > & writer)

Non-member begin() and end() for so LockFree containers can be used in ranged for loops.

Definition at line 276 of file lockfree.h.

◆ forEachIntersection()

template<class Map1, class Map2, class F>
void swift::misc::forEachIntersection ( const Map1 & map1,
const Map2 & map2,
F functor )

Call a functor for each {key,value1,value2} triple in the keywise intersection of two maps.

Definition at line 541 of file dictionary.h.

◆ fromStringUtc() [1/3]

SWIFT_MISC_EXPORT QDateTime swift::misc::fromStringUtc ( const QString & dateTimeString,
const QLocale & locale,
QLocale::FormatType format )

Same as QDateTime::fromString but QDateTime will be set to UTC.

Remarks
potentially slow, so only to be used when format is unknown

◆ fromStringUtc() [2/3]

SWIFT_MISC_EXPORT QDateTime swift::misc::fromStringUtc ( const QString & dateTimeString,
const QString & format )

Same as QDateTime::fromString but QDateTime will be set to UTC.

Remarks
potentially slow, so only to be used when format is unknown

◆ fromStringUtc() [3/3]

SWIFT_MISC_EXPORT QDateTime swift::misc::fromStringUtc ( const QString & dateTimeString,
Qt::DateFormat format = Qt::TextDate )

Same as QDateTime::fromString but QDateTime will be set to UTC.

Remarks
potentially slow, so only to be used when format is unknown

◆ fuzzyShortStringComparision()

SWIFT_MISC_EXPORT int swift::misc::fuzzyShortStringComparision ( const QString & str1,
const QString & str2,
Qt::CaseSensitivity cs = Qt::CaseSensitive )

Fuzzy compare for short strings (like ICAO designators).

Returns
int 0..100 (100 is perfect match)

◆ getAllUserMetatypesTypes()

SWIFT_MISC_EXPORT QString swift::misc::getAllUserMetatypesTypes ( const QString & separator)

Get all user metatypes.

Definition at line 15 of file metadatautils.cpp.

◆ getProcessCpuTimeMs()

SWIFT_MISC_EXPORT int swift::misc::getProcessCpuTimeMs ( )

Get the time in milliseconds that the CPU has spent executing the current process.

This is the sum of getThreadCpuTimeMs() for all threads.

Definition at line 61 of file cputime.cpp.

◆ getStackTrace()

SWIFT_MISC_EXPORT QStringList swift::misc::getStackTrace ( )

Returns a stack trace of the current thread of execution as a list of function names.

Returns a dummy list in release build.

Definition at line 39 of file stacktrace.cpp.

◆ getStackTraceAlways()

SWIFT_MISC_EXPORT QStringList swift::misc::getStackTraceAlways ( )

Returns a stack trace of the current thread of execution as a list of function names.

Definition at line 139 of file stacktrace.cpp.

◆ getThreadCpuTimeMs()

SWIFT_MISC_EXPORT int swift::misc::getThreadCpuTimeMs ( )

Get the time in milliseconds that the CPU has spent executing the current thread.

Definition at line 65 of file cputime.cpp.

◆ heapSizeOf() [1/2]

SWIFT_MISC_EXPORT size_t swift::misc::heapSizeOf ( const QMetaObject & )

Real heap size of an object.

Definition at line 112 of file metadatautils.cpp.

◆ heapSizeOf() [2/2]

SWIFT_MISC_EXPORT size_t swift::misc::heapSizeOf ( const QMetaType & )

Q_CC_MSVC.

Real heap size of an object.

Definition at line 106 of file metadatautils.cpp.

◆ iconToPixmap()

QPixmap swift::misc::iconToPixmap ( const QIcon & icon)

Icon to pixmap.

Definition at line 70 of file imageutils.cpp.

◆ implementationOf() [1/2]

template<class Key, class Value>
const QMap< Key, Value > & swift::misc::implementationOf ( const QMap< Key, Value > & dict)

Identity function for API consistency with CDictionary::implementationOf.

Definition at line 532 of file dictionary.h.

◆ implementationOf() [2/2]

template<class Key, class Value>
QMap< Key, Value > & swift::misc::implementationOf ( QMap< Key, Value > & dict)

Identity function for API consistency with CDictionary::implementationOf.

Definition at line 523 of file dictionary.h.

◆ indexOfChar()

template<class F>
int swift::misc::indexOfChar ( const QString & s,
F predicate )

Index of first character in the string matching the given predicate, or -1 if not found.

Definition at line 77 of file stringutils.h.

◆ is09()

bool swift::misc::is09 ( const QChar & c)
inline

Is 0-9 char, isDigit allows a bunch of more characters.

Definition at line 159 of file stringutils.h.

◆ is09OnlyString()

bool swift::misc::is09OnlyString ( const QString & testString)
inline

String with 0-9 only.

Definition at line 182 of file stringutils.h.

◆ is09OrSeparator()

bool swift::misc::is09OrSeparator ( const QChar & c)
inline

Is 0-9, or ","/";".

Definition at line 162 of file stringutils.h.

◆ is09OrSeparatorOnlyString()

bool swift::misc::is09OrSeparatorOnlyString ( const QString & testString)
inline

String with 0-9/separator only.

Definition at line 188 of file stringutils.h.

◆ isDigitsOnlyString()

bool swift::misc::isDigitsOnlyString ( const QString & testString)
inline

String with digits only.

Definition at line 176 of file stringutils.h.

◆ logFileName()

QString swift::misc::logFileName ( )

Get log file name.

Definition at line 31 of file filelogger.cpp.

◆ makeConstRange()

template<class T>
auto swift::misc::makeConstRange ( const T & container) ->CRange< decltype(container.cbegin())>

Returns a const CRange constructed from the cbegin and cend iterators of the given container.

Definition at line 353 of file range.h.

◆ makeKeysRange() [1/2]

template<class T>
auto swift::misc::makeKeysRange ( const T & container)

Returns a const CRange for iterating over the keys of a Qt associative container.

This is more efficient than the keys() method of the container, as it doesn't allocate memory.

Definition at line 365 of file range.h.

◆ makeKeysRange() [2/2]

template<class T>
void swift::misc::makeKeysRange ( T & container)

Returns a const CRange for iterating over the keys of a Qt associative container.

This is more efficient than the keys() method of the container, as it doesn't allocate memory.

Definition at line 370 of file range.h.

◆ makePairsRange() [1/2]

template<class T>
auto swift::misc::makePairsRange ( const T & container)

Returns a const CRange for iterating over the keys and values of a Qt associative container.

The value_type of the returned range is std::pair<T::key_type &, T::value_type &>.

This is more efficient than using the keys() method of the container and thereafter looking up each key, as it neither allocates memory, nor performs any key lookups.

Definition at line 386 of file range.h.

◆ makePairsRange() [2/2]

template<class T>
auto swift::misc::makePairsRange ( T & container)

Returns a const CRange for iterating over the keys and values of a Qt associative container.

The value_type of the returned range is std::pair<T::key_type &, T::value_type &>.

This is more efficient than using the keys() method of the container and thereafter looking up each key, as it neither allocates memory, nor performs any key lookups.

Definition at line 391 of file range.h.

◆ makeRange() [1/3]

template<class T>
auto swift::misc::makeRange ( const T & container) ->CRange< decltype(container.begin())>

Returns a CRange constructed from the begin and end iterators of the given container.

Definition at line 343 of file range.h.

◆ makeRange() [2/3]

template<class I, class I2>
auto swift::misc::makeRange ( I begin,
I2 end )->CRange< I >

Returns a CRange constructed from begin and end iterators of deduced types.

Parameters
beginThe begin iterator.
endThe end iterator, which can be any iterator type convertible to I.

Definition at line 328 of file range.h.

◆ makeRange() [3/3]

template<class T>
auto swift::misc::makeRange ( T & container) ->CRange< decltype(container.begin())>

Returns a CRange constructed from the begin and end iterators of the given container.

Definition at line 338 of file range.h.

◆ multiRead()

template<typename... Ts>
LockFreeMulti< LockFreeReader, const Ts... > swift::misc::multiRead ( const LockFree< Ts > &... vs)

Return a callable object for reading from multiple LockFree instances simultaneously.

Definition at line 239 of file lockfree.h.

◆ multiUniqueWrite()

template<typename... Ts>
LockFreeMulti< LockFreeUniqueWriter, Ts... > swift::misc::multiUniqueWrite ( LockFree< Ts > &... vs)

Return a callable object for writing to multiple LockFree instances simultaneously.

Definition at line 248 of file lockfree.h.

◆ operator<<() [1/2]

template<class I>
QDebug swift::misc::operator<< ( QDebug d,
const CRange< I > & range )

Streaming operators for CRange to qDebug.

Definition at line 307 of file range.h.

◆ operator<<() [2/2]

template<class I>
QNoDebug swift::misc::operator<< ( QNoDebug d,
const CRange< I > &  )

Streaming operators for CRange to qDebug.

Definition at line 316 of file range.h.

◆ parseDateTimeStringOptimized()

SWIFT_MISC_EXPORT QDateTime swift::misc::parseDateTimeStringOptimized ( const QString & dateTimeString)

Parse yyyyMMddHHmmsszzz strings optimized.

Remarks
string needs to be cleaned up and containing only numbers
TZ is UTC

◆ parseMultipleDateTimeFormats()

SWIFT_MISC_EXPORT QDateTime swift::misc::parseMultipleDateTimeFormats ( const QString & dateTimeString)

Parse multiple date time formats.

Remarks
potentially slow, so only to be used when format is unknown
TZ is UTC

◆ pixmapToPngByteArray()

bool swift::misc::pixmapToPngByteArray ( const QPixmap & pixmap,
QByteArray & array )

Pixmap to PNG byte array.

Definition at line 9 of file imageutils.cpp.

◆ pixmapToPngHexString()

QString swift::misc::pixmapToPngHexString ( const QPixmap & pixmap)

Pixmap as HEX string (for PNG image).

Definition at line 39 of file imageutils.cpp.

◆ pngByteArrayToPixmap()

QPixmap swift::misc::pngByteArrayToPixmap ( const QByteArray & array)

Pixmap from PNG byte array.

Definition at line 18 of file imageutils.cpp.

◆ pngByteArrayToPixmapRef()

bool swift::misc::pngByteArrayToPixmapRef ( const QByteArray & array,
QPixmap & pixmap )

Pixmap from PNG byte array.

Definition at line 29 of file imageutils.cpp.

◆ pngHexStringToPixmap()

QPixmap swift::misc::pngHexStringToPixmap ( const QString & hexString)

Hex encoded pixmap string to Pixmap.

Definition at line 50 of file imageutils.cpp.

◆ pngHexStringToPixmapRef()

bool swift::misc::pngHexStringToPixmapRef ( const QString & hexString,
QPixmap & pixmap )

Hex encoded pixmap string to Pixmap.

Definition at line 60 of file imageutils.cpp.

◆ qHash()

size_t qHash ( const std::string & key,
uint seed )
inline

std::string qHash

Definition at line 84 of file metaclass.h.

◆ qmapToString()

template<class K, class V>
QString swift::misc::qmapToString ( const QMap< K, V > & map)

A map converted to string.

Definition at line 142 of file stringutils.h.

◆ registerMetadata()

SWIFT_MISC_EXPORT void swift::misc::registerMetadata ( )

Register all relevant metadata in Misc.

Definition at line 49 of file registermetadata.cpp.

◆ registerMetaValueType()

template<typename T>
void swift::misc::registerMetaValueType ( )

This registers the value type T with the swift::misc:: meta type system, making it available for use with the extended feature set of swift::misc::CVariant.

The implementation (ab)uses the QMetaType converter function registration mechanism to store a type-erased representation of the set of operations supported by T.

Definition at line 46 of file variant.h.

◆ removeChars()

template<class F>
QString swift::misc::removeChars ( const QString & s,
F predicate )

Return a string with characters removed that match the given predicate.

Definition at line 34 of file stringutils.h.

◆ removeIfIn()

template<typename I, typename J>
auto swift::misc::removeIfIn ( I begin1,
I end1,
J begin2,
J end2 )

Removes those elements in range 1 that appear also in range 2 leaving only those that do not appear in range 2.

Returns an iterator one past the new end of range 1.

Precondition
All the elements of range 2 must be present in the same order in range 1.

Definition at line 25 of file algorithm.h.

◆ removeIfInString()

QString swift::misc::removeIfInString ( const QString & string,
const QString & inString )
inline

Remove if in string.

Definition at line 42 of file stringutils.h.

◆ removeIfNotInString()

QString swift::misc::removeIfNotInString ( const QString & string,
const QString & inString )
inline

Remove if NOT in string.

Definition at line 48 of file stringutils.h.

◆ removeLineBreakAndTab()

QString swift::misc::removeLineBreakAndTab ( const QString & s)
inline

Remove line breaks and tabs.

Definition at line 54 of file stringutils.h.

◆ safeAt()

const QString & swift::misc::safeAt ( const QStringList & stringList,
int index )
inline

Safe "at" function, returns empty string if index does not exists.

Definition at line 165 of file stringutils.h.

◆ setMockCacheRootDirectory()

SWIFT_MISC_EXPORT void swift::misc::setMockCacheRootDirectory ( const QString & path)

Overwrite the default root directory for cache and settings, for testing purposes.

May not be called after any cache or settings objects have been constructed.

◆ singleShot()

template<typename F>
auto swift::misc::singleShot ( int msec,
QObject * target,
F && task )

Starts a single-shot timer which will call a task in the thread of the given object when it times out.

Differs from QTimer::singleShot in that this implementation interacts better with QObject::moveToThread, and returns a QFuture which can be used to detect when the task has finished or obtain its return value.

Definition at line 30 of file threadutils.h.

◆ splitLinesRefs()

SWIFT_MISC_EXPORT QList< QStringView > swift::misc::splitLinesRefs ( const QString & s)

Split a string into multiple lines. Blank lines are skipped.

Warning
The returned refs are only valid during the lifetime of the original string.

◆ splitString()

template<class F>
QStringList swift::misc::splitString ( const QString & s,
F predicate )

Split a string into multiple strings, using a predicate function to identify the split points.

Definition at line 125 of file stringutils.h.

◆ splitStringRefs()

template<class F>
QList< QStringView > swift::misc::splitStringRefs ( const QString & s,
F predicate )

Split a string into multiple strings, using a predicate function to identify the split points.

Warning
The returned refs are only valid during the lifetime of the original string.

Definition at line 94 of file stringutils.h.

◆ startDetachedWithConsoleWindow()

bool swift::misc::startDetachedWithConsoleWindow ( const QString & program,
const QStringList & arguments )
Fixme
Handle Linux and OS X here

Definition at line 62 of file processctrl.cpp.

◆ swap()

template<typename T>
void swift::misc::swap ( Optional< T > & a,
Optional< T > & b )
noexcept

Efficient swap for two Optional objects.

Definition at line 150 of file optional.h.

◆ toHtmTable()

SWIFT_MISC_EXPORT QString swift::misc::toHtmTable ( const QStringList & values,
int columns )

Values as HTML table.

Definition at line 11 of file htmlutils.cpp.

◆ topologicallySortedInsert()

template<typename C, typename T, typename F>
void swift::misc::topologicallySortedInsert ( C & container,
T && value,
F comparator )

Insert an element into a sequential container while preserving the topological ordering of the container.

Parameters
containerA sequential container.
valueThe value to insert.
comparatorA binary function which defines a less-than relation between elements of the container. The ordering it induces must be a partial ordering, which is a more relaxed requirement than the strict weak ordering required by most standard sorting algorithms.
See also
https://en.wikipedia.org/wiki/Topological_sorting
https://en.wikipedia.org/wiki/Partial_ordering

Definition at line 151 of file algorithm.h.

◆ topologicalSort()

template<typename I, typename F>
void swift::misc::topologicalSort ( I begin,
I end,
F comparator )

Topological sorting algorithm.

Parameters
beginBegin iterator of the range to sort.
endEnd iterator of the range to sort.
comparatorA binary function which defines a less-than relation between elements of the range. The ordering it induces must be a partial ordering, which is a more relaxed requirement than the strict weak ordering required by most standard sorting algorithms.
See also
https://en.wikipedia.org/wiki/Topological_sorting
https://en.wikipedia.org/wiki/Partial_ordering

Definition at line 123 of file algorithm.h.

◆ tupleForEachPair()

template<typename T, typename F>
void swift::misc::tupleForEachPair ( T && tuple,
F && visitor )

Invoke a visitor function on each pair of elements of a tuple in order.

Definition at line 181 of file algorithm.h.

Variable Documentation

◆ THasMetaBaseV

template<typename T>
bool swift::misc::THasMetaBaseV = QMetaTypeId<typename TBaseOf<T>::type>::Defined
inlineconstexpr

True if T has a member typedef base_type which is a registered metatype.

Definition at line 38 of file inheritancetraits.h.