本文整理汇总了Java中org.bridj.Pointer.getCString方法的典型用法代码示例。如果您正苦于以下问题:Java Pointer.getCString方法的具体用法?Java Pointer.getCString怎么用?Java Pointer.getCString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bridj.Pointer
的用法示例。
在下文中一共展示了Pointer.getCString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import org.bridj.Pointer; //导入方法依赖的package包/类
@Override
public String toString() {
Pointer<SizeT> size = Pointer.allocateSizeT();
handleRuntimeError(LIB.clingo_theory_atoms_element_to_string_size(pointer, id, size), "Error reading to string size!");
Pointer<Byte> string = Pointer.allocateByte();
handleRuntimeError(LIB.clingo_theory_atoms_element_to_string(pointer, id, string, size.getLong()), "Error reading the theory element string");
return string.getCString();
}
示例2: getValue
import org.bridj.Pointer; //导入方法依赖的package包/类
public String getValue() throws ClingoException {
Pointer<SizeT> size = Pointer.allocateSizeT();
handleError(LIB.clingo_configuration_value_get_size(pointer, key, size), "Error reading the configuration value size!");
Pointer<Byte> value = Pointer.allocateBytes(size.getInt());
handleError(LIB.clingo_configuration_value_get(pointer, key, value, size.getInt()), "Error reading the configuration value!");
return value.getCString();
}
示例3: toString
import org.bridj.Pointer; //导入方法依赖的package包/类
@Override
public String toString() {
Pointer<SizeT> size = Pointer.allocateSizeT();
handleRuntimeError(LIB.clingo_theory_atoms_atom_to_string_size(pointer, id, size), "Error reading to string size!");
Pointer<Byte> string = Pointer.allocateByte();
handleRuntimeError(LIB.clingo_theory_atoms_atom_to_string(pointer, id, string, size.getLong()), "Error reading theory atom string");
return string.getCString();
}
示例4: handleError
import org.bridj.Pointer; //导入方法依赖的package包/类
public static void handleError(boolean value, String message) throws ClingoException {
if (!value) {
Pointer<Byte> msg = LIB.clingo_error_message();
int error = LIB.clingo_error_code();
throw new ClingoException(EnumValue.valueOfInt(ErrorCode.class, error), msg.getCString(), message);
}
}
示例5: toString
import org.bridj.Pointer; //导入方法依赖的package包/类
@Override
public String toString() {
Pointer<SizeT> size = Pointer.allocateSizeT();
handleRuntimeError(LIB.clingo_theory_atoms_term_to_string_size(pointer, id, size), "Error reading to string size!");
Pointer<Byte> string = Pointer.allocateByte();
handleRuntimeError(LIB.clingo_theory_atoms_term_to_string(pointer, id, string, size.getLong()), "Error reading the theory term string");
return string.getCString();
}
示例6: toString
import org.bridj.Pointer; //导入方法依赖的package包/类
@Override
public String toString() {
Pointer<SizeT> size = Pointer.allocateSizeT();
handleRuntimeError(LIB.clingo_symbol_to_string_size(structObject, size), "Error reading the symbol string size!");
Pointer<Byte> string = Pointer.allocateBytes(size.getLong());
handleRuntimeError(LIB.clingo_symbol_to_string(structObject, string, size.getLong()), "Error reading the symbol string value!");
return string.getCString();
}
示例7: listString
import org.bridj.Pointer; //导入方法依赖的package包/类
public static List<String> listString(Pointer<Pointer<Byte>> data, long size) {
if (data == null) {
return null;
}
return new PointerList<String, Pointer<Byte>>(data, size) {
@Override
protected String getItem(Pointer<Byte> p) {
return p.getCString();
}
};
}
示例8: error
import org.bridj.Pointer; //导入方法依赖的package包/类
private static void error(Pointer<Pointer<clingo_control>> ctrl, String details) {
System.err.println(details);
Pointer<Byte> pmsg = LIB.clingo_error_message();
String msg = pmsg.getCString();
LIB.clingo_control_free(ctrl.get());
System.err.println("ERROR: " + msg);
System.exit(LIB.clingo_error_code());
}
示例9: getName
import org.bridj.Pointer; //导入方法依赖的package包/类
public String getName() {
Pointer<Byte> tmp = LIB.clingo_signature_name(pointer);
return tmp.getCString();
}
示例10: ground
import org.bridj.Pointer; //导入方法依赖的package包/类
public void ground(List<Part> parts, GroundCallback callback) throws ClingoException {
Pointer<ClingoLibrary.clingo_ground_callback_t> p_ground_callback = null;
if (callback != null) {
ClingoLibrary.clingo_ground_callback_t ground_callback = new ClingoLibrary.clingo_ground_callback_t() {
@Override
public boolean apply(Pointer<clingo_location> clocation, Pointer<Byte> cname, Pointer<Long> carguments, long carguments_size, Pointer<?> cdata, Pointer<ClingoLibrary.clingo_symbol_callback_t> csymbol_callback, Pointer<?> csymbol_callback_data) {
String name = cname.getCString();
Location loc = new Location(clocation.get());
List<Symbol> symbols = Symbol.list(carguments, carguments_size);
boolean result = true;
try {
callback.groundCallback(loc, name, symbols, (List<Symbol> symbols1) -> {
long v_size = size(symbols1);
if (v_size == 0) {
return;
}
Pointer<Long> v_symbols = Symbol.array(symbols1);
handleError((csymbol_callback.get().apply(v_symbols, v_size, csymbol_callback_data)), "Error symbol callback apply!");
});
} catch (ClingoException ex) {
result = false;
}
return result;
}
};
p_ground_callback = Pointer.getPointer(ground_callback);
}
Pointer<clingo_part> p_parts = Part.array(parts);
int partsSize = size(parts);
// ground the base part
handleError(LIB.clingo_control_ground(pointer, p_parts, partsSize, p_ground_callback, null), "Error ground the program");
}
示例11: getName
import org.bridj.Pointer; //导入方法依赖的package包/类
public String getName() throws ClingoException {
Pointer<Pointer<Byte>> name = Pointer.allocatePointer(Byte.class);
handleError(LIB.clingo_symbol_name(structObject, name), "Error reading the symbol name!");
return name.getCString();
}
示例12: printModel
import org.bridj.Pointer; //导入方法依赖的package包/类
private static void printModel(Pointer<Pointer<clingo_control>> ctrl, Pointer<Pointer<clingo_model>> model) {
Set<String> result = new HashSet<>(RESULTS);
int show = (int) (clingo_show_type.clingo_show_type_shown.value);
Pointer<SizeT> atoms_n = Pointer.allocateSizeT();
// determine the number of (shown) symbols in the model
if (!LIB.clingo_model_symbols_size(model.get(), show, atoms_n)) {
error(ctrl, "Error create symbol size");
}
// allocate required memory to hold all the symbols
Pointer<Long> atoms = Pointer.allocateLongs(atoms_n.getLong());
// retrieve the symbols in the model
if (!LIB.clingo_model_symbols(model.get(), show, atoms, atoms_n.getLong())) {
error(ctrl, "Error create symbol symbols");
}
System.out.println("Model: ");
for (int i = 0; i < atoms_n.getLong(); i++) {
Long atom = atoms.get(i);
// determine size of the string representation of the next symbol in the model
Pointer<SizeT> size = Pointer.allocateSizeT();
LIB.clingo_symbol_to_string_size(atom, size);
// allocate required memory to hold the symbol's string
Pointer<Byte> string = Pointer.allocateBytes(size.getLong());
// retrieve the symbol's string
if (!LIB.clingo_symbol_to_string(atom, string, size.getLong())) {
error(ctrl, "Error symbol to string");
}
String st = string.getCString();
System.out.print(st);
Assert.assertTrue("Atom " + st + " does not exists in the result set", result.remove(st));
System.out.print(" -> ");
Pointer<Pointer<Long>> arguments = Pointer.allocatePointer(Long.class);
Pointer<SizeT> arguments_size = Pointer.allocateSizeT();
LIB.clingo_symbol_arguments(atom, arguments, arguments_size);
Pointer<Pointer<Byte>> name = Pointer.allocatePointer(Byte.class);
LIB.clingo_symbol_name(atom, name);
System.out.print("name=" + name.get().getCString());
System.out.print(",args=[");
Pointer<Integer> t = Pointer.allocateInt();
for (int a = 0; a < arguments_size.getLong(); a++) {
if (a > 0) {
System.out.print(",");
}
LIB.clingo_symbol_number(arguments.get().get(a), t);
System.out.print(t.get());
}
System.out.print("]");
System.out.println();
}
Assert.assertTrue("Result set is not empty!", result.isEmpty());
}