本文整理汇总了C++中xstr函数的典型用法代码示例。如果您正苦于以下问题:C++ xstr函数的具体用法?C++ xstr怎么用?C++ xstr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
// TODO: This all should be wrapped into common class
QGuiApplication app(argc, argv);
ApplicationMain main(&app);
ConsoleApplication consoleApp;
if (main.hasApplicationCode())
consoleApp.setApplicationCode(main.applicationCode());
#ifdef GBERRY_DEBUG_QML_IMPORT_PATH
consoleApp.setImportPaths(QString(xstr(GBERRY_DEBUG_QML_IMPORT_PATH)));
#endif
#ifdef GBERRY_ASSETS_FIXED_ROOT_PATH
consoleApp.assets().setRootPath(QString(xstr(GBERRY_ASSETS_FIXED_ROOT_PATH)));
#endif
#ifdef GBERRY_FIXED_ROOT_PATH
consoleApp.currentApplication().setRootPath(QString(xstr(GBERRY_FIXED_ROOT_PATH)));
#endif
consoleApp.run("qrc:/main.qml");
return app.exec();
}
示例2: str
/** Parse UID to type and ID strings.
* Note that the returned values (type and id) must be freed once they are
* no longer used. Also verifies lengths of the type and id strings.
* @param uid UID to parse
* @param type upon return contains the type part of the UID
* @param id upon return contains the ID part
*/
void
Interface::parse_uid(const char *uid, std::string &type, std::string &id)
{
regex_t re;
int ec = 0;
// Requires in parse_uid()
#define str(s) #s
#define xstr(s) str(s)
if ((ec = regcomp(&re,
"^([a-zA-Z0-9]{1," xstr(__INTERFACE_TYPE_SIZE) "})::"
"([a-zA-Z0-9 _/\\.-]{1," xstr(__INTERFACE_ID_SIZE) "})$",
REG_EXTENDED)) != 0) {
char errbuf[1024];
regerror(ec, &re, errbuf, 1024);
throw Exception("Failed to created regular expression to parse UID (%s)",
errbuf);
}
regmatch_t matches[3];
if (regexec(&re, uid, 3, matches, 0) != 0) {
regfree(&re);
throw Exception("Failed to match UID %s, format error.", uid);
}
type.assign(&(uid[matches[1].rm_so]), matches[1].rm_eo - matches[1].rm_so);
id.assign(&(uid[matches[2].rm_so]), matches[2].rm_eo - matches[2].rm_so);
regfree(&re);
}
示例3: praat_showLogo
void praat_showLogo (bool autoPopDown) {
#if gtk
static const gchar *authors [3] = { "Paul Boersma", "David Weenink", nullptr };
GuiObject dialog = gtk_about_dialog_new ();
#define xstr(s) str(s)
#define str(s) #s
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (dialog), xstr (PRAAT_VERSION_STR));
gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (dialog), "Copyright © 1992–" xstr(PRAAT_YEAR) " by Paul Boersma and David Weenink");
gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (dialog), "GPL");
gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (dialog), "http://www.praat.org");
//gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (dialog), authors);
g_signal_connect (GTK_DIALOG (dialog), "response", G_CALLBACK (gtk_widget_destroy), nullptr);
gtk_dialog_run (GTK_DIALOG (dialog));
#else
if (theCurrentPraatApplication -> batch || ! theLogo.draw) return;
if (! theLogo.dia) {
int width = theLogo.width_mm / 25.4 * Gui_getResolution (nullptr);
int height = theLogo.height_mm / 25.4 * Gui_getResolution (nullptr);
theLogo.dia = GuiDialog_create (theCurrentPraatApplication -> topShell, 100, 100, width, height,
U"About", gui_cb_goAway, nullptr, 0);
theLogo.form = theLogo.dia;
theLogo.drawingArea = GuiDrawingArea_createShown (theLogo.form, 0, width, 0, height,
gui_drawingarea_cb_expose, gui_drawingarea_cb_click, nullptr, nullptr, nullptr, 0);
}
GuiThing_show (theLogo.form);
GuiThing_show (theLogo.dia);
#if motif
if (autoPopDown)
GuiAddTimeOut (2000, logo_timeOut, (XtPointer) nullptr);
#endif
#endif
}
示例4: main
int main(void)
{
printf("%" xstr(AA) "d\n", 1);
printf("%s\n", xstr(AFTERX(BUFSIZE)));
printf("%s\n", xstr(XAFTERX(BUFSIZE)));
return 0;
}
示例5: _desktopFile
QString ApplicationInfo::desktopFile()
{
QString dFile;
const QString _desktopFile(xstr(APP_PREFIX) "/share/applications/" xstr(APP_BIN_NAME) ".desktop");
QFile f(_desktopFile);
if(f.open(QIODevice::ReadOnly)) {
dFile = QString::fromUtf8(f.readAll());
}
return dFile;
}
示例6: _can_usage
static int _can_usage(void)
{
puts("usage: can <command> [arguments]");
puts("commands:");
puts("\tlist");
puts("\tsend ifnum id [B1 .. B8]");
puts("\tdump ifnum nb ms [id1[:mask1][,id2[:mask2], .. id"
xstr(SC_CAN_MAX_FILTERS) ":[mask" xstr(SC_CAN_MAX_FILTERS) "]]");
return 0;
}
示例7: main
int main(int argc, char **argv)
{
FILE *config;
trie_t trie;
char line[LINE_MAX], app[PATH_MAX], debugger[ARG_MAX], *c;
unsigned short perc;
unsigned short fields;
if (trieinit__pt(&trie) != 0) {
fprintf(stderr, "error: there was a problem with memory allocation.\n");
return 1;
}
if ((config = fopen(PRETRACECONF, "r"))) {
while (fgets(line, sizeof(line), config) != NULL) {
if (*line == '#' || *line == '\n')
continue; /* skip comments */
if ((c = strchr(line, ':')))
*c = ' ';
if ((fields = sscanf(line, "%" xstr(PATH_MAX) "s %[^\n]" xstr(ARG_MAX) "s", app, debugger)) < 1)
continue;
/* check for percentage */
if ((c = strchr(app, '%')))
*(c++) = '\0', perc = atoi(c);
else
perc = 100;
eprintf("debug: adding %s, debugger: %s, percentage: %u\n", app, debugger, perc);
if (trieadd__pt(app, perc, fields == 2 ? debugger : DEFAULT_DEBUGGER, &trie) != 0) {
fprintf(stderr, "error: there was a problem constructing the map structure.\n");
return 1;
}
}
fclose(config);
} else {
fprintf(stderr, "error: could not open configuration file %s.\n", PRETRACECONF);
return 1;
}
if (triewrite__pt(PRETRACEMAP, &trie) != 0) {
fprintf(stderr, "error: failed to create map file %s.\n", PRETRACEMAP);
return 1;
}
fprintf(stdout, "info: %s created successfully.\n", PRETRACEMAP);
triedestroy__pt(&trie);
return 0;
}
示例8: extype
char*
extype(int type)
{
switch (type)
{
case FLOATING:
return "double";
case STRING:
return "char*";
case UNSIGNED:
return xstr(uintmax_t);
}
return xstr(intmax_t);
}
示例9: praat_reportSystemProperties
void praat_reportSystemProperties () {
#define xstr(s) str(s)
#define str(s) #s
MelderInfo_open ();
MelderInfo_writeLine (U"System properties of this edition of Praat on this computer:\n");
#ifdef _WIN32
MelderInfo_writeLine (U"_WIN32 is \"" xstr (_WIN32) "\".");
#endif
#ifdef WINVER
MelderInfo_writeLine (U"WINVER is \"" xstr (WINVER) "\".");
#endif
#ifdef _WIN32_WINNT
MelderInfo_writeLine (U"_WIN32_WINNT is \"" xstr (_WIN32_WINNT) "\".");
#endif
#ifdef _WIN32_IE
MelderInfo_writeLine (U"_WIN32_IE is \"" xstr (_WIN32_IE) "\".");
#endif
#ifdef UNICODE
MelderInfo_writeLine (U"UNICODE is \"" xstr (UNICODE) "\".");
#endif
#ifdef _FILE_OFFSET_BITS
MelderInfo_writeLine (U"_FILE_OFFSET_BITS is \"" xstr (_FILE_OFFSET_BITS) "\".");
#endif
#ifdef macintosh
MelderInfo_writeLine (U"macintosh is \"" xstr (macintosh) "\".");
#endif
#ifdef linux
MelderInfo_writeLine (U"linux is \"" xstr (linux) "\".");
#endif
MelderInfo_close ();
}
示例10: __attribute__
/** More help text for this program, which doubles as the "official"
* documentation for the more subtle behaviours of this embedding.
*
* @param argv_zero How this program was invoked.
*
* @note Exits with status 1
*/
static void __attribute__((noreturn)) moreHelp(const char *argv_zero)
{
char spaces[strlen(argv_zero) + 1];
memset(spaces, (int)(' '), sizeof(spaces) -1);
spaces[sizeof(spaces) - 1] = (char)0;
printf(
"\n"
#if defined(__SURELYNX__)
"SureLynx "
#endif
PRODUCT_SHORTNAME " " PRODUCT_VERSION " - " PRODUCT_SUMMARY " " GPSEE_CURRENT_VERSION_STRING "\n"
"Copyright (c) 2007-2010 PageMail, Inc. All Rights Reserved.\n"
"\n"
"More Help: Additional information beyond basic usage.\n"
"\n"
"Verbosity\n"
" Verbosity is a measure of how much output GPSEE and " PRODUCT_SHORTNAME " send to stderr.\n"
" To request verbosity N, specify the d flag N times when invoking " PRODUCT_SHORTNAME ".\n"
" Requests in both the shebang (#!) and comment-embedded options is additive.\n"
"\n"
" If you invoke " PRODUCT_SHORTNAME " such that stderr is a tty, verbosity will be automatically\n"
" set to " xstr(GSR_MIN_TTY_VERBOSITY) ", unless your -d flags indicate an even higher level.\n"
"\n"
" Before your program runs, i.e. you are running script code with -c or a\n"
" preload script, verbosity will be set to " xstr(GSR_PREPROGRAM_TTY_VERBOSITY) " when stderr is a tty,\n"
" and " xstr(GSR_PREPROGRAM_NOTTY_VERBOSITY) " otherwise.\n"
"\n"
"Uncaught Exceptions\n"
" - Errors are output to stderr when verbosity >= " xstr(GPSEE_ERROR_OUTPUT_VERBOSITY) "\n"
" - Warnings are output to stderr when verbosity >= " xstr(GPSEE_ERROR_OUTPUT_VERBOSITY) "\n"
" - Stack is dumped when error output is enabled and stderr is a tty,\n"
" or verbosity >= " xstr(GSR_FORCE_STACK_DUMP_VERBOSITY) "\n"
" - Syntax errors will have their location within the source shown when stderr\n"
" is a tty, and verbosity >= " xstr(GPSEE_ERROR_POINTER_VERBOSITY) "\n"
"\n"
"GPSEE-core debugging\n"
" - The module system will generate debug output whe verbosity >= " xstr(GPSEE_MODULE_DEBUG_VERBOSITY) "\n"
" - The script precompilation sub-system will generate debug output\n"
" when verbosity >= " xstr(GPSEE_XDR_DEBUG_VERBOSITY) "\n"
"\n"
"Miscellaneous\n"
" - Exit codes 0 and 1 are reserved for 'success' and 'error' respectively.\n"
" Application programs can return any exit code they wish, from 0-127,\n"
" with either require('gpsee').exit() or by throwing a number literal.\n"
#if defined(SYSTEM_GSR)
" - Preload scripts will only be processed when " PRODUCT_SHORTNAME " is not invoked\n"
" as " SYSTEM_GSR ".\n"
#endif
"\n"
);
exit(1);
};
示例11: GetModelParams
void GetModelParams(int* p_nthreads, int* p_msize, int print)
{
int nthr = MAXTHREADS;
int msize = NUM;
int ncpu = getCPUCount();
if (ncpu < MAXTHREADS) {
nthr = ncpu;
}
// Making sure the matrix size and the nthreads are aligned
// If you want more robust threading implementation, take care
// of the matrix tails
while ((msize % nthr) != 0 )
nthr--;
// If kernel multiply0, set single threaded execution
if (MULTIPLY == multiply0)
nthr = 1;
if(p_nthreads != 0)
*p_nthreads = nthr;
if(p_msize != 0)
*p_msize = msize;
if(print)
{
printf("Threads #: %d %s\n",nthr,
#ifdef WIN32
"Win threads"
#else
"Pthreads"
#endif
); fflush(stdout);
printf("Matrix size: %d\n",msize); fflush(stdout);
printf("Using multiply kernel: %s\n", xstr(MULTIPLY)); fflush(stdout);
}
}
示例12: parse_cmd_free
int16_t parse_cmd_free(char *cmd, char *output, uint16_t len)
{
/* Docu March 2009: http://www.nongnu.org/avr-libc/user-manual/malloc.html
Stack size: RAMEND-SP
Heap size: __brkval-__heap_start
Space between stack and heap: SP-__brkval
Caution: __brkval is 0 when malloc was not called yet (use __heap_start instead)
Size of network packet frames is stored in NET_MAX_FRAME_LENGTH
*/
extern char *__brkval;
extern unsigned char __heap_start;
size_t f = (size_t)(__brkval ? (size_t)__brkval : (size_t)&__heap_start);
size_t allram = RAMEND;
/* we want an output like this:
free: 16234/32768
heap: 10234
net: 500
*/
return ECMD_FINAL(snprintf_P(output, len,
PSTR("free: %d/%d\nheap: %d\nnet: " xstr(NET_MAX_FRAME_LENGTH)),
SP-f, allram, f-(size_t)&__heap_start));
}
示例13: ZeroMemory
/** 有误 */
void xae::delete_temp_folder(string folder_name)
{
std::string folder = folder_name;
SHFILEOPSTRUCT FileOp;
ZeroMemory((void*)&FileOp,sizeof(SHFILEOPSTRUCT));
FileOp.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
FileOp.hNameMappings = NULL;
FileOp.hwnd = NULL;
FileOp.lpszProgressTitle = NULL;
FileOp.pFrom = folder.c_str();
FileOp.pTo = NULL;
FileOp.wFunc = FO_DELETE;
SHFileOperation(&FileOp);
XStringFunc xstr(folder_name);
xstr.ToUpper();
folder_name = xstr.GetString();
for(vector<string>::iterator it = m_szTmpFolders.begin(); it != m_szTmpFolders.end(); it++)
{
if((*it) == folder_name)
{
m_szTmpFolders.erase(it);
return;
}
}
return;
}
示例14: main
main( void)
{
fputs( "started\n", stderr);
/* 24.1: */
#define str( a) # a
assert( strcmp( str( a+b), "a+b") == 0);
/* 24.2: White spaces between tokens of operand are converted to one space.
*/
assert( strcmp( str( ab /* comment */ +
cd ), "ab + cd") == 0);
/* 24.3: \ is inserted before \ and " in or surrounding literals and no
other character is inserted to anywhere. */
assert( strcmp( str( '"' + "' \""), "'\"' + \"' \\\"\"") == 0);
/* 24.4: Line splicing by <backslash><newline> is done prior to token
parsing. */
assert( strcmp( str( "ab\
c"), "\"abc\"") == 0);
/* 24.5: Token separator inserted by macro expansion should be removed.
(Meanwhile, tokens should not be merged. See 21.2.) */
#define xstr( a) str( a)
#define f(a) a
assert( strcmp( xstr( x-f(y)), "x-y") == 0);
fputs( "success\n", stderr);
return 0;
}
示例15: aux_fields1
static int aux_fields1(void)
{
static const char sam[] = "data:"
"@SQ\tSN:one\tLN:1000\n"
"@SQ\tSN:two\tLN:500\n"
"r1\t0\tone\t500\t20\t8M\t*\t0\t0\tATGCATGC\tqqqqqqqq\tXA:A:k\tXi:i:37\tXf:f:" xstr(PI) "\tXd:d:" xstr(E) "\tXZ:Z:" HELLO "\tXH:H:" BEEF "\tXB:B:c,-2,0,+2\tZZ:i:1000000\n";
// Canonical form of the alignment record above, as output by sam_format1()
static const char r1[] = "r1\t0\tone\t500\t20\t8M\t*\t0\t0\tATGCATGC\tqqqqqqqq\tXA:A:k\tXi:i:37\tXf:f:3.14159\tXd:d:2.71828\tXZ:Z:" HELLO "\tXH:H:" BEEF "\tXB:B:c,-2,0,2\tZZ:i:1000000";
samFile *in = sam_open(sam, "r");
bam_hdr_t *header = sam_hdr_read(in);
bam1_t *aln = bam_init1();
uint8_t *p;
uint32_t n;
kstring_t ks = { 0, 0, NULL };
if (sam_read1(in, header, aln) >= 0) {
if ((p = check_bam_aux_get(aln, "XA", 'A')) && bam_aux2A(p) != 'k')
fail("XA field is '%c', expected 'k'", bam_aux2A(p));
if ((p = check_bam_aux_get(aln, "Xi", 'C')) && bam_aux2i(p) != 37)
fail("Xi field is %d, expected 37", bam_aux2i(p));
if ((p = check_bam_aux_get(aln, "Xf", 'f')) && fabs(bam_aux2f(p) - PI) > 1E-6)
fail("Xf field is %.12f, expected pi", bam_aux2f(p));
if ((p = check_bam_aux_get(aln, "Xd", 'd')) && fabs(bam_aux2f(p) - E) > 1E-6)
fail("Xf field is %.12f, expected e", bam_aux2f(p));
if ((p = check_bam_aux_get(aln, "XZ", 'Z')) && strcmp(bam_aux2Z(p), HELLO) != 0)
fail("XZ field is \"%s\", expected \"%s\"", bam_aux2Z(p), HELLO);
if ((p = check_bam_aux_get(aln, "XH", 'H')) && strcmp(bam_aux2Z(p), BEEF) != 0)
fail("XH field is \"%s\", expected \"%s\"", bam_aux2Z(p), BEEF);
// TODO Invent and use bam_aux2B()
if ((p = check_bam_aux_get(aln, "XB", 'B')) && ! (memcmp(p, "Bc", 2) == 0 && (memcpy(&n, p+2, 4), n) == 3 && memcmp(p+6, "\xfe\x00\x02", 3) == 0))
fail("XB field is %c,..., expected c,-2,0,+2", p[1]);
if ((p = check_bam_aux_get(aln, "ZZ", 'I')) && bam_aux2i(p) != 1000000)
fail("ZZ field is %d, expected 1000000", bam_aux2i(p));
if (sam_format1(header, aln, &ks) < 0)
fail("can't format record");
if (strcmp(ks.s, r1) != 0)
fail("record formatted incorrectly: \"%s\"", ks.s);
free(ks.s);
}
else fail("can't read record");
bam_destroy1(aln);
bam_hdr_destroy(header);
sam_close(in);
return 1;
}