### String Functions Source: https://docs.werwolv.net/pattern-language/libraries/std/string Provides a collection of utility functions for common string operations such as getting length, accessing characters, substrings, parsing, and case conversion. ```APIDOC ## Functions ### `std::string::length` Gets the length of a string. * `string`: The string to get the length of. * `return`: The length of the string. ```rust fn length(str string); ``` ### `std::string::at` Gets the character at a given index. * `string`: The string to get the character from. * `index`: The index of the character to get. * `return`: The character at the given index. ```rust fn at(str string, u32 index); ``` ### `std::string::substr` Gets a substring of a string. * `string`: The string to get the substring from. * `pos`: The position of the first character of the substring. * `count`: The number of characters to get. * `return`: The substring. ```rust fn substr(str string, u32 pos, u32 count); ``` ### `std::string::parse_int` Converts a string to an integer. * `string`: The string to convert. * `base`: The base of the number. * `return`: The integer. ```rust fn parse_int(str string, u8 base); ``` ### `std::string::parse_float` Converts a string to a float. * `string`: The string to convert. * `return`: The float. ```rust fn parse_float(str string); ``` ### `std::string::to_string` Converts any type to a string. * `x`: The value to convert. * `return`: The string. ```rust fn to_string(auto x); ``` ### `std::string::starts_with` Checks if a string starts with a given substring. * `string`: The string to check. * `part`: The substring to check for. * `return`: True if the string starts with the substring, false otherwise. ```rust fn starts_with(str string, str part); ``` ### `std::string::ends_with` Checks if a string ends with a given substring. * `string`: The string to check. * `part`: The substring to check for. * `return`: True if the string ends with the substring, false otherwise. ```rust fn ends_with(str string, str part); ``` ### `std::string::contains` Checks if a string contains a given substring. * `string`: The string to check. * `part`: The substring to check for. * `return`: True if the string contains the substring, false otherwise. ```rust fn contains(str string, str part); ``` ### `std::string::reverse` Reverses a string. * `string`: The string to reverse. * `return`: The reversed string. ```rust fn reverse(str string); ``` ### `std::string::to_upper` Converts a string to upper case. * `string`: The string to convert. * `return`: The converted string. ```rust fn to_upper(str string); ``` ### `std::string::to_lower` Converts a string to lower case. * `string`: The string to convert. * `return`: The converted string. ```rust fn to_lower(str string); ``` ### `std::string::replace` Replaces all occurrences of a substring with another substring. * `string`: The string to replace in. * `pattern`: The substring to replace. * `replace`: The substring to replace with. * `return`: The string with the replacements. ```rust fn replace(str string, str pattern, str replace); ``` ``` -------------------------------- ### Write to a File (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/file Writes the content of a string or Pattern to an open file handle. The data is written starting from the current cursor position. ```rust fn write(std::file::Handle handle, auto data); ``` -------------------------------- ### Get Provider Information (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/hex/provider Queries information from the currently loaded provider. The specific information available depends on the type of provider (e.g., File, Disk, GDB, Process Memory). It requires a category and an optional argument. ```rust fn get_information(str category, str argument); ``` -------------------------------- ### std::core::get_bitfield_order Source: https://docs.werwolv.net/pattern-language/libraries/std/core Gets the current default bitfield order. ```APIDOC ## std::core::get_bitfield_order ### Description Gets the current default bitfield order. ### Method FUNCTION ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust fn get_bitfield_order(); ``` ### Response #### Success Response (N/A) - **return** (std::core::BitfieldOrder) - The currently set default bitfield order. #### Response Example ```rust // Example usage not directly representable in this format ``` ``` -------------------------------- ### Check if String Starts With Substring Source: https://docs.werwolv.net/pattern-language/libraries/std/string Determines if a string begins with a specified substring. It compares the beginning of the input string with the provided substring and returns true if they match, false otherwise. ```rust fn starts_with(str string, str part); ``` -------------------------------- ### Attribute Syntax Examples Source: https://docs.werwolv.net/pattern-language/core-language/attributes Illustrates the syntax for applying attributes in the pattern language. It shows how attributes can be used with no arguments, a single argument, or multiple arguments. It also demonstrates how to apply multiple attributes to a single variable or type. ```plaintext [[attribute_name]] [[attribute_name("arg1", 1234)]] [[attribute1, attribute2(1234)]] ``` -------------------------------- ### Get File Size (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/file Queries the total size of a file in bytes. This function takes a file handle and returns its size. ```rust fn size(std::file::Handle handle); ``` -------------------------------- ### Single Line Comments in C++ Source: https://docs.werwolv.net/pattern-language/core-language/comments Demonstrates single-line comments in C++. Single-line comments start with '//' and extend to the end of the line. They are used for brief explanations or temporarily disabling code. ```cpp // This is a single line comment ``` -------------------------------- ### Documentation Comments in Rust Source: https://docs.werwolv.net/pattern-language/core-language/comments Shows different ways to write documentation comments in Rust for global and local documentation. These comments, starting with '//!', '/** ... */', or '///', are used by tools to extract information and generate documentation for patterns, functions, or types. ```rust /*! This is a global doc comment. It documents the whole pattern and can contain various attributes that can be used by tools to extract information about the pattern. */ ``` ```rust /** This is a local doc comment. It documents the function or type that immediately follows it. */ ``` ```rust /** This is a doc comment documenting a function that adds two numbers together @param x The first parameter. @param y The second parameter. @return The sum of the two parameters. */ fn add(u32 x, u32 y) { return x + y; }; ``` ```rust /// This is a single line local comment. It documents the function or type that immediately follows it. ``` -------------------------------- ### std::core::get_endian Source: https://docs.werwolv.net/pattern-language/libraries/std/core Gets the current default endianness. ```APIDOC ## std::core::get_endian ### Description Gets the current default endianness. ### Method FUNCTION ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust fn get_endian(); ``` ### Response #### Success Response (N/A) - **return** (std::mem::Endian) - The currently set default endianness. #### Response Example ```rust // Example usage not directly representable in this format ``` ``` -------------------------------- ### Rust User-Defined Literals with Single Parameter Source: https://docs.werwolv.net/pattern-language/core-language/functions Demonstrates the creation and usage of single-parameter user-defined literals in Rust. These are syntactic sugar for function calls, defined by functions starting with an underscore and taking a single character parameter. ```rust fn _literal(u32 value) -> u32 { return value * 2; }; fn main() { u32 two_times = 123_literal; // two_times = 246 std::print("{}", two_times); } ``` -------------------------------- ### Get Size of Parameter Pack - Rust Source: https://docs.werwolv.net/pattern-language/libraries/std/sys Returns the number of elements within a parameter pack. Accepts a parameter pack as input and returns an integer representing its size. ```rust fn sizeof_pack(auto ... pack, ); ``` -------------------------------- ### relative_to_pointer Function (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/ptr Calculates a new pointer base using the offset of the current pointer as the starting address. It takes a u128 offset and returns the new pointer base. ```rust fn relative_to_pointer(u128 offset); ``` -------------------------------- ### Get Bitfield Order Function (werwolv.net Pattern Language) Source: https://docs.werwolv.net/pattern-language/libraries/std/core Retrieves the currently set default bitfield order. This indicates the order in which bits are arranged within a byte. ```pattern fn get_bitfield_order(); ``` -------------------------------- ### Endianness Specification in Rust Source: https://docs.werwolv.net/pattern-language/core-language/data-types Demonstrates how to specify endianness for data types in Rust. It shows examples for little-endian and big-endian unsigned 32-bit integers and signed 8-bit integers using native endianness. ```rust le u32 myUnsigned; // Little endian 32 bit unsigned integer be double myDouble; // Big endian 64 bit double precision floating point s8 myInteger; // Native endian 8 bit signed integer ``` -------------------------------- ### Get Member Count Function (werwolv.net Pattern Language) Source: https://docs.werwolv.net/pattern-language/libraries/std/core Queries the number of members in a struct, union, bitfield, or the number of entries in an array. Takes the pattern to query as input. ```pattern fn member_count(auto pattern); ``` -------------------------------- ### Format u32 as Hexadecimal using type::Formatted Source: https://docs.werwolv.net/pattern-language/libraries/type/fmt This example demonstrates how to read a u32 from data and format it as an uppercase hexadecimal value with a minimum of 8 digits, prefixed by '0x'. The format string adheres to the libfmt specification. ```rust type::Formatted hex_formatted_integer @ 0x00; ``` -------------------------------- ### Create Directories (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/file Creates all necessary parent directories for a given file path. This is useful before creating a new file in a non-existent directory structure. ```rust fn create_directories(str path); ``` -------------------------------- ### Get String Length Source: https://docs.werwolv.net/pattern-language/libraries/std/string A function to retrieve the length of a given string. It takes a string as input and returns its length as a value. ```rust fn length(str string); ``` -------------------------------- ### Open a File (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/file Opens a file at the specified path with the given mode and returns a file handle. This function requires user permission due to its potentially dangerous nature. ```rust fn open(str path, std::file::Mode mode); ``` -------------------------------- ### Get Current Epoch Time Source: https://docs.werwolv.net/pattern-language/libraries/std/time The `epoch` function returns the current time in seconds since the epoch. This is a fundamental function for obtaining a Unix-like timestamp. ```rust fn epoch(); ``` -------------------------------- ### Get Pattern Attribute Argument Function (werwolv.net Pattern Language) Source: https://docs.werwolv.net/pattern-language/libraries/std/core Retrieves the nth parameter of an attribute associated with a pattern, if it exists. Defaults to the 0th index if not specified. Takes the pattern, attribute name, and optional index. ```pattern fn get_attribute_argument(auto pattern, str attribute, u32 index); ``` -------------------------------- ### Get Environment Variable Value - Rust Source: https://docs.werwolv.net/pattern-language/libraries/std/sys Retrieves the value of a specified environment variable. Takes the variable name as a string and returns its value. ```rust fn env(str name); ``` -------------------------------- ### Format String to String (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/io Formats a string using C++20 std::format or libfmt syntax and returns the result. Takes a format string and variable arguments. ```rust fn format(auto fmt, auto ... args); ``` -------------------------------- ### Rust Pattern Views for Data Access Source: https://docs.werwolv.net/pattern-language/core-language/functions Explains how pattern views are created when using placement syntax in Rust within certain statements like 'if' or 'for'. Views provide access to data without generating an output pattern, similar to a placed variable. ```rust fn read_u32(u32 address) -> u32 { // Creates a view of the data at 'address' u32 value @ address; return value; }; fn main() { // Assuming 0x1234 is a valid memory address std::print("{}", read_u32(0x1234)); // Prints the value at address 0x1234 formatted as a u32 } ``` -------------------------------- ### Define a Simple Rust Struct for a 3D Vector Source: https://docs.werwolv.net/pattern-language/core-language/data-types Demonstrates the basic syntax for defining a struct in Rust to group related data members. This example creates a `Vector3f` struct to hold three float values representing x, y, and z coordinates. ```rust struct Vector3f { float x, y, z; }; ``` -------------------------------- ### Get Character at Index Source: https://docs.werwolv.net/pattern-language/libraries/std/string Retrieves the character at a specific index within a string. It requires the string and the desired index as input, returning the character found at that position. ```rust fn at(str string, u32 index); ``` -------------------------------- ### math::perm Source: https://docs.werwolv.net/pattern-language/libraries/std/math Calculates the number of permutations P(n, k). ```APIDOC ## math::perm ### Description Calculates the permutation of `n` and `k`. ### Method N/A (Function Call) ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust let result = std::math::perm(5, 2); ``` ### Response #### Success Response (200) - **return** (u128) - Permutation of `n` and `k` #### Response Example ```rust // Assuming n = 5, k = 2 // result = 20 ``` ``` -------------------------------- ### Dollar Operator for Offset Tracking in Rust Source: https://docs.werwolv.net/pattern-language/core-language/expressions Demonstrates the use of the dollar operator ($) in Rust to get the current offset within a pattern. It shows how to print the offset and how to modify it. It also shows accessing bytes at specific offsets. ```rust #pragma base_address 0x00 std::print($); // 0 u32 x @ 0x00; std::print($); // 4 ``` ```rust $ += 0x100; ``` ```rust std::print($[0]); // Prints the value of the byte at address 0x00 ``` -------------------------------- ### Get Current Selection Source: https://docs.werwolv.net/pattern-language/libraries/hex/core Retrieves the current selection within the hex editor. This function returns a `hex::core::Selection` type. ```APIDOC ## GET /hex/core/get_selection ### Description Returns the current selection in the hex editor. ### Method GET ### Endpoint /hex/core/get_selection ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **selection** (`hex::core::Selection`) - The current selection in the hex editor. #### Response Example ```json { "selection": { ... } } ``` ``` -------------------------------- ### std::warning Source: https://docs.werwolv.net/pattern-language/libraries/std/io Prints a warning message to the console without aborting execution. ```APIDOC ## std::warning ### Description Prints a warning message to the console. ### Method `warning` ### Parameters #### Arguments - **message** (string) - The message to print. ### Request Example ```rust warning("Configuration file not found. Using default settings."); ``` ### Response #### Output Prints the warning message to the console. ``` -------------------------------- ### Assertion Functions Source: https://docs.werwolv.net/pattern-language/libraries/std/sys Functions to assert conditions and provide feedback if they are not met. ```APIDOC ## `std::assert` ### Description Asserts that a given value is true. If it's not, abort evaluation and print the given message to the console. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (N/A) N/A #### Response Example N/A ## `std::assert_warn` ### Description Asserts that a given value is true. If it's not, print the given message to the console as a warning. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Extract Substring Source: https://docs.werwolv.net/pattern-language/libraries/std/string Extracts a portion of a string, known as a substring. It takes the original string, a starting position, and the desired count of characters as arguments, returning the extracted substring. ```rust fn substr(str string, u32 pos, u32 count); ``` -------------------------------- ### Include Files with #include Directive Source: https://docs.werwolv.net/pattern-language/core-language/importing-modules The #include directive acts as a preprocessor directive, replacing the directive with the lexical tokens of the included file. It supports quoted or braced paths and automatically searches for .pat and .hexpat extensions. This method includes preprocessor defines from the included file. ```rust #include "std/io.pat" #include ``` -------------------------------- ### Query Provider Information Source: https://docs.werwolv.net/pattern-language/libraries/hex/provider Queries information from the currently loaded provider. The type of information available depends on the specific provider that is loaded. ```APIDOC ## hex::prv::get_information ### Description Queries information from the currently loaded provider. The kind of information that's available depends on the provider that's loaded. ### Method GET (or a similar method depending on how providers are accessed) ### Endpoint `/provider/information` ### Parameters #### Query Parameters - **category** (str) - Required - The category of information to query (e.g., "File", "Disk", "GDB", "Process Memory"). - **argument** (str) - Optional - An extra argument to pass along, if required by the specific information category. ### Request Example ```json { "category": "File", "argument": "file_path" } ``` ### Response #### Success Response (200) - **value** (str | u128 | time_t | u16 | u64 | u32) - The requested information from the provider. The type depends on the category and specific information requested. #### Response Example ```json { "value": "/path/to/your/file.txt" } ``` ### Available Information Details #### File Provider - `file_path()` -> str - `file_name()` -> str - `file_extension()` -> str - `creation_time()` -> time_t - `access_time()` -> time_t - `modification_time()` -> time_t - `permissions()` -> u16 #### Disk Provider - `file_path()` -> str - `sector_size()` -> u128 #### GDB Provider - `ip()` -> str - `port()` -> u16 #### Process Memory Provider - `region_address(regionName)` -> u64 - `region_size(regionName)` -> u64 - `process_id()` -> u32 - `process_name()` -> str ``` -------------------------------- ### std::core::execute_function Source: https://docs.werwolv.net/pattern-language/libraries/std/core Executes the function with the given name, passing in all given arguments. ```APIDOC ## std::core::execute_function ### Description Executes the function with the given name, passing in all given arguments. ### Method FUNCTION ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust fn execute_function(str function_name, auto ... args); ``` ### Response #### Success Response (N/A) - **return** (any) - The return value of the executed function. Type depends on the function. #### Response Example ```rust // Example usage not directly representable in this format ``` ``` -------------------------------- ### std::print Source: https://docs.werwolv.net/pattern-language/libraries/std/io Formats the given arguments using the format string and prints the result to the console. Supports C++20 std::format or libfmt. ```APIDOC ## std::print ### Description Formats the given arguments using the format string and prints the result to the console. This function uses the C++20 `std::format` or libfmt's `fmt::format` syntax. ### Method `print` ### Parameters #### Arguments - **fmt** (string) - The format string or any other value that can be converted to a string. - **args** (variadic) - Values to use in the formatting. ### Request Example ```rust print("Hello, {}! You have {} messages.", "World", 5); ``` ### Response #### Output Prints the formatted string to the console. ``` -------------------------------- ### relative_to_parent Function (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/ptr Determines a new pointer base by using the offset of the pointer's parent as the starting address. It accepts a u128 offset and returns the new pointer base. ```rust fn relative_to_parent(u128 offset); ``` -------------------------------- ### File Operations API Source: https://docs.werwolv.net/pattern-language/libraries/std/file This section details the functions available in the File library for performing various operations on files. These include opening, closing, reading, writing, seeking, resizing, flushing, removing files, and creating directories. ```APIDOC ## std::file::open ### Description Opens a file at the specified path with the given mode. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **path** (str) - Required - The path to the file to open. - **mode** (std::file::Mode) - Required - File open mode (Create, Read, Write). ### Request Example ```rust std::file::open("path/to/file.txt", std::file::Mode::Read); ``` ### Response #### Success Response - **return** (std::file::Handle) - Handle to the newly opened file. #### Response Example ```rust let file_handle: std::file::Handle = std::file::open("my_file.txt", std::file::Mode::Write); ``` ## std::file::close ### Description Closes a file handle that has been opened previously. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **handle** (std::file::Handle) - Required - The handle to close. ### Request Example ```rust std::file::close(file_handle); ``` ### Response #### Success Response None #### Response Example N/A ## std::file::read ### Description Reads a specified number of bytes from the content of a file into a string. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **handle** (std::file::Handle) - Required - The file handle to read from. - **size** (u64) - Required - Number of bytes to read. ### Request Example ```rust let content: str = std::file::read(file_handle, 1024); ``` ### Response #### Success Response - **return** (str) - String containing the read data. #### Response Example ```rust let file_content: str = std::file::read(my_handle, 512); ``` ## std::file::write ### Description Writes the content of a string or Pattern into a file. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **handle** (std::file::Handle) - Required - The file handle to write to. - **data** (auto) - Required - String or Pattern to write to the file. ### Request Example ```rust std::file::write(file_handle, "Some data to write"); ``` ### Response #### Success Response None #### Response Example N/A ## std::file::seek ### Description Sets the current cursor position in the given file handle. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **handle** (std::file::Handle) - Required - The file handle to set the cursor position in. - **offset** (u64) - Required - The offset to move the cursor to. ### Request Example ```rust std::file::seek(file_handle, 0); ``` ### Response #### Success Response None #### Response Example N/A ## std::file::size ### Description Queries the size of a file. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **handle** (std::file::Handle) - Required - The handle of the file to get the size of. ### Request Example ```rust let file_size: u64 = std::file::size(file_handle); ``` ### Response #### Success Response - **return** (u64) - The file's size. #### Response Example ```rust let size: u64 = std::file::size(my_handle); ``` ## std::file::resize ### Description Resizes a file to the specified size. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **handle** (std::file::Handle) - Required - The handle of the file to resize. - **size** (u64) - Required - The new size of the file. ### Request Example ```rust std::file::resize(file_handle, 1024); ``` ### Response #### Success Response None #### Response Example N/A ## std::file::flush ### Description Flushes changes made to a file to disk. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **handle** (std::file::Handle) - Required - The handle of the file to flush. ### Request Example ```rust std::file::flush(file_handle); ``` ### Response #### Success Response None #### Response Example N/A ## std::file::remove ### Description Deletes a file from disk. This will also automatically close this file. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **handle** (std::file::Handle) - Required - The handle of the file to delete. ### Request Example ```rust std::file::remove(file_handle); ``` ### Response #### Success Response None #### Response Example N/A ## std::file::create_directories ### Description Create all directories for the provided path. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **path** (str) - Required - The path for which all directories should be created. ### Request Example ```rust std::file::create_directories("path/to/new/directories"); ``` ### Response #### Success Response None #### Response Example N/A ``` -------------------------------- ### Warning Reporting (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/io Prints a warning message to the console without aborting execution. Accepts a string message. ```rust fn warning(str message); ``` -------------------------------- ### Rust Pointer Declaration Source: https://docs.werwolv.net/pattern-language/core-language/data-types Declares a pointer variable. This example shows a pointer to a `u16` whose address is stored as a `u32`. Pointers are fundamental for referencing memory locations indirectly. ```rust u16 *pointer : u32 @ 0x08; ``` -------------------------------- ### math::comb Source: https://docs.werwolv.net/pattern-language/libraries/std/math Calculates the binomial coefficient C(n, k). ```APIDOC ## math::comb ### Description Calculates the binomial coefficient of `n` and `k`. ### Method N/A (Function Call) ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust let result = std::math::comb(5, 2); ``` ### Response #### Success Response (200) - **return** (u128) - Binomial coefficient of `n` and `k` #### Response Example ```rust // Assuming n = 5, k = 2 // result = 10 ``` ``` -------------------------------- ### Get Default Endianness Function (werwolv.net Pattern Language) Source: https://docs.werwolv.net/pattern-language/libraries/std/core Retrieves the currently set default endianness. This indicates the byte order used for multi-byte data interpretation. ```pattern fn get_endian(); ``` -------------------------------- ### Get Pattern Attribute Value Function (werwolv.net Pattern Language) Source: https://docs.werwolv.net/pattern-language/libraries/std/core Retrieves the value of a specified attribute from a given pattern. Takes the pattern and attribute name as input. ```pattern fn get_attribute_value(auto pattern, str attribute); ``` -------------------------------- ### std::core::set_pattern_palette_colors Source: https://docs.werwolv.net/pattern-language/libraries/std/core Sets the pattern color palette for all future created patterns. ```APIDOC ## std::core::set_pattern_palette_colors ### Description Sets the pattern color palette for all future created patterns. ### Method FUNCTION ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust fn set_pattern_palette_colors(auto ... colors, ); ``` ### Response #### Success Response (N/A) No return value. #### Response Example ```rust // Example usage not directly representable in this format ``` ``` -------------------------------- ### Get Current Selection in Rust Source: https://docs.werwolv.net/pattern-language/libraries/hex/core Retrieves the current selection active in the ImHex Hex Editor. This function returns an instance of the `Selection` type, providing details about the selected data. ```rust fn get_selection() -> Selection; ``` -------------------------------- ### std::format Source: https://docs.werwolv.net/pattern-language/libraries/std/io Formats the given arguments using the format string and returns the result as a string. Supports C++20 std::format or libfmt. ```APIDOC ## std::format ### Description Formats the given arguments using the format string and returns the result as a string. This function uses the C++20 `std::format` or libfmt's `fmt::format` syntax. ### Method `format` ### Parameters #### Arguments - **fmt** (string) - The format string or any other value that can be converted to a string. - **args** (variadic) - Values to use in the formatting. ### Request Example ```rust let message = format("User ID: {}", 12345); ``` ### Response #### Success Response (string) - **return** (string) - The formatted string. ``` -------------------------------- ### Casting Operator for Type Conversion in Rust Source: https://docs.werwolv.net/pattern-language/core-language/expressions Illustrates the casting operator in Rust, which converts an expression from one type to another. The example shows casting a float to a unsigned 32-bit integer. ```rust fn test(float x) { return 1 + u32(x); } test(3.14159); // 4 ``` -------------------------------- ### math::min Source: https://docs.werwolv.net/pattern-language/libraries/std/math Compares two values and returns the smaller one. ```APIDOC ## math::min ### Description Compares the values `a` and `b` with each other and returns the smaller of the two. ### Method N/A (Function Call) ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust let result = std::math::min(5, 10); ``` ### Response #### Success Response (200) - **return** (auto) - `a` if `a` is smaller than `b`, otherwise `b` #### Response Example ```rust // Assuming a = 5, b = 10 // result = 5 ``` ``` -------------------------------- ### Get Custom Memory Section Size Source: https://docs.werwolv.net/pattern-language/libraries/std/mem Retrieves the current size of a custom memory section. It requires a handle to the section and returns the size as a u128 value. This is useful for understanding memory allocation. ```Rust fn get_section_size(std::mem::Section section); ``` -------------------------------- ### Parameter Pack Size Source: https://docs.werwolv.net/pattern-language/libraries/std/sys Function to determine the number of elements in a parameter pack. ```APIDOC ## `std::sizeof_pack` ### Description Returns the number of parameters in a parameter pack. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (N/A) - **return** (int) - Number of parameters in the pack. #### Response Example N/A ``` -------------------------------- ### Rust While Loop Syntax Source: https://docs.werwolv.net/pattern-language/core-language/functions Demonstrates the basic syntax for a while loop in Rust. The loop continues to execute its body as long as the condition specified in the `while` head evaluates to true. ```rust while (check()) { // Keeps on executing as long as the check() function returns true } ``` -------------------------------- ### Accumulate Values in Memory Range Source: https://docs.werwolv.net/pattern-language/libraries/std/math Calculates the sum of all values within a specified memory range. It takes the start and end addresses, the size of each value, and optional section, operation, and endianness parameters. Defaults to addition and native endianness. ```Rust fn accumulate(u128 start, u128 end, u128 valueSize, std::mem::Section section, std::math::AccumulateOperation operation, std::mem::Endian endian); ``` -------------------------------- ### std::core::set_bitfield_order Source: https://docs.werwolv.net/pattern-language/libraries/std/core Sets the bitfield order for subsequent pattern creations. ```APIDOC ## std::core::set_bitfield_order ### Description Sets the bitfield order for subsequent pattern creations. ### Method FUNCTION ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust fn set_bitfield_order(std::core::BitfieldOrder order); ``` ### Response #### Success Response (N/A) No return value. #### Response Example ```rust // Example usage not directly representable in this format ``` ``` -------------------------------- ### Rust Pointer to Array Declaration Source: https://docs.werwolv.net/pattern-language/core-language/data-types Declares a pointer that points to an array. This specific example declares a pointer to an array of 10 `u32`s, where the pointer itself has a size of `s16`. Absolute addressing is assumed for pointers. ```rust u32 *pointerToArray[10] : s16 @ 0x10; ``` -------------------------------- ### Time and Date Operations Source: https://docs.werwolv.net/pattern-language/libraries/std/time This section details the various types and functions available for handling time and date operations, including conversions and formatting. ```APIDOC ## Types ### `std::time::DOSDate` A type to represent a DOS date. ### `std::time::DOSTime` A type to represent a DOS time. ### `std::time::EpochTime` A type to represent a time in seconds since the epoch. ### `std::time::Time` A structured representation of a time and date. ### `std::time::TimeConverter` A helper type to convert between Time and u128. ### `std::time::TimeZone` A type to represent a time zone. Can be `Local` or `UTC`. ## Functions ### `std::time::epoch` Returns the current time in seconds since the epoch. ### `std::time::to_local` Converts a time in seconds since the epoch to a local time. * **epoch_time** (std::time::EpochTime) - The time in seconds since the epoch. ### `std::time::to_utc` Converts a time in seconds since the epoch to a UTC time. * **epoch_time** (std::time::EpochTime) - The time in seconds since the epoch. ### `std::time::now` Queries the current time in the specified time zone. * **time_zone** (std::time::TimeZone) - The time zone to query. Defaults to local. ### `std::time::to_dos_date` Converts a value to a DOS date. * **value** (u16) - The value to convert. ### `std::time::to_dos_time` Converts a value to a DOS time. * **value** (u16) - The value to convert. ### `std::time::filetime_to_unix` Converts a FILETIME to unix time. * **value** (u64) - The value to convert. ### `std::time::format` Formats a time according to the specified format string. * **time** (std::time::Time) - The time to format. * **format_string** (str) - The format string to use. Defaults to "%c". ### `std::time::format_dos_date` Formats a DOS date according to the specified format string. * **date** (std::time::DOSDate) - The DOS date to format. * **format_string** (str) - The format string to use. Defaults to "{}/{}/{}". ### `std::time::format_dos_time` Formats a DOS time according to the specified format string. * **time** (std::time::DOSTime) - The DOS time to format. * **format_string** (str) - The format string to use. Defaults to "{:02}:{:02}:{:02}". ``` -------------------------------- ### Set Pattern Palette Colors Function (werwolv.net Pattern Language) Source: https://docs.werwolv.net/pattern-language/libraries/std/core Sets the color palette for all subsequently created patterns. Accepts a variable number of RGBA8 colors as 32-bit integers. ```pattern fn set_pattern_palette_colors(auto ... colors, ); ``` -------------------------------- ### Fixed-Point Conversion Functions Source: https://docs.werwolv.net/pattern-language/libraries/std/fxpt Functions for converting between fixed-point and floating-point representations, and for adjusting the precision of fixed-point numbers. ```APIDOC ## `std::fxpt::to_float` ### Description Converts a fixed-point value into a floating-point value with a specified precision. ### Method `std::fxpt::to_float(std::fxpt::fixed fxt, u32 precision)` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **fxt** (`std::fxpt::fixed`) - The fixed-point value to convert. - **precision** (`u32`) - The number of bits of precision the new floating-point value should have. ### Request Example ```json { "fxt": "", "precision": 32 } ``` ### Response #### Success Response (200) - **return** (``) - The floating-point representation of `fxt`. #### Response Example ```json { "return": 123.456 } ``` ## `std::fxpt::to_fixed` ### Description Converts a floating-point value into a fixed-point value with a specified precision. ### Method `std::fxpt::to_fixed(double flt, u32 precision)` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **flt** (`double`) - The floating-point value to convert. - **precision** (`u32`) - The number of bits of precision the new fixed-point value should have. ### Request Example ```json { "flt": 123.456, "precision": 32 } ``` ### Response #### Success Response (200) - **return** (`std::fxpt::fixed`) - The fixed-point representation of `flt`. #### Response Example ```json { "return": "" } ``` ## `std::fxpt::change_precision` ### Description Changes the number of bits used to represent the decimal part of a given fixed-point number. ### Method `std::fxpt::change_precision(std::fxpt::fixed value, u32 start_precision, u32 end_precision)` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **value** (`std::fxpt::fixed`) - The fixed-point value to convert. - **start_precision** (`u32`) - The current number of bits used for the decimal part. - **end_precision** (`u32`) - The new number of bits to use for the decimal part. ### Request Example ```json { "value": "", "start_precision": 16, "end_precision": 32 } ``` ### Response #### Success Response (200) - **return** (`std::fxpt::fixed`) - `value` as a new fixed-point number with `end_precision` bits of precision. #### Response Example ```json { "return": "" } ``` ``` -------------------------------- ### Get Maximum Value for Signed 128-bit Integer (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/limits Retrieves the maximum value that can be stored in a `s128` (signed 128-bit integer) data type in Rust. This function has no input parameters and returns the maximum representable value. ```rust fn s128_max(); ``` -------------------------------- ### Print Formatted String (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/io Formats and prints a string to the console using C++20 std::format or libfmt syntax. Accepts a format string and variable arguments. ```rust fn print(auto fmt, auto ... args); ``` -------------------------------- ### Get Minimum Value for Signed 128-bit Integer (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/limits Retrieves the minimum value that can be stored in a `s128` (signed 128-bit integer) data type in Rust. This function has no input parameters and returns the minimum representable value. ```rust fn s128_min(); ``` -------------------------------- ### Get Maximum Value for Unsigned 128-bit Integer (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/limits Retrieves the maximum value that can be stored in a `u128` (unsigned 128-bit integer) data type in Rust. This function has no input parameters and returns the maximum representable value. ```rust fn u128_max(); ``` -------------------------------- ### Random Number Generation API Source: https://docs.werwolv.net/pattern-language/libraries/std/random This section details the functions available for generating random numbers, including setting seeds and specifying distributions. ```APIDOC ## std::random::set_seed ### Description Sets the seed of the random number generator. ### Method POST ### Endpoint /std/random/set_seed ### Parameters #### Query Parameters - **seed** (u64) - Required - Seed to use ### Request Example ```json { "seed": 1234567890 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ## std::random::generate_using ### Description Generates a random number using the given distribution with the given parameters. The random number generator used internally is C++'s std::mt19937_64 Mersenne Twister implementation. ### Method POST ### Endpoint /std/random/generate_using ### Parameters #### Query Parameters - **distribution** (std::random::Distribution) - Required - Distribution to use. Supported distributions include Uniform, Normal, Exponential, Gamma, Weibull, ExtremeValue, ChiSquared, Cauchy, FisherF, StudentT, LogNormal, Bernoulli, Binomial, NegativeBinomial, Geometric, Poisson. - **param1** (auto) - Optional - This parameter depends on the type of distribution used. Defaults to 0. - **param2** (auto) - Optional - This parameter depends on the type of distribution used. Defaults to 0. ### Request Example ```json { "distribution": "Normal", "param1": 0.0, "param2": 1.0 } ``` ### Response #### Success Response (200) - **randomNumber** (auto) - The generated random number, type depends on the distribution. #### Response Example ```json { "randomNumber": 0.753 } ``` ## std::random::generate ### Description Generates a uniformly distributed random number between `min` and `max`. ### Method POST ### Endpoint /std/random/generate ### Parameters #### Query Parameters - **min** (u64) - Optional - Minimum number. Defaults to 0. - **max** (u64) - Optional - Maximum number. Defaults to `u64_max`. ### Request Example ```json { "min": 10, "max": 100 } ``` ### Response #### Success Response (200) - **randomNumber** (u64) - The generated uniformly distributed random number. #### Response Example ```json { "randomNumber": 55 } ``` ``` -------------------------------- ### Get Minimum Value for Unsigned 128-bit Integer (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/limits Retrieves the minimum value that can be stored in a `u128` (unsigned 128-bit integer) data type in Rust. This function has no input parameters and returns the minimum representable value. ```rust fn u128_min(); ``` -------------------------------- ### Get Maximum Value for Signed 64-bit Integer (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/limits Retrieves the maximum value that can be stored in a `s64` (signed 64-bit integer) data type in Rust. This function has no input parameters and returns the maximum representable value. ```rust fn s64_max(); ``` -------------------------------- ### math::pow Source: https://docs.werwolv.net/pattern-language/libraries/std/math Calculates a base raised to the power of an exponent. ```APIDOC ## math::pow ### Description Calculates the value of `base` raised to the power of `exp`. ### Method N/A (Function Call) ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust let result = std::math::pow(2.0, 3.0); ``` ### Response #### Success Response (200) - **return** (auto) - `base` raised to the power of `exp` #### Response Example ```rust // Assuming base = 2.0, exp = 3.0 // result = 8.0 ``` ``` -------------------------------- ### Rust Function Return Statement Source: https://docs.werwolv.net/pattern-language/core-language/functions Shows how to return a value from a Rust function using the 'return' keyword. The function's return type is inferred from the returned value. ```rust fn get_value() -> u32 { return 1234; }; fn main() { std::print("{}", get_value()); // 1234 } ``` -------------------------------- ### Get Minimum Value for Signed 64-bit Integer (Rust) Source: https://docs.werwolv.net/pattern-language/libraries/std/limits Retrieves the minimum value that can be stored in a `s64` (signed 64-bit integer) data type in Rust. This function has no input parameters and returns the minimum representable value. ```rust fn s64_min(); ``` -------------------------------- ### Format Pattern Value Function (werwolv.net Pattern Language) Source: https://docs.werwolv.net/pattern-language/libraries/std/core Formats a pattern using its default or custom formatter. This allows for consistent string representation of data. Takes the pattern to format as input. ```pattern fn formatted_value(auto pattern); ```