当前位置: 首页>>代码示例>>Java>>正文


Java Pointer.pointerToCString方法代码示例

本文整理汇总了Java中org.bridj.Pointer.pointerToCString方法的典型用法代码示例。如果您正苦于以下问题:Java Pointer.pointerToCString方法的具体用法?Java Pointer.pointerToCString怎么用?Java Pointer.pointerToCString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bridj.Pointer的用法示例。


在下文中一共展示了Pointer.pointerToCString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: add

import org.bridj.Pointer; //导入方法依赖的package包/类
public void add(String name, List<String> parameters, String program) throws ClingoException {

        Pointer<Byte> tmp_name = Pointer.pointerToCString(name);
        Pointer<Byte> tmp_program = Pointer.pointerToCString(program);

        Pointer<Pointer<Byte>> tmp_params = stringArray(parameters);
        int tmp_size = size(parameters);

        // add a logic program to the base part
        handleError(LIB.clingo_control_add(pointer, tmp_name, tmp_params, tmp_size, tmp_program), "Error add the program to controller");
    }
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:12,代码来源:Clingo.java

示例2: get

import org.bridj.Pointer; //导入方法依赖的package包/类
public Statistics get(String name) {
    Pointer<Byte> tmp = Pointer.pointerToCString(name);
    Pointer<Long> subkey = Pointer.allocateLong();
    handleRuntimeError(LIB.clingo_statistics_map_at(pointer, key, tmp, subkey), "Error reading the statistic item in map by" + tmp + " key!");
    return new Statistics(pointer, subkey.getLong());
}
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:7,代码来源:StatisticsMap.java

示例3: controlTest

import org.bridj.Pointer; //导入方法依赖的package包/类
@Test
public void controlTest() {

    Pointer<Byte> name = Pointer.pointerToCString("base");
    Pointer<Byte> program = Pointer.pointerToCString(PROGRAM3);

    clingo_part p = new clingo_part();
    p.name(name);
    p.params(null);
    p.size(0);

    Pointer<clingo_part> parts = Pointer.allocate(clingo_part.class);
    parts.set(p);

    Pointer<Integer> major = Pointer.allocateInt();
    Pointer<Integer> minor = Pointer.allocateInt();
    Pointer<Integer> revision = Pointer.allocateInt();
    LIB.clingo_version(major, minor, revision);
    System.out.println("Clingo library version: " + major.getInt() + "." + minor.getInt() + "." + revision.getInt());
    
    // create a control object and pass command line arguments
    Pointer<Pointer<clingo_control>> control = Pointer.allocatePointer(clingo_control.class);
    if (!LIB.clingo_control_new(null, 0, null, null, 20, control)) {
        error(control, "Could not create controller");
    }

    long startTime = System.currentTimeMillis();

    // add a logic program to the base part
    if (!LIB.clingo_control_add(control.get(), name, null, 0, program)) {
        error(control, "Error add the program to controller");
    }

    // ground the base part
    if (!LIB.clingo_control_ground(control.get(), parts, 1, null, null)) {
        error(control, "Error ground the program");
    }

    if (!solve(control)) {
        error(control, "Error solving the program");
    }

    float endTime = (System.currentTimeMillis() - startTime) / 1000f;
    System.out.println("Time:" + String.format(TIME_FORMAT, endTime) + "s");
    
    LIB.clingo_control_free(control.get());
}
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:48,代码来源:ControlTest.java


注:本文中的org.bridj.Pointer.pointerToCString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。