retdec
|
Namespaces | |
io | |
Classes | |
class | ByteValueStorage |
class | NonIterableSet |
struct | EnumClassKeyHash |
class | CRC32 |
compute CRC32 hash, based on Intel's Slicing-by-8 algorithm More... | |
class | DynamicBuffer |
The class for dynamic buffered data manipulation taking the endianness of the data in account. More... | |
class | FilterIterator |
An adapter of an iterator range in which some elements of the range are skipped. More... | |
class | NonCopyable |
A mixin to make classes non-copyable. More... | |
class | ScopeExitGuard |
struct | ScopeExitGuardHelper |
Typedefs | |
using | WideCharType = std::uint32_t |
using | WideStringType = std::basic_string< WideCharType > |
Enumerations | |
enum class | Endianness { UNKNOWN , LITTLE , BIG } |
Functions | |
bool | isAligned (std::uint64_t value, std::uint64_t alignment, std::uint64_t &remainder) |
std::uint64_t | alignDown (std::uint64_t value, std::uint64_t alignment) |
std::uint64_t | alignUp (std::uint64_t value, std::uint64_t alignment) |
template<typename T , std::size_t N> | |
constexpr std::size_t | arraySize (T(&)[N]) noexcept |
Returns the number of elements of the given array as a compile-time constant. More... | |
fs::path | getThisBinaryPath () |
fs::path | getThisBinaryDirectoryPath () |
template<typename N > | |
bool | readFile (std::istream &fileStream, std::vector< N > &result, std::size_t start=0, std::size_t desiredSize=0) |
template<typename N > | |
bool | readFile (const std::string &fileName, std::vector< N > &result, std::size_t start=0, std::size_t desiredSize=0) |
template<typename N > | |
bool | writeFile (std::ostream &fileStream, const std::vector< N > &data, std::size_t start=0, std::size_t desiredSize=0) |
template<typename N > | |
bool | writeFile (const std::string &fileName, const std::vector< N > &data, std::size_t start=0, std::size_t desiredSize=0) |
template<typename N > | |
bool | isPowerOfTwo (N number) |
Check if number is power of two. More... | |
template<typename N > | |
bool | isPowerOfTwoOrZero (N number) |
Check if number is power of two or zero. More... | |
unsigned | countBits (unsigned long long n) |
Counts all 1 bits in the given number. More... | |
unsigned | bitSizeOfNumber (unsigned long long v) |
Returns the number of bits needed to encode the given number. More... | |
std::size_t | getTotalSystemMemory () |
Returns the total size of system RAM (in bytes). More... | |
bool | limitSystemMemory (std::size_t limit) |
Limits system memory to the given size (in bytes). More... | |
bool | limitSystemMemoryToHalfOfTotalSystemMemory () |
Limits system memory to half of the total memory. More... | |
template<typename Function > | |
auto | operator+ (ScopeExitGuardHelper, Function &&f) |
bool | hasOnlyDecimalDigits (const std::string &str) |
Returns true if the given string is formed only by decimal digits. More... | |
bool | hasOnlyHexadecimalDigits (const std::string &str) |
Returns true if the given string is formed only by hexadecimal digits. More... | |
bool | hasNonprintableChars (const std::string &str) |
Returns true if the given string contains at least one non-printable character. More... | |
bool | hasNonasciiChars (const std::string &str) |
Returns true if the given string contains at least one non-ASCII character. More... | |
bool | isLowerThanCaseInsensitive (const std::string &str1, const std::string &str2) |
Checks if str1 < str2 (case-insensitively). More... | |
bool | areEqualCaseInsensitive (const std::string &str1, const std::string &str2) |
Checks if str1 == str2 (case-insensitively). More... | |
bool | isShorterPrefixOfCaseInsensitive (const std::string &str1, const std::string &str2) |
Checks if the shorter string of str1 and str2 is a case-insensitive prefix of the longer string. More... | |
bool | contains (const std::string &str, const std::string &sub) |
Checks if str contains sub. More... | |
bool | containsAny (const std::string &str, const std::vector< std::string > &subs) |
Check if at least one string from subs is contained in str. More... | |
bool | containsCaseInsensitive (const std::string &str, const std::string &sub) |
Find out if string contains another string, no matter the case. More... | |
bool | containsAnyOfChars (const std::string &str, const std::string &chars) |
Returns true if str contains at least one character from chars, false otherwise. More... | |
bool | containsAnyOfChars (const std::string &str, std::string::value_type c) |
Returns true if str contains c, false otherwise. More... | |
std::string | toLower (std::string str) |
Converts all characters in str to lower case. More... | |
std::string | toUpper (std::string str) |
Converts all characters in str to upper case. More... | |
std::string | toWide (const std::string &str, std::string::size_type length) |
Converts str to wide string. More... | |
std::string | unicodeToAscii (const std::uint8_t *bytes, std::size_t nBytes) |
Converts unicode bytes to ASCII string. More... | |
std::string | unicodeToAscii (const std::uint8_t *bytes, std::size_t nBytes, std::size_t &nRead) |
Converts unicode bytes to ASCII string. More... | |
std::string | readNullTerminatedAscii (const std::uint8_t *bytes, std::size_t bytesLen, std::size_t offset, std::size_t maxBytes, bool failOnExceed) |
Read up to maxBytes bytes as ASCII string. More... | |
std::string | trim (std::string str, const std::string &toTrim) |
Trims the given string. More... | |
std::vector< std::string > | split (const std::string &str, char sep, bool trimWhitespace) |
Splits the given string by a separator. More... | |
std::string | unifyLineEnds (const std::string &str) |
Unifies line ends in the given string to LF. More... | |
template<typename Container > | |
std::string | joinStrings (const Container &strings, const std::string &separator=", ") |
Joins all the strings in strings into a single string. More... | |
std::string | addSlashes (const std::string &str, const std::string &toBackslash) |
Returns str with backslashes before characters that need to be quoted, specified in toBackslash. More... | |
std::string | replaceCharsWithStrings (const std::string &str, char what, const std::string &withWhat) |
Replaces all occurrences of what with withWhat in str and returns the resulting string. More... | |
template<typename String > | |
bool | startsWith (const std::string &str, const String &withWhat) |
Returns true if str starts with the prefix withWhat, false otherwise. More... | |
bool | endsWith (const std::string &str, const std::string &withWhat) |
Retruns true if str ends with the suffix withWhat, false otherwise. More... | |
bool | endsWith (const std::string &str, char withWhat) |
Retruns true if str ends with the suffix withWhat, false otherwise. More... | |
bool | endsWith (const std::string &str, const std::set< std::string > &withWhat) |
bool | hasSubstringOnPosition (const std::string &str, const std::string &withWhat, std::string::size_type position) |
Returns true if str has substring withWhat on index position. More... | |
bool | hasSubstringInArea (const std::string &str, const std::string &withWhat, std::string::size_type start, std::string::size_type stop) |
Returns true if str has substring withWhat in area bordered by offsets start and stop. More... | |
bool | isComposedOnlyOfChars (const std::string &str, const std::string &chars) |
Returns true if str is composed solely of chars in chars, false otherwise. More... | |
bool | isComposedOnlyOfChars (const std::string &str, std::string::value_type c) |
Returns true if str is composed solely of char c, false otherwise. More... | |
bool | isComposedOnlyOfStrings (const std::string &str, const std::string &ss) |
Returns true if str is composed solely of strings ss, false otherwise. More... | |
std::string | stripDirs (const std::string &path) |
Strips all directories from the given path. More... | |
std::string | replaceAll (const std::string &str, const std::string &from, const std::string &to) |
Replaces all occurrences of from in str with to and returns the string obtained in this way. More... | |
std::string | replaceNonprintableChars (const std::string &str) |
Replaces non-printable characters in str with their hexadecimal values. More... | |
std::string | replaceNonasciiChars (const std::string &str) |
Replaces non-ASCII characters in str with their hexadecimal values. More... | |
std::string | replaceNonalnumCharsWith (const std::string &str, std::string::value_type c) |
Replaces non-alphanumeric characters in str with c. More... | |
std::string | removeWhitespace (std::string s) |
Removes all whitespace from the given string. More... | |
std::pair< std::size_t, std::size_t > | getLineAndColumnFromPosition (const std::string &json, std::size_t position) |
Transform position in json into line and column location. More... | |
bool | isNumber (const std::string &str) |
Checks if the string is a number. More... | |
bool | isIdentifier (const std::string &str) |
Checks if the string is a valid C language identifier. More... | |
bool | isPrintable (const std::string &str) |
Checks if the string is printable. More... | |
std::string | removeLeadingCharacter (const std::string &s, char leading, std::size_t n) |
Removes n leading characters from the given string s and returns the result. More... | |
bool | isContolCharacter (char c) |
bool | isNiceCharacter (unsigned char c) |
bool | isNiceString (const std::string &str, double minRatio) |
Does the provided string seem nice, i.e ratio of printable characters and escape sequences in the string is at least minRatio . More... | |
bool | isNiceAsciiWideCharacter (unsigned long long c) |
bool | isNiceAsciiWideString (const std::vector< unsigned long long > &str, double minRatio) |
Does the provided wide string consist only from ASCII characters and is nice? Nice string have ration of printable characters and escape sequences in the string is at least minRatio . Empty string is never nice. More... | |
std::string | getIndentation (std::size_t count, char c) |
Returns an indentation string containing the specified number of characters. More... | |
void | appendHex (std::string &n, const long long a) |
Appends hexadecimal address to string (typically object name). More... | |
void | appendDec (std::string &n, const long long a) |
Appends hexadecimal address to string (typically object name). More... | |
std::string | appendHexRet (const std::string &n, const long long a) |
Appends hexadecimal address to string and return new string. More... | |
std::string | appendDecRet (const std::string &n, const long long a) |
Appends hexadecimal address to string and return new string. More... | |
void | removeSuffix (std::string &n, const std::string &suffix) |
Finds the last occurrence of the specified suffix and removes everything from its start to the end. More... | |
std::string | removeSuffixRet (const std::string &n, const std::string &suffix) |
Finds the last occurrence of the specified suffix and removes everything from its start to the end. More... | |
std::string | normalizeName (const std::string &name) |
Replaces all special symbols by their normalized equivalent. More... | |
std::string | normalizeNamePrefix (const std::string &name) |
bool | findFirstInEmbeddedLists (std::size_t &pos, const std::string &str, char c, const std::vector< std::pair< char, char >> &pairs) |
Finds the first occurrence of c character in string str that is outside of embedded lists delimited by pairs . More... | |
std::string | removeConsecutiveSpaces (const std::string &str) |
std::string | asEscapedCString (const WideStringType &value, std::size_t charSize) |
Returns the constant's value as an escaped C string. More... | |
std::string | removeComments (const std::string &str, char commentChar) |
std::string | extractVersion (const std::string &input) |
bool | isLittleEndian () |
Finds out if the runtime architecture is little endian. More... | |
bool | systemHasLongDouble () |
Finds out if the runtime system supports long double (at least 10 bytes long). More... | |
std::tm * | getCurrentTimestamp () |
Returns the current timestamp. More... | |
std::string | getCurrentDate () |
Returns the current date in the form YYYY-MM-DD . More... | |
std::string | getCurrentTime () |
Returns the current time in the form HH:MM:SS . More... | |
std::string | getCurrentYear () |
Returns the current year in the form YYYY . More... | |
std::string | timestampToDate (std::tm *tm) |
Returns date in human readable form. More... | |
std::string | timestampToDate (std::time_t timestamp) |
Returns date in human readable form. More... | |
double | getElapsedTime () |
Returns how much time has elapsed since the program was started (in seconds). More... | |
General Operations with Containers | |
template<class Container , typename Item > | |
bool | hasItem (const Container &container, const Item &item) |
Returns true if container contains item, false otherwise. More... | |
template<typename Item > | |
bool | hasItem (const std::list< Item > &container, const Item &item) |
A "specialization" of hasItem<>() for std::list. More... | |
template<typename Item > | |
bool | hasItem (const std::vector< Item > &container, const Item &item) |
A "specialization" of hasItem<>() for std::vector. More... | |
template<typename Item > | |
const Item & | getNthItem (const std::vector< Item > &container, std::size_t n) |
Returns the n-th item in container. More... | |
template<typename Item > | |
const Item & | getNthItem (const std::list< Item > &container, std::size_t n) |
Returns the n-th item in container. More... | |
template<class Container , typename Item > | |
Item | getValueOrDefault (const Container &container, const Item &item, Item defaultValue=Item()) |
Returns the found value if container contains item, defaultValue otherwise. More... | |
template<typename Item > | |
Item | getValueOrDefault (const std::list< Item > &container, const Item &item, Item defaultValue=Item()) |
A "specialization" of getValueOrDefault<>() for std::list. More... | |
template<typename Item > | |
Item | getValueOrDefault (const std::vector< Item > &container, const Item &item, Item defaultValue=Item()) |
A "specialization" of getValueOrDefault<>() for std::vector. More... | |
template<typename Item > | |
void | removeItem (std::vector< Item > &v, const Item &item) |
Removes all occurrences of the given item from the given vector. More... | |
template<class Container > | |
void | clear (Container &container) |
Clears the given container. More... | |
template<typename Item > | |
void | clear (std::queue< Item > &q) |
A "specialization" of clear<>() for std::queue. More... | |
template<typename Item > | |
void | clear (std::stack< Item > &s) |
A "specialization" of clear<>() for std::stack. More... | |
template<typename OutputContainer , typename InputContainer , typename Predicate > | |
OutputContainer | filterTo (const InputContainer &input, const Predicate &predicate) |
Returns OutputContainer with items from input that satistfy predicate. More... | |
template<typename Container , typename Predicate > | |
Container | filter (const Container &input, const Predicate &predicate) |
Returns Container with items from input that satistfy predicate. More... | |
Operations with Sets | |
template<typename T > | |
void | addToSet (const std::set< T > &from, std::set< T > &to) |
Adds all values from from into to. More... | |
template<typename T > | |
std::set< T > | setUnion (const std::set< T > &s1, const std::set< T > &s2) |
Returns the set union s1 \cup s2 . More... | |
template<typename T > | |
std::set< T > | setIntersection (const std::set< T > &s1, const std::set< T > &s2) |
Returns the set intersection s1 \cap s2 . More... | |
template<typename T > | |
std::set< T > | setDifference (const std::set< T > &s1, const std::set< T > &s2) |
Returns the set difference s1 \setminus s2 . More... | |
template<typename T > | |
void | removeFromSet (std::set< T > &from, const std::set< T > &toRemove) |
Removes all values that are in toRemove from from. More... | |
template<typename T > | |
bool | areDisjoint (const std::set< T > &s1, const std::set< T > &s2) |
Returns true if s1 is disjoint with s2. More... | |
template<typename T > | |
bool | shareSomeItem (const std::set< T > &s1, const std::set< T > &s2) |
Returns true if s1 and s2 have at least one item in common. More... | |
Operations with Maps | |
template<typename Map > | |
std::set< typename Map::key_type > | getKeysFromMap (const Map &m) |
Returns all keys in the given map m. More... | |
template<typename Map > | |
std::set< typename Map::mapped_type > | getValuesFromMap (const Map &m) |
Returns all values in the given map m. More... | |
template<typename Map > | |
bool | mapHasKey (const Map &m, const typename Map::key_type &k) |
Returns true if the given map m has a key k, false otherwise. More... | |
template<typename Map > | |
bool | mapHasValue (const Map &m, const typename Map::mapped_type &v) |
Returns true if the given map m has a value v, false otherwise. More... | |
template<typename Map > | |
Map::mapped_type | mapGetValueOrDefault (const Map &m, const typename Map::key_type &key, typename Map::mapped_type defaultValue=typename Map::mapped_type()) |
Returns the value associated to the given key in m, or defaultValue if there is no key in m. More... | |
template<typename Map > | |
Map::mapped_type | mapGetMaxValue (const Map &m) |
Returns the maximum value from m. More... | |
template<typename Map > | |
Map::mapped_type & | addToMap (const typename Map::key_type &key, const typename Map::mapped_type &value, Map &m) |
Adds the pair <key, value> to map m. More... | |
template<typename K , typename V > | |
std::map< V, K > | getMapWithSwappedKeysAndValues (const std::map< K, V > &m) |
Returns a new map that has swapped keys and values. More... | |
Conversions | |
char * | byteToHexString (uint8_t b, bool uppercase=true) |
template<typename N > | |
void | bytesToHexString (const N *data, std::size_t dataSize, std::string &result, std::size_t offset=0, std::size_t size=0, bool uppercase=true, bool spacing=false) |
template<typename N > | |
void | bytesToHexString (const std::vector< N > &bytes, std::string &result, std::size_t offset=0, std::size_t size=0, bool uppercase=true, bool spacing=false) |
template<typename I > | |
std::string | intToHexString (I w, bool addBase=false, unsigned fillToN=0) |
Converts the given integer into its hexadecimal representation. More... | |
std::vector< uint8_t > | hexStringToBytes (const std::string &hexIn) |
template<typename N > | |
bool | strToNum (const std::string &str, N &number, std::ios_base &(*format)(std::ios_base &)=std::dec) |
Converts the given string into a number. More... | |
template<typename N > | |
std::string | bytesToBits (const N *data, std::size_t dataSize) |
Converts the given array of numbers into a bits. More... | |
template<typename N > | |
std::string | bytesToBits (const std::vector< N > &bytes) |
Converts the given vector of numbers into a bits. More... | |
template<typename N > | |
void | bytesToString (const N *data, std::size_t dataSize, std::string &result, std::size_t offset=0, std::size_t size=0) |
template<typename N > | |
void | bytesToString (const std::vector< N > &bytes, std::string &result, std::size_t offset=0, std::size_t size=0) |
void | double10ToDouble8 (std::vector< unsigned char > &dest, const std::vector< unsigned char > &src) |
Convert 80-bit (10-byte) long double binary data (byte array) into 64-bit (8-byte) double binary data. More... | |
unsigned short | byteSwap16 (unsigned short val) |
Swap bytes for Intel x86 16-bit little-endian immediate. More... | |
unsigned int | byteSwap32 (unsigned int val) |
Swap bytes for Intel x86 32-bit little-endian immediate. More... | |
std::string | byteSwap16 (const std::string &val) |
Swap bytes for Intel x86 16-bit little-endian immediate. More... | |
std::string | byteSwap32 (const std::string &val) |
Swap bytes for Intel x86 32-bit little-endian immediate. More... | |
Equality of Values | |
template<typename T > | |
bool | areEqual (const T &x, const T &y) |
Returns true if x is equal to y, false otherwise. More... | |
template<> | |
bool | areEqual< float > (const float &x, const float &y) |
template<> | |
bool | areEqual< double > (const double &x, const double &y) |
template<> | |
bool | areEqual< long double > (const long double &x, const long double &y) |
using retdec::utils::WideCharType = typedef std::uint32_t |
using retdec::utils::WideStringType = typedef std::basic_string<WideCharType> |
|
strong |
std::string retdec::utils::addSlashes | ( | const std::string & | str, |
const std::string & | toBackslash | ||
) |
Returns str with backslashes before characters that need to be quoted, specified in toBackslash.
[in] | str | String to be backslashed. |
[in] | toBackslash | List of characters to be backslashed in str. |
By default, toBackslash include a single quote ('), double quote ("), backslash () and NUL (the zero byte).
Map::mapped_type& retdec::utils::addToMap | ( | const typename Map::key_type & | key, |
const typename Map::mapped_type & | value, | ||
Map & | m | ||
) |
Adds the pair <key, value>
to map m.
Map | Type of the map (std::map or std::unordered_map ). |
If the key already exists in the map, its value is overwritten.
The behavior of this function is similar to m[key] = value
, but does not require values in the map to have the default constructor. To use operator
[] in a map, values in the map must have a default constructor. If this is not the case, you cannot use operator
[].
void retdec::utils::addToSet | ( | const std::set< T > & | from, |
std::set< T > & | to | ||
) |
Adds all values from from into to.
T | Type of elements in the sets. |
std::uint64_t retdec::utils::alignDown | ( | std::uint64_t | value, |
std::uint64_t | alignment | ||
) |
Aligns given value down by specified alignment. Alignment must be power of 2.
value | Value to align. |
alignment | Alignment to use. |
std::uint64_t retdec::utils::alignUp | ( | std::uint64_t | value, |
std::uint64_t | alignment | ||
) |
Aligns given value up by specified alignment. Alignment must be power of 2.
value | Value to align. |
alignment | Alignment to use. |
void retdec::utils::appendDec | ( | std::string & | n, |
const long long | a | ||
) |
Appends hexadecimal address to string (typically object name).
n | Reference to string. |
a | Address to append. |
std::string retdec::utils::appendDecRet | ( | const std::string & | n, |
const long long | a | ||
) |
Appends hexadecimal address to string and return new string.
n | Original to string. |
a | Address to append. |
void retdec::utils::appendHex | ( | std::string & | n, |
const long long | a | ||
) |
Appends hexadecimal address to string (typically object name).
n | Reference to string. |
a | Address to append. |
std::string retdec::utils::appendHexRet | ( | const std::string & | n, |
const long long | a | ||
) |
Appends hexadecimal address to string and return new string.
n | Original to string. |
a | Address to append. |
bool retdec::utils::areDisjoint | ( | const std::set< T > & | s1, |
const std::set< T > & | s2 | ||
) |
Returns true
if s1 is disjoint with s2.
T | Type of elements in the sets. |
|
inline |
Returns true
if x is equal to y, false
otherwise.
T | Type of x and y. |
By default, it returns x == y
.
|
inline |
|
inline |
|
inline |
bool retdec::utils::areEqualCaseInsensitive | ( | const std::string & | str1, |
const std::string & | str2 | ||
) |
Checks if str1 == str2
(case-insensitively).
|
constexprnoexcept |
Returns the number of elements of the given array as a compile-time constant.
Usage example:
std::string retdec::utils::asEscapedCString | ( | const WideStringType & | value, |
std::size_t | charSize | ||
) |
Returns the constant's value as an escaped C string.
unsigned retdec::utils::bitSizeOfNumber | ( | unsigned long long | v | ) |
Returns the number of bits needed to encode the given number.
std::string retdec::utils::bytesToBits | ( | const N * | data, |
std::size_t | dataSize | ||
) |
Converts the given array of numbers into a bits.
[in] | data | Array of numbers. |
[in] | dataSize | Size of array. |
std::string retdec::utils::bytesToBits | ( | const std::vector< N > & | bytes | ) |
Converts the given vector of numbers into a bits.
[in] | bytes | Vector to be converted into a bits. |
void retdec::utils::bytesToHexString | ( | const N * | data, |
std::size_t | dataSize, | ||
std::string & | result, | ||
std::size_t | offset = 0 , |
||
std::size_t | size = 0 , |
||
bool | uppercase = true , |
||
bool | spacing = false |
||
) |
Converts the given array of numbers into a hexadecimal string representation
data | Array to be converted into a hexadecimal string |
dataSize | Size of array |
result | Into this parameter the result is stored |
offset | First byte from data which will be converted |
size | Number of bytes from data for conversion (0 means all bytes from offset) |
uppercase | true if hex letters (A-F) should be uppercase |
spacing | insert ' ' between every byte |
void retdec::utils::bytesToHexString | ( | const std::vector< N > & | bytes, |
std::string & | result, | ||
std::size_t | offset = 0 , |
||
std::size_t | size = 0 , |
||
bool | uppercase = true , |
||
bool | spacing = false |
||
) |
Converts the given vector of numbers into a hexadecimal string representation
bytes | Vector to be converted into a hexadecimal string |
result | Into this parameter the result is stored |
offset | First byte from bytes which will be converted |
size | Number of bytes from bytes for conversion (0 means all bytes from offset) |
uppercase | true if hex letters (A-F) should be uppercase |
spacing | insert ' ' between every byte |
void retdec::utils::bytesToString | ( | const N * | data, |
std::size_t | dataSize, | ||
std::string & | result, | ||
std::size_t | offset = 0 , |
||
std::size_t | size = 0 |
||
) |
Converts the given array of numbers into a string
data | Array to be converted into a string |
dataSize | Size of array |
result | Into this parameter the result is stored |
offset | First byte from data which will be converted to string |
size | Number of bytes from data for conversion (0 means all bytes from offset) |
void retdec::utils::bytesToString | ( | const std::vector< N > & | bytes, |
std::string & | result, | ||
std::size_t | offset = 0 , |
||
std::size_t | size = 0 |
||
) |
Converts the given vector of numbers into a string
bytes | Vector to be converted into a string |
result | Into this parameter the result is stored |
offset | First byte from bytes which will be converted to string |
size | Number of bytes from bytes for conversion (0 means all bytes from offset) |
std::string retdec::utils::byteSwap16 | ( | const std::string & | val | ) |
Swap bytes for Intel x86 16-bit little-endian immediate.
val | Original value. |
unsigned short retdec::utils::byteSwap16 | ( | unsigned short | val | ) |
Swap bytes for Intel x86 16-bit little-endian immediate.
val | Original value. |
std::string retdec::utils::byteSwap32 | ( | const std::string & | val | ) |
Swap bytes for Intel x86 32-bit little-endian immediate.
val | Original value. |
unsigned int retdec::utils::byteSwap32 | ( | unsigned int | val | ) |
Swap bytes for Intel x86 32-bit little-endian immediate.
val | Original value. |
char * retdec::utils::byteToHexString | ( | uint8_t | b, |
bool | uppercase | ||
) |
void retdec::utils::clear | ( | Container & | container | ) |
Clears the given container.
Container | Type of the container. |
void retdec::utils::clear | ( | std::queue< Item > & | q | ) |
A "specialization" of clear<>() for std::queue.
void retdec::utils::clear | ( | std::stack< Item > & | s | ) |
A "specialization" of clear<>() for std::stack.
bool retdec::utils::contains | ( | const std::string & | str, |
const std::string & | sub | ||
) |
Checks if str contains sub.
bool retdec::utils::containsAny | ( | const std::string & | str, |
const std::vector< std::string > & | subs | ||
) |
Check if at least one string from subs is contained in str.
bool retdec::utils::containsAnyOfChars | ( | const std::string & | str, |
const std::string & | chars | ||
) |
Returns true
if str contains at least one character from chars, false
otherwise.
If chars is the empty string, it returns false
.
bool retdec::utils::containsAnyOfChars | ( | const std::string & | str, |
std::string::value_type | c | ||
) |
Returns true
if str contains c, false
otherwise.
bool retdec::utils::containsCaseInsensitive | ( | const std::string & | str, |
const std::string & | sub | ||
) |
Find out if string contains another string, no matter the case.
str | String to search in. |
sub | String to search for. |
true
if string contains another string, false
otherwise. unsigned retdec::utils::countBits | ( | unsigned long long | n | ) |
Counts all 1 bits in the given number.
void retdec::utils::double10ToDouble8 | ( | std::vector< unsigned char > & | dest, |
const std::vector< unsigned char > & | src | ||
) |
Convert 80-bit (10-byte) long double
binary data (byte array) into 64-bit (8-byte) double
binary data.
[out] | dest | 64-bit double to create. |
[in] | src | 80-bit long double to convert. |
bool retdec::utils::endsWith | ( | const std::string & | str, |
char | withWhat | ||
) |
Retruns true
if str ends with the suffix withWhat, false
otherwise.
bool retdec::utils::endsWith | ( | const std::string & | str, |
const std::set< std::string > & | withWhat | ||
) |
true
if str ends with any of the suffixes in withWhat, false
otherwise bool retdec::utils::endsWith | ( | const std::string & | str, |
const std::string & | withWhat | ||
) |
Retruns true
if str ends with the suffix withWhat, false
otherwise.
std::string retdec::utils::extractVersion | ( | const std::string & | input | ) |
Search for version stored in input string
input | Input string |
A version is considered to be a substring which consisting of numbers (and dots). If input string contains more versions, result contains only the first one.
Container retdec::utils::filter | ( | const Container & | input, |
const Predicate & | predicate | ||
) |
Returns Container
with items from input that satistfy predicate.
It is a shortcut for filterTo<Container>(input, predicate)
.
Usage example:
The type of result
is Container
, i.e. std::vector<int>
.
OutputContainer retdec::utils::filterTo | ( | const InputContainer & | input, |
const Predicate & | predicate | ||
) |
Returns OutputContainer
with items from input that satistfy predicate.
This function is an implementation of the standard functional filter()
function.
Usage example:
The type of result
is OutputContainer
, i.e. std::set<int>
.
bool retdec::utils::findFirstInEmbeddedLists | ( | std::size_t & | pos, |
const std::string & | str, | ||
char | c, | ||
const std::vector< std::pair< char, char >> & | pairs | ||
) |
Finds the first occurrence of c
character in string str
that is outside of embedded lists delimited by pairs
.
[out] | pos | Character position of std::string::npos if character not found. Position is left unchanged, if true is returned. |
str | String to find occerrences in. | |
c | Character to find. | |
pairs | Vector of delimiter pairs: <delim_start ,delim_end>. |
False
if substring before the first found occurrence is ok (delimiter pairs match each other), true
otherwise.The check is performed only before the occurrence is found, after that, string may not be ok. Only delimiter numbers are checked, not their correct positions. For example, this is malformed string because delimiters ("{}"
) do not match before character ','
we search for: "{abc{},def"
. However, this is currently ok (search for ','
, delimiters "{}()"
): "{a(b}c),def"
.
std::string retdec::utils::getCurrentDate | ( | ) |
Returns the current date in the form YYYY-MM-DD
.
std::string retdec::utils::getCurrentTime | ( | ) |
Returns the current time in the form HH:MM:SS
.
std::tm * retdec::utils::getCurrentTimestamp | ( | ) |
Returns the current timestamp.
std::string retdec::utils::getCurrentYear | ( | ) |
Returns the current year in the form YYYY
.
double retdec::utils::getElapsedTime | ( | ) |
Returns how much time has elapsed since the program was started (in seconds).
std::string retdec::utils::getIndentation | ( | std::size_t | count, |
char | c = '\t' |
||
) |
Returns an indentation string containing the specified number of characters.
std::set<typename Map::key_type> retdec::utils::getKeysFromMap | ( | const Map & | m | ) |
Returns all keys in the given map m.
Map | Type of the map (std::map or std::unordered_map ). |
std::pair< std::size_t, std::size_t > retdec::utils::getLineAndColumnFromPosition | ( | const std::string & | json, |
std::size_t | position | ||
) |
Transform position in json
into line and column location.
json | JSON string. |
position | Byte distance from start of JSON string. |
(line, column)
. std::map<V, K> retdec::utils::getMapWithSwappedKeysAndValues | ( | const std::map< K, V > & | m | ) |
Returns a new map that has swapped keys and values.
K | Type of objects serving as keys. |
V | Type of objects serving as values. |
For example, if you have std::map<int, std::string>
, this function returns std::map<std::string, int>
.
You have to ensure that all values in m
are distinct; otherwise, the returned map may have less elements than m
.
const Item& retdec::utils::getNthItem | ( | const std::list< Item > & | container, |
std::size_t | n | ||
) |
Returns the n-th item in container.
Item | Type of the items that container holds. |
1 <= n <= container.size()
const Item& retdec::utils::getNthItem | ( | const std::vector< Item > & | container, |
std::size_t | n | ||
) |
Returns the n-th item in container.
Item | Type of the items that container holds. |
1 <= n <= container.size()
fs::path retdec::utils::getThisBinaryDirectoryPath | ( | ) |
Get absolute path to directory of currently running binary.
fs::path retdec::utils::getThisBinaryPath | ( | ) |
Get absolute path of currently running binary.
std::size_t retdec::utils::getTotalSystemMemory | ( | ) |
Returns the total size of system RAM (in bytes).
When the size cannot be obtained, it returns 0
.
Item retdec::utils::getValueOrDefault | ( | const Container & | container, |
const Item & | item, | ||
Item | defaultValue = Item() |
||
) |
Returns the found value if container contains item, defaultValue otherwise.
Container | Type of the container. |
Item | Type of the items that container holds. |
If Container is a map, the searched and returned values are pairs. To get a value corresponding to a given key from a map, use mapGetValueOrDefault<>().
Item retdec::utils::getValueOrDefault | ( | const std::list< Item > & | container, |
const Item & | item, | ||
Item | defaultValue = Item() |
||
) |
A "specialization" of getValueOrDefault<>() for std::list.
Item retdec::utils::getValueOrDefault | ( | const std::vector< Item > & | container, |
const Item & | item, | ||
Item | defaultValue = Item() |
||
) |
A "specialization" of getValueOrDefault<>() for std::vector.
std::set<typename Map::mapped_type> retdec::utils::getValuesFromMap | ( | const Map & | m | ) |
Returns all values in the given map m.
Map | Type of the map (std::map or std::unordered_map ). |
bool retdec::utils::hasItem | ( | const Container & | container, |
const Item & | item | ||
) |
Returns true
if container contains item, false
otherwise.
Container | Type of the container. |
Item | Type of the items that container holds. |
If Container is a map, Item has to be a key. To check whether a map contains a value, use mapHasValue<>().
bool retdec::utils::hasItem | ( | const std::list< Item > & | container, |
const Item & | item | ||
) |
A "specialization" of hasItem<>() for std::list.
bool retdec::utils::hasItem | ( | const std::vector< Item > & | container, |
const Item & | item | ||
) |
A "specialization" of hasItem<>() for std::vector.
bool retdec::utils::hasNonasciiChars | ( | const std::string & | str | ) |
Returns true
if the given string contains at least one non-ASCII character.
bool retdec::utils::hasNonprintableChars | ( | const std::string & | str | ) |
Returns true
if the given string contains at least one non-printable character.
bool retdec::utils::hasOnlyDecimalDigits | ( | const std::string & | str | ) |
Returns true
if the given string is formed only by decimal digits.
The empty string is considered to be composed only by digits.
bool retdec::utils::hasOnlyHexadecimalDigits | ( | const std::string & | str | ) |
Returns true
if the given string is formed only by hexadecimal digits.
The empty string is considered to be composed only by hexadecimal digits.
bool retdec::utils::hasSubstringInArea | ( | const std::string & | str, |
const std::string & | withWhat, | ||
std::string::size_type | start, | ||
std::string::size_type | stop | ||
) |
Returns true
if str has substring withWhat in area bordered by offsets start and stop.
bool retdec::utils::hasSubstringOnPosition | ( | const std::string & | str, |
const std::string & | withWhat, | ||
std::string::size_type | position | ||
) |
Returns true
if str has substring withWhat on index position.
std::vector< uint8_t > retdec::utils::hexStringToBytes | ( | const std::string & | hexIn | ) |
Convert hexadecimal string hexIn
string into bytes. There might be whitespaces in the string, e.g. "0b 84 d1 a0 80 60 40" is the same as "0b84d1a0806040".
std::string retdec::utils::intToHexString | ( | I | w, |
bool | addBase = false , |
||
unsigned | fillToN = 0 |
||
) |
Converts the given integer into its hexadecimal representation.
[in] | w | Number to be converted. |
[in] | addBase | Prepends "0x" before the result. |
[in] | fillToN | If needed, prepends "0" before the result to get at least fillToN characters long string. |
All letters in the result are lowercase.
bool retdec::utils::isAligned | ( | std::uint64_t | value, |
std::uint64_t | alignment, | ||
std::uint64_t & | remainder | ||
) |
Checks whether given value is aligned based on alignment value. Alignment must be power of 2.
value | Value to be checked. |
alignment | Alignment to check. Must be power of 2. |
remainder | Output value that is non-zero if value is not aligned and zero if it is aligned. It contains value modulo alignment . Contains undefined value if alignment is not power of 2. |
bool retdec::utils::isComposedOnlyOfChars | ( | const std::string & | str, |
const std::string & | chars | ||
) |
Returns true
if str is composed solely of chars in chars, false
otherwise.
If chars is the empty string, it returns false
.
bool retdec::utils::isComposedOnlyOfChars | ( | const std::string & | str, |
std::string::value_type | c | ||
) |
Returns true
if str is composed solely of char c, false
otherwise.
bool retdec::utils::isComposedOnlyOfStrings | ( | const std::string & | str, |
const std::string & | ss | ||
) |
Returns true
if str is composed solely of strings ss, false
otherwise.
Examples:
bool retdec::utils::isContolCharacter | ( | char | c | ) |
True
if character c is a control character, false
otherwise. bool retdec::utils::isIdentifier | ( | const std::string & | str | ) |
Checks if the string is a valid C language identifier.
Empty string is not valid identifier.
bool retdec::utils::isLittleEndian | ( | ) |
Finds out if the runtime architecture is little endian.
bool retdec::utils::isLowerThanCaseInsensitive | ( | const std::string & | str1, |
const std::string & | str2 | ||
) |
Checks if str1 < str2
(case-insensitively).
This function doesn't consider non-ASCII character sets.
bool retdec::utils::isNiceAsciiWideCharacter | ( | unsigned long long | c | ) |
True
if character c is a nice ASCII wide character. False
otherwise. bool retdec::utils::isNiceAsciiWideString | ( | const std::vector< unsigned long long > & | str, |
double | minRatio | ||
) |
Does the provided wide string consist only from ASCII characters and is nice? Nice string have ration of printable characters and escape sequences in the string is at least minRatio
. Empty string is never nice.
str | Wide string to check. |
minRatio | Minimum ratio of printable characters. |
True
if the string seems nice, false
otherwise. bool retdec::utils::isNiceCharacter | ( | unsigned char | c | ) |
True
if character c is a nice character (printable or control). False
otherwise. bool retdec::utils::isNiceString | ( | const std::string & | str, |
double | minRatio | ||
) |
Does the provided string seem nice, i.e ratio of printable characters and escape sequences in the string is at least minRatio
.
str | String to check. |
minRatio | Minimum ratio of printable characters. |
True
if the string seems nice, false
otherwise.Empty string is never nice.
bool retdec::utils::isNumber | ( | const std::string & | str | ) |
Checks if the string is a number.
bool retdec::utils::isPowerOfTwo | ( | N | number | ) |
Check if number is power of two.
[in] | number | Value which will be checked. |
N | Type of number. |
bool retdec::utils::isPowerOfTwoOrZero | ( | N | number | ) |
Check if number is power of two or zero.
[in] | number | Value which will be checked. |
N | Type of number. |
bool retdec::utils::isPrintable | ( | const std::string & | str | ) |
Checks if the string is printable.
Empty string is considered printable. This is different from isNiceString because this function considers only printable characters, not control ones.
str | input string |
true
if input string is printable, false
otherwise. bool retdec::utils::isShorterPrefixOfCaseInsensitive | ( | const std::string & | str1, |
const std::string & | str2 | ||
) |
Checks if the shorter string of str1 and str2 is a case-insensitive prefix of the longer string.
std::string retdec::utils::joinStrings | ( | const Container & | strings, |
const std::string & | separator = ", " |
||
) |
Joins all the strings in strings into a single string.
[in] | strings | Strings to be joined. |
[in] | separator | Separator to separate individual strings. |
Container | Type of strings. |
If Container is an unordered container, the order depends on the implementation of the container.
bool retdec::utils::limitSystemMemory | ( | std::size_t | limit | ) |
Limits system memory to the given size (in bytes).
true
if the limiting succeeded, false
otherwise.When limit is 0
, it immediately returns false
.
This function is not reentrant, i.e. it is not safe to call it simultaneously from multiple threads.
bool retdec::utils::limitSystemMemoryToHalfOfTotalSystemMemory | ( | ) |
Limits system memory to half of the total memory.
Map::mapped_type retdec::utils::mapGetMaxValue | ( | const Map & | m | ) |
Returns the maximum value from m.
If m is empty, this function returns Map::mapped_type()
(default-constructed value).
Map::mapped_type retdec::utils::mapGetValueOrDefault | ( | const Map & | m, |
const typename Map::key_type & | key, | ||
typename Map::mapped_type | defaultValue = typename Map::mapped_type() |
||
) |
Returns the value associated to the given key in m, or defaultValue if there is no key in m.
Map | Type of the map (std::map or std::unordered_map ). |
bool retdec::utils::mapHasKey | ( | const Map & | m, |
const typename Map::key_type & | k | ||
) |
Returns true
if the given map m has a key k, false
otherwise.
Map | Type of the map (std::map or std::unordered_map ). |
bool retdec::utils::mapHasValue | ( | const Map & | m, |
const typename Map::mapped_type & | v | ||
) |
Returns true
if the given map m has a value v, false
otherwise.
Map | Type of the map (std::map or std::unordered_map ). |
std::string retdec::utils::normalizeName | ( | const std::string & | name | ) |
Replaces all special symbols by their normalized equivalent.
[in] | name | Input string. |
std::string retdec::utils::normalizeNamePrefix | ( | const std::string & | name | ) |
TODO: Is this and normalizeName()
really needed/wanted? If so, can they be merged into one. If not remove them.
auto retdec::utils::operator+ | ( | ScopeExitGuardHelper | , |
Function && | f | ||
) |
bool retdec::utils::readFile | ( | const std::string & | fileName, |
std::vector< N > & | result, | ||
std::size_t | start = 0 , |
||
std::size_t | desiredSize = 0 |
||
) |
Read bytes from file
fileName | Name of the file |
result | Into this parameter the resulting bytes are stored |
start | Start offset of read |
desiredSize | Number of bytes for read. If this parameter is set to zero, function will read all bytes from start until end of file. |
true
if operation went OK, otherwise false
If function returns false
, bytes is set to empty vector
bool retdec::utils::readFile | ( | std::istream & | fileStream, |
std::vector< N > & | result, | ||
std::size_t | start = 0 , |
||
std::size_t | desiredSize = 0 |
||
) |
Read bytes from file stream
fileStream | Representation of input file |
result | Into this parameter the resulting bytes are stored |
start | Start offset of read |
desiredSize | Number of bytes for read. If this parameter is set to zero, function will read all bytes from start until end of file. |
true
if operation went OK, otherwise false
If function returns false
, bytes is set to empty vector
std::string retdec::utils::readNullTerminatedAscii | ( | const std::uint8_t * | bytes, |
std::size_t | bytesLen, | ||
std::size_t | offset, | ||
std::size_t | maxBytes, | ||
bool | failOnExceed | ||
) |
Read up to maxBytes bytes as ASCII string.
[in] | bytes | Bytes to read from. |
[in] | bytesLen | Length of bytes |
[in] | offset | Offset in bytes. |
[in] | maxBytes | Maximum of bytes to read. Zero indicates as much as possible. |
[in] | failOnExceed | If string isn't null terminated until maxBytes, an empty string is returned |
std::string retdec::utils::removeComments | ( | const std::string & | str, |
char | commentChar | ||
) |
Remove comments from string. Comment must start with a single commentChar
character and end on new line (i.e. '
') character. For example LLVM comment: a = add i32 0, 0 ; this part will be removed
str | String from which to remove comments. |
commentChar | Character used to start the comment (e.g. ';'). |
std::string retdec::utils::removeConsecutiveSpaces | ( | const std::string & | str | ) |
void retdec::utils::removeFromSet | ( | std::set< T > & | from, |
const std::set< T > & | toRemove | ||
) |
Removes all values that are in toRemove from from.
T | Type of elements in the sets. |
void retdec::utils::removeItem | ( | std::vector< Item > & | v, |
const Item & | item | ||
) |
Removes all occurrences of the given item from the given vector.
Item | Type of the items that the vector holds. |
std::string retdec::utils::removeLeadingCharacter | ( | const std::string & | s, |
char | leading, | ||
std::size_t | n | ||
) |
Removes n
leading
characters from the given string s
and returns the result.
s | String from which leading characters are tp be removed. |
leading | Leading character to remove. |
n | Max number of characters to remove. If not set, remove as much as possible. |
void retdec::utils::removeSuffix | ( | std::string & | n, |
const std::string & | suffix | ||
) |
Finds the last occurrence of the specified suffix and removes everything from its start to the end.
[out] | n | Reference to string. |
[in] | suffix | Suffix to find and remove. |
std::string retdec::utils::removeSuffixRet | ( | const std::string & | n, |
const std::string & | suffix | ||
) |
Finds the last occurrence of the specified suffix and removes everything from its start to the end.
[in] | n | Source string. |
[in] | suffix | Suffix to find and remove. |
std::string retdec::utils::removeWhitespace | ( | std::string | s | ) |
Removes all whitespace from the given string.
std::string retdec::utils::replaceAll | ( | const std::string & | str, |
const std::string & | from, | ||
const std::string & | to | ||
) |
Replaces all occurrences of from in str with to and returns the string obtained in this way.
If from is the empty string, it returns str.
std::string retdec::utils::replaceCharsWithStrings | ( | const std::string & | str, |
char | what, | ||
const std::string & | withWhat | ||
) |
Replaces all occurrences of what with withWhat in str and returns the resulting string.
std::string retdec::utils::replaceNonalnumCharsWith | ( | const std::string & | str, |
std::string::value_type | c | ||
) |
Replaces non-alphanumeric characters in str with c.
std::string retdec::utils::replaceNonasciiChars | ( | const std::string & | str | ) |
Replaces non-ASCII characters in str with their hexadecimal values.
std::string retdec::utils::replaceNonprintableChars | ( | const std::string & | str | ) |
Replaces non-printable characters in str with their hexadecimal values.
std::set<T> retdec::utils::setDifference | ( | const std::set< T > & | s1, |
const std::set< T > & | s2 | ||
) |
Returns the set difference s1 \setminus s2
.
In other words, this function returns the set whose elements are in s1 but are not in s2.
T | Type of elements in the sets. |
std::set<T> retdec::utils::setIntersection | ( | const std::set< T > & | s1, |
const std::set< T > & | s2 | ||
) |
Returns the set intersection s1 \cap s2
.
In other words, this function returns the set whose elements are in both s1 and s2.
T | Type of elements in the sets. |
std::set<T> retdec::utils::setUnion | ( | const std::set< T > & | s1, |
const std::set< T > & | s2 | ||
) |
Returns the set union s1 \cup s2
.
In other words, this function returns the set whose elements are in s1 or in s2.
T | Type of elements in the sets. |
bool retdec::utils::shareSomeItem | ( | const std::set< T > & | s1, |
const std::set< T > & | s2 | ||
) |
Returns true
if s1 and s2 have at least one item in common.
T | Type of elements in the sets. |
std::vector< std::string > retdec::utils::split | ( | const std::string & | str, |
char | sep, | ||
bool | trimWhitespace | ||
) |
Splits the given string by a separator.
[in] | str | String to be splitted. |
[in] | sep | Separator to be used. |
[in] | trimWhitespace | If true , trims whitespace around the separated strings. |
For example,
returns
bool retdec::utils::startsWith | ( | const std::string & | str, |
const String & | withWhat | ||
) |
Returns true
if str starts with the prefix withWhat, false
otherwise.
String | Either std::string or char * . |
std::string retdec::utils::stripDirs | ( | const std::string & | path | ) |
Strips all directories from the given path.
For example, stripDirs("/home/user/test.c")
returns "test.c"
.
TODO Implement the following functionality:
|
inline |
Converts the given string into a number.
[in] | str | String to be converted into a number. |
[out] | number | Into this parameter the resulting number is stored. |
[in] | format | Number format (e.g. std::dec, std::hex). |
true
if the conversion went ok, false
otherwise.If the conversion fails, number is left unchanged.
bool retdec::utils::systemHasLongDouble | ( | ) |
Finds out if the runtime system supports long double
(at least 10 bytes long).
std::string retdec::utils::timestampToDate | ( | std::time_t | timestamp | ) |
Returns date in human readable form.
timestamp | Timestamp for conversion. |
std::string retdec::utils::timestampToDate | ( | std::tm * | tm | ) |
Returns date in human readable form.
tm | Timestamp for conversion. |
std::string retdec::utils::toLower | ( | std::string | str | ) |
Converts all characters in str to lower case.
For example, "Crazy Willy"
is converted into "crazy willy"
.
std::string retdec::utils::toUpper | ( | std::string | str | ) |
Converts all characters in str to upper case.
For example, "Crazy Willy"
is converted into "CRAZY WILLY"
.
std::string retdec::utils::toWide | ( | const std::string & | str, |
std::string::size_type | length | ||
) |
Converts str to wide string.
[in] | str | String for conversion. |
[in] | length | Length in bytes of one character in output string. If length is zero, function returns empty string. |
std::string retdec::utils::trim | ( | std::string | str, |
const std::string & | toTrim | ||
) |
Trims the given string.
[in] | str | String to be trimmed. |
[in] | toTrim | String of characters to be trimmed (removed) from the beginning and the end of str. By default, it contains all whitespace characters from the ASCII set. |
For example, trim(" hey there ", " ")
returns "hey
there"
.
std::string retdec::utils::unicodeToAscii | ( | const std::uint8_t * | bytes, |
std::size_t | nBytes | ||
) |
Converts unicode bytes to ASCII string.
[in] | bytes | Bytes for conversion. |
[in] | nBytes | Number of bytes. |
std::string retdec::utils::unicodeToAscii | ( | const std::uint8_t * | bytes, |
std::size_t | nBytes, | ||
std::size_t & | nRead | ||
) |
Converts unicode bytes to ASCII string.
[in] | bytes | Bytes for conversion. |
[in] | nBytes | Number of bytes. |
[in] | nRead | Number of bytes read. Note that this doesn't have to be the length of returned string |
std::string retdec::utils::unifyLineEnds | ( | const std::string & | str | ) |
Unifies line ends in the given string to LF.
In a greater detail, this function converts CRLF and CR inside str to LF.
bool retdec::utils::writeFile | ( | const std::string & | fileName, |
const std::vector< N > & | data, | ||
std::size_t | start = 0 , |
||
std::size_t | desiredSize = 0 |
||
) |
Write bytes to file
fileName | Name of the file |
data | Data to write into the file |
start | Start offset of write |
desiredSize | Number of bytes to write. If this parameter is set to zero, function will write all bytes from data . |
true
if operation went OK, otherwise false
bool retdec::utils::writeFile | ( | std::ostream & | fileStream, |
const std::vector< N > & | data, | ||
std::size_t | start = 0 , |
||
std::size_t | desiredSize = 0 |
||
) |
Write bytes to file
fileStream | Representation of output file |
data | Data to write into the file |
start | Start offset of write |
desiredSize | Number of bytes to write. If this parameter is set to zero, function will write all bytes from data . |
true
if operation went OK, otherwise false