Package io.github.cvc5
Class Utils
java.lang.Object
io.github.cvc5.Utils
A utility class containing static helper methods commonly used across the application.
This class is not meant to be instantiated. All methods are static and stateless.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresent the operating system types supported by cvc5. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe base path inside the JAR where native libraries are stored. -
Method Summary
Modifier and TypeMethodDescriptionConvert an array ofPairobjects, where the second element extendsAbstractPointer, into an array ofPairobjects with the second element as aLongrepresenting the native pointer.static long[]getPointers(io.github.cvc5.IPointer[] objects) Extract native pointer values from a one-dimensional array ofIPointerobjects.static long[][]getPointers(io.github.cvc5.IPointer[][] objects) Extract native pointer values from a two-dimensional matrix ofIPointerobjects.static Proof[]getProofs(long[] pointers) Construct an array ofProofobjects from an array of native pointers.static StringgetRational(Pair<BigInteger, BigInteger> pair) Convert a pair of BigIntegers to a rational string a/bstatic Pair<BigInteger, BigInteger> getRational(String rational) Convert a rational string a/b to a pair of BigIntegersstatic Sort[]getSorts(long[] pointers) Construct an array ofSortobjects from an array of native pointers.static Term[]getTerms(long[] pointers) Construct an array ofTermobjects from an array of native pointers.static voidLoad cvc5 native libraries.static voidloadLibraryFromJar(Path tempDir, String path, String filename) Load a native library from a specified path within a JAR file and loads it into the JVM.static voidtransferTo(InputStream inputStream, FileOutputStream outputStream) Transfer all bytes from the providedInputStreamto the specifiedFileOutputStream.static voidvalidateUnsigned(int[] integers, String name) Validate that all elements in the given array are non-negative (unsigned).static voidvalidateUnsigned(int integer, String name) Validate that the specified integer is non-negative (unsigned).static voidvalidateUnsigned(long[] integers, String name) Validate that all elements in the given array are non-negative (unsigned).static voidvalidateUnsigned(long integer, String name) Validate that the specified long integer is non-negative (unsigned).
-
Field Details
-
LIBPATH_IN_JAR
The base path inside the JAR where native libraries are stored.- See Also:
-
-
Method Details
-
transferTo
public static void transferTo(InputStream inputStream, FileOutputStream outputStream) throws IOException Transfer all bytes from the providedInputStreamto the specifiedFileOutputStream.Note: This method replicates the functionality of InputStream#transferTo(OutputStream), which was introduced in Java 9 (currently, the minimum required Java version is 1.8)
- Parameters:
inputStream- The input stream from which data is readoutputStream- The output stream to which data is written- Throws:
IOException- If an I/O error occurs during reading or writing
-
loadLibraryFromJar
public static void loadLibraryFromJar(Path tempDir, String path, String filename) throws FileNotFoundException, Exception Load a native library from a specified path within a JAR file and loads it into the JVM.- Parameters:
tempDir- The temporary directory where the extracted native library will be written.path- The path inside the JAR where the library is located (e.g., "/cvc5-libs").filename- The name of the library file (e.g., "libcvc5.so").- Throws:
FileNotFoundException- If the library cannot be foundException- If an I/O error occurs or the library cannot be loaded
-
loadLibraries
public static void loadLibraries()Load cvc5 native libraries. -
getSorts
Construct an array ofSortobjects from an array of native pointers.- Parameters:
pointers- The array of pointers.- Returns:
- Sorts array from array of Sort pointers.
-
getTerms
Construct an array ofTermobjects from an array of native pointers.- Parameters:
pointers- The array of pointers.- Returns:
- Terms array from array of Term pointers.
-
getProofs
Construct an array ofProofobjects from an array of native pointers.- Parameters:
pointers- The array of pointers.- Returns:
- proofs array from array of Proof pointers
-
getPointers
public static long[] getPointers(io.github.cvc5.IPointer[] objects) Extract native pointer values from a one-dimensional array ofIPointerobjects.- Parameters:
objects- The one dimensional array of pointers.- Returns:
- Pointers from one dimensional array.
-
getPointers
public static long[][] getPointers(io.github.cvc5.IPointer[][] objects) Extract native pointer values from a two-dimensional matrix ofIPointerobjects.- Parameters:
objects- The two dimensional array of pointers.- Returns:
- Pointers from two dimensional matrix.
-
validateUnsigned
Validate that the specified integer is non-negative (unsigned).- Parameters:
integer- The integer value to validatename- A name to use in the exception message for identification- Throws:
CVC5ApiException- if the value is negative
-
validateUnsigned
Validate that the specified long integer is non-negative (unsigned).- Parameters:
integer- The long value to validatename- A name to use in the exception message for identification- Throws:
CVC5ApiException- if the value is negative
-
validateUnsigned
Validate that all elements in the given array are non-negative (unsigned).- Parameters:
integers- The array of integers to validatename- A name to use in the exception message for identification- Throws:
CVC5ApiException- if any element in the array is negative
-
validateUnsigned
Validate that all elements in the given array are non-negative (unsigned).- Parameters:
integers- The array of long integers to validatename- A name to use in the exception message for identification- Throws:
CVC5ApiException- if any element in the array is negative
-
getPairs
public static <K> Pair<K,Long>[] getPairs(Pair<K, ? extends io.github.cvc5.AbstractPointer>[] abstractPointers) Convert an array ofPairobjects, where the second element extendsAbstractPointer, into an array ofPairobjects with the second element as aLongrepresenting the native pointer.- Type Parameters:
K- The type of the first element in the pairs.- Parameters:
abstractPointers- The input array of pairs withAbstractPointeras the second element.- Returns:
- An array of pairs where the second element is the native pointer value as a
Long.
-
getRational
Convert a rational string a/b to a pair of BigIntegers- Parameters:
rational- The rational string.- Returns:
- The pair of big integers.
-
getRational
Convert a pair of BigIntegers to a rational string a/b- Parameters:
pair- The pair of big integers.- Returns:
- The rational string.
-