Utilities Service

The Utilities service offers miscellaneous operations.

Available Operations

cStringQuote

Utilities.cStringQuote(str: string): string

Takes a string and escapes special characters in a way that the result is suitable for use as a C/C++ string literal. This function is typically used to specify values for cpp.defines.

getHash

Utilities.getHash(key: string): string

Calculates a 16-byte hash of the input and returns it. Rules in modules should use this function to find unique locations for output artifacts in the build directory without duplicating the whole directory structure of the respective input file (to deal with the case of two files with the same name in different subdirectories of the same product).

rfc1034Identifier

Utilities.rfc1034Identifier(str: string): string

Returns an RFC-1034 compliant identifier based on the given string by replacing each character that is not Latin alphanumeric or . with -.

versionCompare

Utilities.versionCompare(version1: string, version2: string): number

Interprets the two arguments as version numbers and returns a number that is smaller than, equal to, or greater than zero if version1 is smaller than, equal to, or greater than version2, respectively.

The version strings consist of up to three numbers separated by dots.

© 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.