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 enum
Represent the operating system types supported by cvc5. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The base path inside the JAR where native libraries are stored. -
Method Summary
Modifier and TypeMethodDescriptionConvert an array ofPair
objects, where the second element extendsAbstractPointer
, into an array ofPair
objects with the second element as aLong
representing the native pointer.static long[]
getPointers
(io.github.cvc5.IPointer[] objects) Extract native pointer values from a one-dimensional array ofIPointer
objects.static long[][]
getPointers
(io.github.cvc5.IPointer[][] objects) Extract native pointer values from a two-dimensional matrix ofIPointer
objects.static Proof[]
getProofs
(long[] pointers) Construct an array ofProof
objects from an array of native pointers.static String
getRational
(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 ofSort
objects from an array of native pointers.static Term[]
getTerms
(long[] pointers) Construct an array ofTerm
objects from an array of native pointers.static void
Load cvc5 native libraries.static void
loadLibraryFromJar
(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 void
transferTo
(InputStream inputStream, FileOutputStream outputStream) Transfer all bytes from the providedInputStream
to the specifiedFileOutputStream
.static void
validateUnsigned
(int[] integers, String name) Validate that all elements in the given array are non-negative (unsigned).static void
validateUnsigned
(int integer, String name) Validate that the specified integer is non-negative (unsigned).static void
validateUnsigned
(long[] integers, String name) Validate that all elements in the given array are non-negative (unsigned).static void
validateUnsigned
(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 providedInputStream
to 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 ofSort
objects from an array of native pointers.- Parameters:
pointers
- The array of pointers.- Returns:
- Sorts array from array of Sort pointers.
-
getTerms
Construct an array ofTerm
objects from an array of native pointers.- Parameters:
pointers
- The array of pointers.- Returns:
- Terms array from array of Term pointers.
-
getProofs
Construct an array ofProof
objects 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 ofIPointer
objects.- 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 ofIPointer
objects.- 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 ofPair
objects, where the second element extendsAbstractPointer
, into an array ofPair
objects with the second element as aLong
representing the native pointer.- Type Parameters:
K
- The type of the first element in the pairs.- Parameters:
abstractPointers
- The input array of pairs withAbstractPointer
as 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.
-