本文整理汇总了C++中USTR函数的典型用法代码示例。如果您正苦于以下问题:C++ USTR函数的具体用法?C++ USTR怎么用?C++ USTR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USTR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lilv_state_new_from_string
LILV_API
LilvState*
lilv_state_new_from_string(LilvWorld* world,
const LV2_URID_Map* map,
const char* str)
{
if (!str) {
return NULL;
}
SerdNode base = SERD_NODE_NULL;
SerdEnv* env = serd_env_new(&base);
SordModel* model = sord_new(world->world, SORD_SPO|SORD_OPS, false);
SerdReader* reader = sord_new_reader(model, env, SERD_TURTLE, NULL);
set_prefixes(env);
serd_reader_read_string(reader, USTR(str));
SordNode* o = sord_new_uri(world->world, USTR(LV2_PRESETS__Preset));
SordNode* s = sord_get(model, NULL, world->uris.rdf_a, o, NULL);
LilvState* state = new_state_from_model(world, map, model, s, NULL);
sord_node_free(world->world, s);
sord_node_free(world->world, o);
serd_reader_free(reader);
sord_free(model);
serd_env_free(env);
return state;
}
示例2: sizeof
static uchar *hlc_resolve_symbol( void *addr, uchar *out, int *outSize ) {
#ifdef _WIN32
static HANDLE stack_process_handle = NULL;
DWORD64 index;
IMAGEHLP_LINEW64 line;
struct {
SYMBOL_INFOW sym;
uchar buffer[256];
} data;
data.sym.SizeOfStruct = sizeof(data.sym);
data.sym.MaxNameLen = 255;
if( !stack_process_handle ) {
stack_process_handle = GetCurrentProcess();
SymSetOptions(SYMOPT_LOAD_LINES);
SymInitialize(stack_process_handle,NULL,TRUE);
}
if( SymFromAddrW(stack_process_handle,(DWORD64)(int_val)addr,&index,&data.sym) ) {
DWORD offset = 0;
line.SizeOfStruct = sizeof(line);
line.FileName = USTR("\\?");
line.LineNumber = 0;
SymGetLineFromAddrW64(stack_process_handle, (DWORD64)(int_val)addr, &offset, &line);
*outSize = usprintf(out,*outSize,USTR("%s(%s:%d)"),data.sym.Name,wcsrchr(line.FileName,'\\')+1,(int)line.LineNumber);
return out;
}
#endif
return NULL;
}
示例3: osl_regex_impl
OSL_SHADEOP int
osl_regex_impl (void *sg_, const char *subject_, void *results, int nresults,
const char *pattern, int fullmatch)
{
ShaderGlobals *sg = (ShaderGlobals *)sg_;
ShadingContext *ctx = sg->context;
const std::string &subject (ustring::from_unique(subject_).string());
match_results<std::string::const_iterator> mresults;
const regex ®ex (ctx->find_regex (USTR(pattern)));
if (nresults > 0) {
std::string::const_iterator start = subject.begin();
int res = fullmatch ? regex_match (subject, mresults, regex)
: regex_search (subject, mresults, regex);
int *m = (int *)results;
for (int r = 0; r < nresults; ++r) {
if (r/2 < (int)mresults.size()) {
if ((r & 1) == 0)
m[r] = mresults[r/2].first - start;
else
m[r] = mresults[r/2].second - start;
} else {
m[r] = USTR(pattern).length();
}
}
return res;
} else {
return fullmatch ? regex_match (subject, regex)
: regex_search (subject, regex);
}
}
示例4: AdjustWindowRectEx
HL_PRIM wref *HL_NAME(ui_winlog_new)( const uchar *title, int width, int height ) {
HWND wnd, text;
RECT rc;
RECT dtop;
DWORD style = WS_SYSMENU | WS_OVERLAPPED | WS_CAPTION;
DWORD exstyle = 0;
wref *ref;
// SIZE
rc.left = 0;
rc.right = width;
rc.top = 0;
rc.bottom = height;
AdjustWindowRectEx(&rc, style, FALSE, exstyle);
GetWindowRect(GetDesktopWindow(),&dtop);
// WINDOW
wnd = CreateWindowEx(
exstyle,
CLASS_NAME,
title,
style,
(dtop.right - rc.right) / 2,
(dtop.bottom - rc.bottom) / 2,
rc.right - rc.left,
rc.bottom - rc.top,
GetActiveWindow(),
NULL,
GetModuleHandle(NULL),
NULL
);
// FONT
if( font == NULL ) {
LOGFONT f;
f.lfHeight = -8;
f.lfWidth = 0;
f.lfEscapement = 0;
f.lfOrientation = 0;
f.lfWeight = FW_NORMAL;
f.lfItalic = FALSE;
f.lfUnderline = FALSE;
f.lfStrikeOut = FALSE;
f.lfCharSet = DEFAULT_CHARSET;
f.lfOutPrecision = OUT_DEFAULT_PRECIS;
f.lfClipPrecision = 0;
f.lfQuality = DEFAULT_QUALITY;
f.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
wcscpy(f.lfFaceName,USTR("MS Sans Serif"));
font = CreateFontIndirect(&f);
}
// TEXT
text = CreateWindowEx(WS_EX_CLIENTEDGE,USTR("RICHEDIT20A"),USTR(""),ES_MULTILINE | ES_DISABLENOSCROLL | ES_READONLY | WS_VSCROLL | WS_VISIBLE | WS_CHILD,5,5,width - 10,height - 50,wnd,NULL,NULL,NULL);
SendMessage(text,WM_SETFONT,(WPARAM)font,TRUE);
SetProp(wnd,PTEXT,text);
SetTimer(wnd,0,1000,NULL); // prevent lock in ui_loop
ShowWindow(wnd,SW_SHOW);
ref = alloc_ref(wnd);
ref->width = width;
ref->height = height;
return ref;
}
示例5: CreateWindowEx
HL_PRIM wref *HL_NAME(ui_button_new)( wref *w, const uchar *txt, vclosure *callb ) {
HWND but = CreateWindowEx(0,USTR("BUTTON"),USTR(""),WS_VISIBLE | WS_CHILD,w->width - 80,w->height - 30,75,25,w->h,NULL,NULL,NULL);
wref *ref = alloc_ref(but);
w->width -= 80;
ref->callb = callb;
SendMessage(but,WM_SETFONT,(WPARAM)font,TRUE);
SetWindowText(but,txt);
return ref;
}
示例6: DrmKernel_NvDrmPlugin_onSaveRights
status_t DrmKernel_NvDrmPlugin_onSaveRights(int uniqueId,
const struct NV_DrmRights_st *drmRights, const char *rightsPath,
const char *contentId)
{
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - Entry");
ALOGV("uniqueId = %d", uniqueId);
ALOGV("rightsPath = '%s'", rightsPath);
ALOGV("contentId = '%s'", contentId);
status_t retVal = NV_DRM_ERROR_UNKNOWN;
SecureRecord record;
uint8_t *dataptr = (uint8_t *)drmRights->data->data;
record._key = contentId;
dataptr += strlen(contentId) +1;
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data));
record._keyId = dataptr;
dataptr += AES_BLOCK_SIZE;
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data));
record._contentKeySize = *dataptr << 8;
dataptr++;
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data));
record._contentKeySize += *dataptr;
dataptr++;
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data));
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - key size = %d", record._contentKeySize);
record._contentKey = USTR(dataptr);
dataptr += record._contentKeySize;
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data));
record._tag = USTR(dataptr);
record._tagSize = (unsigned int)drmRights->data->length - (dataptr - (uint8_t *)drmRights->data->data);
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data));
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - tag size = %d", record._tagSize);
ALOGV("record.key = %s", record._key);
ALOGV("record.contentKeySize = %d", record._contentKeySize);
ALOGV("record.tagSize = %d", record._tagSize);
if (insertRecord(&mDatabaseConnection, &record))
{
retVal = NV_NO_ERROR;
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights() - Rights saved");
}
else
ALOGE("DrmKernel_NvDrmPlugin_onSaveRights() - Unable to save rights");
ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - Exit (%d)", retVal);
return retVal;
}
示例7: HL_NAME
/**
request : 'db -> sql:string -> 'result
<doc>Executes the SQL request and returns its result</doc>
**/
HL_PRIM sqlite_result *HL_NAME(request)(sqlite_database *db, vbyte *sql ) {
sqlite_result *r;
const char *tl;
int i,j;
r = (sqlite_result*)hl_gc_alloc_finalizer(sizeof(sqlite_result));
r->finalize = HL_NAME(finalize_result);
r->db = db;
if( sqlite3_prepare16_v2(db->db, sql, -1, &r->r, &tl) != SQLITE_OK ) {
HL_NAME(error)(db->db, false);
}
if( *tl ) {
sqlite3_finalize(r->r);
hl_error("SQLite error: Cannot execute several SQL requests at the same time");
}
r->ncols = sqlite3_column_count(r->r);
r->names = (int*)hl_gc_alloc(sizeof(int)*r->ncols);
r->bools = (int*)hl_gc_alloc(sizeof(int)*r->ncols);
r->first = 1;
r->done = 0;
for(i=0;i<r->ncols;i++) {
int id = hl_hash_gen((uchar*)sqlite3_column_name16(r->r,i), true);
const char *dtype = sqlite3_column_decltype(r->r,i);
for(j=0;j<i;j++)
if( r->names[j] == id ) {
if( strcmp(sqlite3_column_name16(r->r,i), sqlite3_column_name16(r->r,j)) == 0 ) {
sqlite3_finalize(r->r);
hl_buffer *b = hl_alloc_buffer();
hl_buffer_str(b, USTR("SQLite error: Same field is two times in the request: "));
hl_buffer_str(b, (uchar*)sql);
hl_error_msg(hl_buffer_content(b, NULL));
} else {
hl_buffer *b = hl_alloc_buffer();
hl_buffer_str(b, USTR("SQLite error: Same field ids for: "));
hl_buffer_str(b, sqlite3_column_name16(r->r,i));
hl_buffer_str(b, USTR(" and "));
hl_buffer_str(b, sqlite3_column_name16(r->r,j));
sqlite3_finalize(r->r);
hl_error_msg(hl_buffer_content(b, NULL));
}
}
r->names[i] = id;
r->bools[i] = dtype?(strcmp(dtype,"BOOL") == 0):0;
}
// changes in an update/delete
if( db->last != NULL )
HL_NAME(finalize_request)(db->last, false);
db->last = r;
return db->last;
}
示例8: lilv_state_save
LILV_API
int
lilv_state_save(LilvWorld* world,
LV2_URID_Map* map,
LV2_URID_Unmap* unmap,
const LilvState* state,
const char* uri,
const char* dir,
const char* filename)
{
if (!filename || !dir || lilv_mkdir_p(dir)) {
return 1;
}
char* abs_dir = absolute_dir(dir);
char* const path = lilv_path_join(abs_dir, filename);
FILE* fd = fopen(path, "w");
if (!fd) {
LILV_ERRORF("Failed to open %s (%s)\n", path, strerror(errno));
free(abs_dir);
free(path);
return 4;
}
// FIXME: make parameter non-const?
if (state->dir && strcmp(state->dir, abs_dir)) {
free(state->dir);
((LilvState*)state)->dir = lilv_strdup(abs_dir);
}
// Create symlinks to files if necessary
lilv_state_make_links(state, abs_dir);
// Write state to Turtle file
SerdNode file = serd_node_new_file_uri(USTR(path), NULL, NULL, false);
SerdEnv* env = NULL;
SerdWriter* writer = ttl_file_writer(fd, &file, &env);
SerdNode node = uri ? serd_node_from_string(SERD_URI, USTR(uri)) : file;
int ret = lilv_state_write(
world, map, unmap, state, writer, (const char*)node.buf, dir);
serd_node_free(&file);
serd_writer_free(writer);
serd_env_free(env);
fclose(fd);
char* const manifest = lilv_path_join(abs_dir, "manifest.ttl");
add_state_to_manifest(state->plugin_uri, manifest, uri, path);
free(manifest);
free(abs_dir);
free(path);
return ret;
}
示例9: osl_split
OSL_SHADEOP int
osl_split (const char *str, ustring *results, const char *sep,
int maxsplit, int resultslen)
{
maxsplit = OIIO::clamp (maxsplit, 0, resultslen);
std::vector<std::string> splits;
Strutil::split (USTR(str).string(), splits, USTR(sep).string(), maxsplit);
int n = std::min (maxsplit, (int)splits.size());
for (int i = 0; i < n; ++i)
results[i] = ustring(splits[i]);
return n;
}
示例10: osl_endswith_iss
OSL_SHADEOP int
osl_endswith_iss (const char *s_, const char *substr_)
{
ustring substr (USTR(substr_));
size_t substr_len = substr.length();
if (substr_len == 0) // empty substr always matches
return 1;
ustring s (USTR(s_));
size_t s_len = s.length();
if (substr_len > s_len) // longer needle than haystack can't
return 0; // match (including empty s)
return strncmp (s.c_str()+s_len-substr_len, substr.c_str(), substr_len) == 0;
}
示例11: while
HL_PRIM ereg *regexp_regexp_new_options( vbyte *str, vbyte *opts ) {
ereg *r;
const char *error;
int err_offset;
int errorcode;
pcre16 *p;
uchar *o = (uchar*)opts;
int options = 0;
while( *o ) {
switch( *o++ ) {
case 'i':
options |= PCRE_CASELESS;
break;
case 's':
options |= PCRE_DOTALL;
break;
case 'm':
options |= PCRE_MULTILINE;
break;
case 'u':
options |= PCRE_UTF8;
break;
case 'g':
options |= PCRE_UNGREEDY;
break;
default:
return NULL;
}
}
p = pcre16_compile2((PCRE_SPTR16)str,options,&errorcode,&error,&err_offset,NULL);
if( p == NULL ) {
hl_buffer *b = hl_alloc_buffer();
hl_buffer_str(b,USTR("Regexp compilation error : "));
hl_buffer_cstr(b,error);
hl_buffer_str(b,USTR(" in "));
hl_buffer_str(b,(uchar*)str);
hl_error_msg(USTR("%s"),hl_buffer_content(b,NULL));
}
r = (ereg*)hl_gc_alloc_finalizer(sizeof(ereg));
r->finalize = regexp_finalize;
r->p = p;
r->nmatches = 0;
r->matched = 0;
pcre16_fullinfo(p,NULL,PCRE_INFO_CAPTURECOUNT,&r->nmatches);
r->nmatches++;
r->matches = (int*)malloc(sizeof(int) * 3 * r->nmatches);
limit.flags = PCRE_EXTRA_MATCH_LIMIT_RECURSION;
limit.match_limit_recursion = 3500; // adapted based on Windows 1MB stack size
return r;
}
示例12: defined
HL_PRIM vbyte *hl_sys_string() {
#if defined(HL_WIN) || defined(HL_CYGWIN) || defined(HL_MINGW)
return (vbyte*)USTR("Windows");
#elif defined(HL_GNUKBSD)
return (vbyte*)USTR("GNU/kFreeBSD");
#elif defined(HL_LINUX)
return (vbyte*)USTR("Linux");
#elif defined(HL_BSD)
return (vbyte*)USTR("BSD");
#elif defined(HL_MAC)
return (vbyte*)USTR("Mac");
#else
#error Unknow system string
#endif
}
示例13: osl_spline_dffdf
OSL_SHADEOP void osl_spline_dffdf(void *out, const char *spline_, void *x,
float *knots, int knot_count, int knot_arraylen)
{
const Spline::SplineBasis *spline = Spline::getSplineBasis(USTR(spline_));
Spline::spline_evaluate<Dual2<float>, float, Dual2<float>, float, true>
(spline, DFLOAT(out), *(float *)x, knots, knot_count, knot_arraylen);
}
示例14: osl_spline_dvdfdv
OSL_SHADEOP void osl_spline_dvdfdv(void *out, const char *spline_, void *x,
Vec3 *knots, int knot_count)
{
const Spline::SplineBasis *spline = Spline::getSplineBasis(USTR(spline_));
Spline::spline_evaluate<Dual2<Vec3>, Dual2<float>, Dual2<Vec3>, Vec3, true>
(spline, DVEC(out), DFLOAT(x), knots, knot_count);
}
示例15: osl_spline_dvdfv
OSL_SHADEOP void osl_spline_dvdfv(void *out, const char *spline_, void *x,
Vec3 *knots, int knot_count)
{
const Spline::SplineBasis *spline = Spline::getSplineBasis(USTR(spline_));
Spline::spline_evaluate<Vec3, float, Vec3, Vec3, false>
(spline, *(Vec3 *)out, *(float *)x, knots, knot_count);
}