Ejemplo n.º 1
0
static char* ExtractStringShapedJson (TRI_shaper_t* shaper,
                                      TRI_shaped_json_t const* document,
                                      char const* path) {
  TRI_json_t* json;
  TRI_shape_pid_t pid;
  TRI_shape_t const* shape;
  TRI_shaped_json_t shaped;
  bool ok;
  char* result;

  pid = shaper->findAttributePathByName(shaper, path);

  ok = TRI_ExtractShapedJsonVocShaper(shaper, document, 0, pid, &shaped, &shape);

  if (! ok || shape == NULL) {
    return NULL;
  }

  json = TRI_JsonShapedJson(shaper, &shaped);

  if (json == NULL) {
    return NULL;
  }

  if (json->_type != TRI_JSON_STRING) {
    return NULL;
  }

  result = TRI_DuplicateString2(json->_value._string.data, json->_value._string.length);

  TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);

  return result;
}
Ejemplo n.º 2
0
char* TRI_ParseQueryAllocString2 (TRI_query_template_t* const template_,
                                  const char* string, 
                                  const size_t length) {
  // do string part duplication
  char* copy = TRI_DuplicateString2(string, length);

  // store pointer to copy and return it
  return TRI_ParseQueryRegisterString(template_, copy);
}