Ejemplo n.º 1
0
unsigned int lg_read_window(
  LG_HDECODER hDec,
  const char* bufStart,
  const char* bufEnd,
  uint64_t dataOffset,
  const LG_Window* inner,
  const char* encoding,
  size_t preContext,
  size_t postContext,
  int32_t** characters,
  size_t** offsets,
  size_t* clen,
  LG_Window* decodedHit,
  LG_Error** err)
{
  return trapWithRetval(
    [=](){
      return readWindow(
        hDec->Factory,
        bufStart, bufEnd, dataOffset, inner, encoding,
        preContext, postContext, characters, offsets, clen, decodedHit
      );
    },
    0,
    err
  );
}
Ejemplo n.º 2
0
unsigned int lg_hit_context(
  LG_HDECODER hDec,
  const char* bufStart,
  const char* bufEnd,
  uint64_t dataOffset,
  const LG_Window* inner,
  const char* encoding,
  size_t windowSize,
  uint32_t replacement,
  const char** utf8,
  LG_Window* outer,
  LG_Window* decodedHit,
  LG_Error** err)
{
  return trapWithRetval(
    [=]() {
      return hitContext(
        hDec->Factory,
        bufStart, bufEnd, dataOffset, inner, encoding,
        windowSize, replacement, utf8, outer, decodedHit
      );
    },
    0,
    err
  );
}
Ejemplo n.º 3
0
int lg_add_pattern_list(LG_HFSM hFsm,
                        LG_HPATTERNMAP hMap,
                        const char* patterns,
                        const char* source,
                        const char** defaultEncodings,
                        unsigned int defaultEncodingsNum,
                        const LG_KeyOptions* defaultOptions,
                        LG_Error** err)
{
  LG_Error* in_err = nullptr;

  int ret = trapWithRetval(
    [hFsm, hMap, patterns, source, defaultEncodings, defaultEncodingsNum, defaultOptions, &in_err]() {
      return addPatternList(hFsm, hMap, patterns, source, defaultEncodings, defaultEncodingsNum, defaultOptions, &in_err);
    },
    -1,
    err
  );

  if (err) {
    if (in_err) {
      if (*err) {
        // append the error from addPatternList to the chain
        in_err->Next = *err;
      }
      *err = in_err;
    }
  }

  return ret;
}
Ejemplo n.º 4
0
LG_HPROGRAM lg_create_program(LG_HFSM hFsm,
                              const LG_ProgramOptions* options)
{
  return trapWithRetval(
    [hFsm,options](){ return create_program(hFsm, options); },
    nullptr
  );
}
Ejemplo n.º 5
0
uint64_t lg_search_resolve(LG_HCONTEXT hCtx,
                       const char* bufStart,
                       const char* bufEnd,
                       const uint64_t startOffset,
                       void* userData,
                       LG_HITCALLBACK_FN callbackFn)
{
  return trapWithRetval(std::bind(&VmInterface::searchResolve, hCtx->Impl, (const byte*) bufStart, (const byte*) bufEnd, startOffset, callbackFn, userData), std::numeric_limits<uint64_t>::max());
}
Ejemplo n.º 6
0
int lg_get_byte_transform_id(const char* const name) {
  return trapWithRetval(
    [name](){
      return find_trans_id(
        std::begin(LG_BYTE_TRANSFORMS),
        std::end(LG_BYTE_TRANSFORMS),
        name
      );
    },
    -1
  );
}
Ejemplo n.º 7
0
int lg_get_encoding_id(const char* const name) {
  return trapWithRetval(
    [name](){
      return find_trans_id(
        std::begin(LG_ENCODINGS),
        std::end(LG_ENCODINGS),
        name
      );
    },
    -1
  );
}
Ejemplo n.º 8
0
LG_HCONTEXT lg_create_context(LG_HPROGRAM hProg,
                              const LG_ContextOptions* options)
{
  const uint64_t
    begin = options ? options->TraceBegin : std::numeric_limits<uint64_t>::max(),
    end = options ? options->TraceEnd : std::numeric_limits<uint64_t>::max();

  return trapWithRetval(
    [hProg,begin,end](){ return create_context(hProg, begin, end); },
    nullptr
  );
}
Ejemplo n.º 9
0
int lg_get_byte_transform_id(const char* const name) {
  return trapWithRetval(
    [name](){
      return find_trans_id(
        LG_BYTE_TRANSFORMS,
        LG_BYTE_TRANSFORMS +
          sizeof(LG_BYTE_TRANSFORMS)/sizeof(LG_TRANS),
        name
      );
    },
    -1
  );
}
Ejemplo n.º 10
0
int lg_get_encoding_id(const char* const name) {
  return trapWithRetval(
    [name](){
      return find_trans_id(
        LG_ENCODINGS,
        LG_ENCODINGS +
          sizeof(LG_ENCODINGS)/sizeof(LG_TRANS),
        name
      );
    },
    -1
  );
}
Ejemplo n.º 11
0
int lg_add_pattern(LG_HFSM hFsm,
                   LG_HPATTERNMAP hMap,
                   LG_HPATTERN hPattern,
                   const char* encoding,
                   LG_Error** err)
{
  return trapWithRetval(
    [hFsm,hMap,hPattern,encoding]() {
      return addPattern(hFsm, hMap, hPattern, encoding);
    },
    -1,
    err
  );
}
Ejemplo n.º 12
0
LG_HPROGRAM lg_read_program(void* buffer, int size) {
  return trapWithRetval(
    [buffer,size](){ return read_program(buffer, size); },
    nullptr
  );
}
Ejemplo n.º 13
0
LG_HFSM lg_create_fsm(unsigned int numFsmStateSizeHint) {
  return trapWithRetval(
    [numFsmStateSizeHint](){ return create_fsm(numFsmStateSizeHint); },
    nullptr
  );
}