• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ prefix函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中prefix函数的典型用法代码示例。如果您正苦于以下问题:C++ prefix函数的具体用法?C++ prefix怎么用?C++ prefix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了prefix函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: moveFilesProc


//.........这里部分代码省略.........
     }
     chdir(user.home);
     fnames->dirtarget = True;
     toend = strlen(to);
     if (to[toend-1] != '/')
     {
	 to[toend++] = '/';
	 to[toend] = 0;
     }
 }
 else if (fnames->n_sel == 1)  fnames->dirtarget = False;
 else
 {
     error(fnames->shell, op_name, "Target for multiple files must be a folder");
     umountDev(devto, False);
     umountDev(devfrom, False);
     freeSelFiles(fnames);
     return;
 }
 if (!fnames->first)  zzz();
 XTFREE(fnames->target);
 fnames->target = XtNewString(to);
 for (i = fnames->first; i < fnames->n_sel; i++)
 {
     name = fnames->names[i];
     if (fnames->op != LINK && (!strcmp(name, ".") || !strcmp(name, "..")))
     {
	 error(fnames->shell, "Cannot move or copy . or ..", NULL);
	 continue;
     }
     strcpy(from+fromend, name);
     if (fnames->dirtarget)
     {
	 if (fnames->op != LINK && prefix(from, to))
	 {
	     String err_str, format = "Cannot move or copy %s to";
	     err_str = (String) XtMalloc((strlen(format) + strlen(from)) * sizeof(char));
	     sprintf(err_str, format, from);
	     error(fnames->shell, err_str, to);
	     XTFREE(err_str);
	     umountDev(devto, False);
	     umountDev(devfrom, False);
	     freeSelFiles(fnames);
	     wakeUp();
	     return;
	 }
	 strcpy(to+toend, name);
     }
     if (!(lstat(to, &tolstats)))
     {
	 fnames->first = i;
	 is_dir = False;
	 if (!(stat(to, &tostats)))
	 {
	     if (S_ISDIR(tostats.st_mode))
		 is_dir = True;
	     if (!stat(from, &frstats) && tostats.st_ino == frstats.st_ino)
	     {
		 error(fnames->shell, op_name, "Source and destination are identical");
		 umountDev(devto, False);
		 umountDev(devfrom, False);
		 freeSelFiles(fnames);
		 wakeUp();
		 return;
	     }
	 }
开发者ID:ThomasAdam,项目名称:moxfm,代码行数:67,代码来源:FmFwActions.c


示例2: folder

void BlockDataManagerConfig::parseArgs(int argc, char* argv[])
{
   /***
   --testnet: run db against testnet bitcoin network

   --regtest: run db against regression test network

   --rescan: delete all processed history data and rescan blockchain from the
   first block

   --rebuild: delete all DB data and build and scan from scratch

   --rescanSSH: delete balance and txcount data and rescan it. Much faster than
   rescan or rebuild.

   --datadir: path to the operation folder

   --dbdir: path to folder containing the database files. If empty, a new db
   will be created there

   --satoshi-datadir: path to blockchain data folder (blkXXXXX.dat files)

   --ram_usage: defines the ram use during scan operations. 1 level averages
   128MB of ram (without accounting the base amount, ~400MB). Defaults at 4.
   Can't be lower than 1. Can be changed in between processes

   --thread-count: defines how many processing threads can be used during db
   builds and scans. Defaults to maximum available CPU threads. Can't be
   lower than 1. Can be changed in between processes

   --zcthread-count: defines the maximum number on threads the zc parser can
   create for processing incoming transcations from the network node

   --db-type: sets the db type:
   DB_BARE: tracks wallet history only. Smallest DB.
   DB_FULL: tracks wallet history and resolves all relevant tx hashes.
   ~750MB DB at the time of 0.95 release. Default DB type.
   DB_SUPER: tracks all blockchain history. XXL DB (100GB+).
   Not implemented yet

   db type cannot be changed in between processes. Once a db has been built
   with a certain type, it will always function according to that type.
   Specifying another type will do nothing. Build a new db to change type.

   --cookie: create a cookie file holding a random authentication key to allow
   local clients to make use of elevated commands, like shutdown.

   --fcgi-port: sets the DB listening port.

   --clear-mempool: delete all zero confirmation transactions from the DB.

   ***/

   try
   {
      //parse cli args
      map<string, string> args;
      for (int i = 1; i < argc; i++)
      {
         //check prefix
         if (strlen(argv[i]) < 2)
            throw DbErrorMsg("invalid CLI arg");

         string prefix(argv[i], 2);
         if (prefix != "--")
            throw DbErrorMsg("invalid CLI arg");

         //string prefix and tokenize
         string line(argv[i] + 2);
         auto&& argkeyval = getKeyValFromLine(line, '=');
         args.insert(make_pair(
            argkeyval.first, stripQuotes(argkeyval.second)));
      }

      processArgs(args, true);

      //figure out datadir
      auto argIter = args.find("datadir");
      if (argIter != args.end())
      {
         dataDir_ = argIter->second;
         args.erase(argIter);
      }
      else
      {
         if (!testnet_ && !regtest_)
            dataDir_ = defaultDataDir_;
         else if (!regtest_)
            dataDir_ = defaultTestnetDataDir_;
         else
            dataDir_ = defaultRegtestDataDir_;
      }

      expandPath(dataDir_);

      //get datadir
      auto configPath = dataDir_;
      appendPath(configPath, "armorydb.conf");

      if (DBUtils::fileExists(configPath, 2))
//.........这里部分代码省略.........
开发者ID:yurivict,项目名称:BitcoinArmory,代码行数:101,代码来源:BlockDataManagerConfig.cpp


示例3: parsePrefix

QString IrcMessagePrivate::host() const
{
    if (m_host.isNull())
        parsePrefix(prefix(), &m_nick, &m_ident, &m_host);
    return m_host;
}
开发者ID:vitalyster,项目名称:libcommuni-gbp,代码行数:6,代码来源:ircmessage_p.cpp


示例4: while

PRBool nsDefaultURIFixup::MakeAlternateURI(nsIURI *aURI)
{
    if (!mPrefBranch)
    {
        return PR_FALSE;
    }
    PRBool makeAlternate = PR_TRUE;
    mPrefBranch->GetBoolPref("browser.fixup.alternate.enabled", &makeAlternate);
    if (!makeAlternate)
    {
        return PR_FALSE;
    }

    // Code only works for http. Not for any other protocol including https!
    PRBool isHttp = PR_FALSE;
    aURI->SchemeIs("http", &isHttp);
    if (!isHttp) {
        return PR_FALSE;
    }

    // Security - URLs with user / password info should NOT be fixed up
    nsCAutoString userpass;
    aURI->GetUserPass(userpass);
    if (!userpass.IsEmpty()) {
        return PR_FALSE;
    }

    nsCAutoString oldHost;
    nsCAutoString newHost;
    aURI->GetHost(oldHost);

    // Count the dots
    PRInt32 numDots = 0;
    nsReadingIterator<char> iter;
    nsReadingIterator<char> iterEnd;
    oldHost.BeginReading(iter);
    oldHost.EndReading(iterEnd);
    while (iter != iterEnd) {
        if (*iter == '.')
            numDots++;
        ++iter;
    }


    nsresult rv;

    // Get the prefix and suffix to stick onto the new hostname. By default these
    // are www. & .com but they could be any other value, e.g. www. & .org

    nsCAutoString prefix("www.");
    nsXPIDLCString prefPrefix;
    rv = mPrefBranch->GetCharPref("browser.fixup.alternate.prefix", getter_Copies(prefPrefix));
    if (NS_SUCCEEDED(rv))
    {
        prefix.Assign(prefPrefix);
    }

    nsCAutoString suffix(".com");
    nsXPIDLCString prefSuffix;
    rv = mPrefBranch->GetCharPref("browser.fixup.alternate.suffix", getter_Copies(prefSuffix));
    if (NS_SUCCEEDED(rv))
    {
        suffix.Assign(prefSuffix);
    }
    
    if (numDots == 0)
    {
        newHost.Assign(prefix);
        newHost.Append(oldHost);
        newHost.Append(suffix);
    }
    else if (numDots == 1)
    {
        if (!prefix.IsEmpty() &&
                oldHost.EqualsIgnoreCase(prefix.get(), prefix.Length())) {
            newHost.Assign(oldHost);
            newHost.Append(suffix);
        }
        else if (!suffix.IsEmpty()) {
            newHost.Assign(prefix);
            newHost.Append(oldHost);
        }
        else
        {
            // Do nothing
            return PR_FALSE;
        }
    }
    else
    {
        // Do nothing
        return PR_FALSE;
    }

    if (newHost.IsEmpty()) {
        return PR_FALSE;
    }

    // Assign the new host string over the old one
    aURI->SetHost(newHost);
//.........这里部分代码省略.........
开发者ID:lofter2011,项目名称:Icefox,代码行数:101,代码来源:nsDefaultURIFixup.cpp


示例5: ut_start

/*
 * ut_start -- initialize unit test framework, indicate test started
 */
void
ut_start(const char *file, int line, const char *func,
    int argc, char * const argv[], const char *fmt, ...)
{
	va_list ap;
	int saveerrno = errno;
	char logname[MAXLOGNAME];
	char *logsuffix;

	va_start(ap, fmt);

	if (getenv("UNITTEST_NO_SIGHANDLERS") == NULL)
		ut_register_sighandlers();

	if (getenv("UNITTEST_QUIET") != NULL)
		Quiet++;

	Testname = getenv("UNITTEST_NAME");

	if ((logsuffix = getenv("UNITTEST_NUM")) == NULL)
		logsuffix = "";

	snprintf(logname, MAXLOGNAME, "out%s.log", logsuffix);
	if ((Outfp = fopen(logname, "w")) == NULL) {
		perror(logname);
		exit(1);
	}

	snprintf(logname, MAXLOGNAME, "err%s.log", logsuffix);
	if ((Errfp = fopen(logname, "w")) == NULL) {
		perror(logname);
		exit(1);
	}

	snprintf(logname, MAXLOGNAME, "trace%s.log", logsuffix);
	if ((Tracefp = fopen(logname, "w")) == NULL) {
		perror(logname);
		exit(1);
	}

	setlinebuf(Outfp);
	setlinebuf(Errfp);
	setlinebuf(Tracefp);
	setlinebuf(stdout);

	prefix(file, line, func, 0);
	vout(OF_LOUD|OF_NAME, "START", fmt, ap);

	out(OF_NONL, 0, "     args:");
	for (int i = 0; i < argc; i++)
		out(OF_NONL, " %s", argv[i]);
	out(0, NULL);

	va_end(ap);

	record_open_files();

	long long sc = sysconf(_SC_PAGESIZE);
	if (sc < 0)
		abort();
	Ut_pagesize = (unsigned long)sc;

	errno = saveerrno;
}
开发者ID:AmesianX,项目名称:nvml,代码行数:67,代码来源:ut.c


示例6: init_gcu

/*
 * Prepare "curses" for use by the file "z-term.c"
 *
 * Installs the "hook" functions defined above, and then activates
 * the main screen "term", which clears the screen and such things.
 *
 * Someone should really check the semantics of "initscr()"
 */
errr init_gcu(int argc, char **argv)
{
	int i;
	int rows, cols, y, x;
	int next_win = 0;
	bool graphics = TRUE;

	/* Initialize info about terminal capabilities */
	termtype = getenv("TERM");
	loaded_terminfo = termtype && tgetent(0, termtype) == 1;

	/* Parse args */
	for (i = 1; i < argc; i++) {
		if (prefix(argv[i], "-b"))
			use_big_screen = TRUE;
		else if (prefix(argv[i], "-B"))
			bold_extended = TRUE;
		else if (prefix(argv[i], "-a"))
			graphics = FALSE;
		else
			plog_fmt("Ignoring option: %s", argv[i]);
	}

	if (graphics) {
		ctrl_char[CTRL_WALL] = ' ';
		ctrl_attr[CTRL_ORE] = A_REVERSE;
		ctrl_attr[CTRL_WALL] = A_REVERSE;
		ctrl_attr[CTRL_ROCK] = A_REVERSE;
	}

	/* Extract the normal keymap */
	keymap_norm_prepare();

	/* We do it like this to prevent a link error with curseses that
	 * lack ESCDELAY.
	 */
	if (!getenv("ESCDELAY"))
		putenv("ESCDELAY=20");

	/* Initialize */
	if (initscr() == NULL) return (-1);

	/* Activate hooks */
	quit_aux = hook_quit;

	/* Require standard size screen */
	if (LINES < 24 || COLS < 80)
		quit("Angband needs at least an 80x24 'curses' screen");

#ifdef A_COLOR
	/* Do we have color, and enough color, available? */
	can_use_color = ((start_color() != ERR) && has_colors() &&
			 (COLORS >= 8) && (COLOR_PAIRS >= 8));

#ifdef HAVE_USE_DEFAULT_COLORS
	/* Should we use curses' "default color" */
	/*
	 * Turned off since it screws up the colors,
	 * making background white and text black. -CJN
	 */
	/* if (use_default_colors() == OK) bg_color = -1; */
#endif

	/* Attempt to use colors */
	if (can_use_color) {
		/* Prepare the color pairs */
		/* PAIR_WHITE (pair 0) is *always* WHITE on BLACK */
		init_pair(PAIR_RED, COLOR_RED, bg_color);
		init_pair(PAIR_GREEN, COLOR_GREEN, bg_color);
		init_pair(PAIR_YELLOW, COLOR_YELLOW, bg_color);
		init_pair(PAIR_BLUE, COLOR_BLUE, bg_color);
		init_pair(PAIR_MAGENTA, COLOR_MAGENTA, bg_color);
		init_pair(PAIR_CYAN, COLOR_CYAN, bg_color);
		init_pair(PAIR_BLACK, COLOR_BLACK, bg_color);

		/* Prepare the colors */
		colortable[TERM_DARK]     = (COLOR_PAIR(PAIR_BLACK));
		colortable[TERM_WHITE]    = (COLOR_PAIR(PAIR_WHITE) | A_BRIGHT);
		colortable[TERM_SLATE]    = (COLOR_PAIR(PAIR_WHITE));
		colortable[TERM_ORANGE]   = (COLOR_PAIR(PAIR_YELLOW) | A_BRIGHT);
		colortable[TERM_RED]      = (COLOR_PAIR(PAIR_RED));
		colortable[TERM_GREEN]    = (COLOR_PAIR(PAIR_GREEN));
		colortable[TERM_BLUE]     = (COLOR_PAIR(PAIR_BLUE));
		colortable[TERM_UMBER]    = (COLOR_PAIR(PAIR_YELLOW));
		colortable[TERM_L_DARK]   = (COLOR_PAIR(PAIR_BLACK) | A_BRIGHT);
		colortable[TERM_L_WHITE]  = (COLOR_PAIR(PAIR_WHITE));
		colortable[TERM_L_PURPLE] = (COLOR_PAIR(PAIR_MAGENTA));
		colortable[TERM_YELLOW]   = (COLOR_PAIR(PAIR_YELLOW) | A_BRIGHT);
		colortable[TERM_L_RED]    = (COLOR_PAIR(PAIR_MAGENTA) | A_BRIGHT);
		colortable[TERM_L_GREEN]  = (COLOR_PAIR(PAIR_GREEN) | A_BRIGHT);
		colortable[TERM_L_BLUE]   = (COLOR_PAIR(PAIR_BLUE) | A_BRIGHT);
		colortable[TERM_L_UMBER]  = (COLOR_PAIR(PAIR_YELLOW));
//.........这里部分代码省略.........
开发者ID:CJNyfalt,项目名称:angband,代码行数:101,代码来源:main-gcu.c


示例7: sys_setxattr

int sys_setxattr (const char *path, const char *uname, const void *value, size_t size, int flags)
{
	const char *name = prefix(uname);
#if defined(HAVE_SETXATTR)
#ifndef XATTR_ADD_OPT
	return setxattr(path, name, value, size, flags);
#else
	int options = 0;
	return setxattr(path, name, value, size, 0, options);
#endif
#elif defined(HAVE_SETEA)
	return setea(path, name, value, size, flags);
#elif defined(HAVE_EXTATTR_SET_FILE)
	int retval = 0;
	if (flags) {
		/* Check attribute existence */
		retval = extattr_get_file(path, EXTATTR_NAMESPACE_USER, uname, NULL, 0);
		if (retval < 0) {
			/* REPLACE attribute, that doesn't exist */
			if (flags & XATTR_REPLACE && errno == ENOATTR) {
				errno = ENOATTR;
				return -1;
			}
			/* Ignore other errors */
		}
		else {
			/* CREATE attribute, that already exists */
			if (flags & XATTR_CREATE) {
				errno = EEXIST;
				return -1;
			}
		}
	}
	retval = extattr_set_file(path, EXTATTR_NAMESPACE_USER, uname, value, size);
	return (retval < 0) ? -1 : 0;
#elif defined(HAVE_ATTR_SET)
	int myflags = 0;
	char *attrname = strchr(name,'.') + 1;
	
	if (strncmp(name, "system", 6) == 0) myflags |= ATTR_ROOT;
	if (flags & XATTR_CREATE) myflags |= ATTR_CREATE;
	if (flags & XATTR_REPLACE) myflags |= ATTR_REPLACE;

	return attr_set(path, attrname, (const char *)value, size, myflags);
#elif defined(HAVE_ATTROPEN)
	int ret = -1;
	int myflags = O_RDWR;
	int attrfd;
	if (flags & XATTR_CREATE) myflags |= O_EXCL;
	if (!(flags & XATTR_REPLACE)) myflags |= O_CREAT;
	attrfd = solaris_attropen(path, name, myflags, (mode_t) SOLARIS_ATTRMODE);
	if (attrfd >= 0) {
		ret = solaris_write_xattr(attrfd, value, size);
		close(attrfd);
	}
	return ret;
#else
	errno = ENOSYS;
	return -1;
#endif
}
开发者ID:Distrotech,项目名称:netatalk,代码行数:61,代码来源:extattr.c


示例8: main

main()
{
	int state 1000, i, book, volume, corp, report;
	int na;
	char *v[20], **vv, **rr;
	char ubuff[1000], *up;
	char line[100];
	char *p, *s, *r, *q;
	while (gets(line))
	{
		if (line[1]>'9' || line[1]<'0') continue;
		switch(line[0])
		{
		case 'T':
			if (state > 'T')
			{
				book=0;
				report=0;
				printf("\n%%T ");
			}
			printf("%s\n", line+18);
			state='T';
			na = getargs(line+18, v);
			for(i=0;i<na;i++)
				if (strcmp(v[i], "(Book)")==0)
					book=1;
			continue;
		case 'A':
			state = 'A';
			na=getargs(line+18, vv=v);
			if (na<=0) continue;
			while (na>0)
			{
				printf("%%A ");
				corp=0;
				for(p=vv[1]; *p; p++)
					if (islower(*p))
						corp=1;
				if (corp==0)
				{
					for(p=vv[1]; *p; p++)
						printf("%c. ", *p);
					if (na>2 &&strcmp(vv[2], "+"))
					{
						printf("%s", vv[0]);
						if (strcmp(vv[2], "Jr.")==0)
							printf(",");
						printf(" %s\n",vv[2]);
						vv++;
						na--;
					}
					else
						printf("%s\n", vv[0]);
				}
				else
					printf("%s %s\n",vv[0],vv[1]);
				vv+=2;
				na-=2;
				if (strcmp(vv[0], "+")==0)
				{
					vv++;
					na--;
				}
			}
			continue;
		case 'U':
			if (state!='U')
				ubuff[0]=0;
			else
				strcat(ubuff, " ");
			state = 'U';
			strcat(ubuff, line+18);
			if (line[2]=='.')
			{ /* end of item */
				p=ubuff; /*start*/
				volume=0;
				for(s=ubuff; *s; s++)
					if (s[-1]==' ' && prefix("Vol", s))
					{
						for(q=s-1; q>ubuff; q--)
						{
							if (*q==' ' || *q==',') *q=0;
							else break;
						}
						volume=1;
						break;
					}
				if (*s==0)
					for(s=ubuff; *s && (*s!=',' || sprefix("Inc", s+1)); s++)
						;
				else
					s++;
				if (*s==',')*s++=0;
				if (book)
					printf("%%I %s\n",ubuff);
				else if (volume)
					printf("%%J %s\n", ubuff);
				else if (substr(ubuff, "Report")!=0)
				{
					report=1;
//.........这里部分代码省略.........
开发者ID:dank101,项目名称:4.2BSD,代码行数:101,代码来源:kaiser.c


示例9: input


//.........这里部分代码省略.........

		i = sstr2arg(bigbuf, 20, av, " \t");
		if( i == 1 ) {	/* tell him what the current options are */
			printf(" Copyfile  - '%s'\n", copyfile);
			printf(" Signature - '%s'\n", signature);
			printf(" Aliases   - '%s'\n", aliasfilename);
			printf(" Editor    - '%s'\n", editor);
			printf(" Checker   - '%s'\n", checker);
			printf(" Subargs   - '%s'\n", subargs);

			if(qflag == 0 && cflag == 1)
				printf(" File copy option is on\n");
			if(qflag == 1 && cflag == 0)
				printf(" File copy on confirmation only\n");
			continue;
		}
		if( (i = picko( av[1] ) ) < 0) {
			fprintf(stderr,"Option '%s' is invalid.\n", av[1]);
			continue;
		}
		select_o( i, &av[1] );
		continue;
	}
	compress (bigbuf, bigbuf);
				  /* so prefix works on multi-words     */
	if (bigbuf[0] == '\0')
	    continue;             /* just hit newline                   */

	signal (SIGINT, onint);

	for (i = 0; !isnull (bigbuf[i]); i++)
	    bigbuf[i] = uptolow (bigbuf[i]);

	if (prefix ("bcc", bigbuf))
	{
	    getaddr (bccname, bcc, YES, locname);
	    bccflag = 1;	
	    continue;
	}

/*	"Edit" option (grandfathered to also accept "v" for visual edit) */

	if (prefix ("edit body", bigbuf) || prefix("visual edit body", bigbuf))
	{
		dropen( DRBEGIN );
    		if((tmpfd = open(tmpdrffile, 2, 0600)) < 0)
    		{
    			fprintf(stderr,"Cannot open temporary draft file %s\n", tmpdrffile);
    			s_exit(-1);
    		}

    		if(lseek(tmpfd, 0L, 0) < 0)
    		{
    			fprintf(stderr,"Lseek failed on temporary draft file %s\n", tmpdrffile);
    			s_exit(-1);
    		}

    		if(chmod(drffile, 0600) < 0)
    			fprintf(stderr,"Could not make draft %s writable\n", drffile);

		/* 	Write the header info to the temporary draft	*/
		dist = 0L;
		dist += write(tmpfd, fromname, strlen( fromname ));
    		dist += write(tmpfd, from, strlen( from ));
    		dist += write(tmpfd, "\n", 1);
    		dist += write(tmpfd, toname, strlen( toname ));
开发者ID:yeonsh,项目名称:Amoeba,代码行数:67,代码来源:s_input.c


示例10: default_pos_analyzer

sequence_analyzer default_pos_analyzer()
{
    sequence_analyzer analyzer;

    auto word_feats = [](const std::string& word, uint64_t t,
                         sequence_analyzer::collector& coll)
    {
        auto norm = utf::foldcase(word);
        for (uint64_t i = 1; i <= 4; i++)
        {
            auto len = std::to_string(i);
            coll.add("w[t]_suffix_" + len + "=" + suffix(norm, i), 1);
            coll.add("w[t]_prefix_" + len + "=" + prefix(norm, i), 1);
        }
        coll.add("w[t]=" + norm, 1);

        // additional binary word features
        if (std::any_of(word.begin(), word.end(), [](char c)
                        {
                            return std::isdigit(c);
                        }))
        {
            coll.add("w[t]_has_digit=1", 1);
        }

        if (std::find(word.begin(), word.end(), '-') != word.end())
            coll.add("w[t]_has_hyphen=1", 1);

        if (std::any_of(word.begin(), word.end(), [](char c)
                        {
                            return std::isupper(c);
                        }))
        {
            coll.add("w[t]_has_upper=1", 1);
            if (t != 0)
            {
                coll.add("w[t]_has_upper_and_not_sentence_start=1", 1);
            }
        }

        if (std::all_of(word.begin(), word.end(), [](char c)
                        {
                            return std::isupper(c);
                        }))
        {
            coll.add("w[t]_all_upper=1", 1);
        }
    };

    // current word features
    analyzer.add_observation_function(
        [=](const sequence& seq, uint64_t t, sequence_analyzer::collector& coll)
        {
            std::string word = seq[t].symbol();
            word_feats(word, t, coll);
        });

    // previous word features
    analyzer.add_observation_function(
        [](const sequence& seq, uint64_t t, sequence_analyzer::collector& coll)
        {
            std::string word = seq[t].symbol();
            if (t > 0)
            {
                auto prevword = seq[t - 1].symbol();
                coll.add("w[t-1]=" + utf::foldcase(prevword), 1);
                if (t > 1)
                {
                    auto prev2word = seq[t - 2].symbol();
                    coll.add("w[t-2]=" + utf::foldcase(prev2word), 1);
                }
                else
                {
                    coll.add("w[t-2]=<s>", 1);
                }
            }
            else
            {
                coll.add("w[t-1]=<s>", 1);
                coll.add("w[t-2]=<s1>", 1);
            }
        });

    // next word features
    analyzer.add_observation_function(
        [](const sequence& seq, uint64_t t, sequence_analyzer::collector& coll)
        {
            if (t + 1 < seq.size())
            {
                auto nextword = seq[t + 1].symbol();
                coll.add("w[t+1]=" + utf::foldcase(nextword), 1);
                if (t + 2 < seq.size())
                {
                    auto next2word = seq[t + 2].symbol();
                    coll.add("w[t+2]=" + utf::foldcase(next2word), 1);
                }
                else
                {
                    coll.add("w[t+2]=</s>", 1);
                }
//.........这里部分代码省略.........
开发者ID:MGKhKhD,项目名称:meta,代码行数:101,代码来源:sequence_analyzer.cpp


示例11: init_x11

/*
 * Initialization function for an "X11" module to Angband
 */
errr init_x11(int argc, char **argv)
{
	int i;

	cptr dpy_name = "";

	int num_term = 1;

#ifdef USE_GRAPHICS

	cptr bitmap_file = "";
	char filename[1024];

	int pict_wid = 0;
	int pict_hgt = 0;

	char *TmpData;

#endif /* USE_GRAPHICS */


	/* Parse args */
	for (i = 1; i < argc; i++)
	{
		if (prefix(argv[i], "-d"))
		{
			dpy_name = &argv[i][2];
			continue;
		}

#ifdef USE_GRAPHICS
		if (prefix(argv[i], "-s"))
		{
			smoothRescaling = FALSE;
			continue;
		}

		if (prefix(argv[i], "-o"))
		{
			arg_graphics = GRAPHICS_ORIGINAL;
			continue;
		}

		if (prefix(argv[i], "-a"))
		{
			arg_graphics = GRAPHICS_ADAM_BOLT;
			continue;
		}

		if (prefix(argv[i], "-g"))
		{
			smoothRescaling = FALSE;
			arg_graphics = GRAPHICS_DAVID_GERVAIS;
			continue;
		}

		if (prefix(argv[i], "-b"))
		{
			use_bigtile = TRUE;
			continue;
		}

#endif /* USE_GRAPHICS */

		if (prefix(argv[i], "-n"))
		{
			num_term = atoi(&argv[i][2]);
			if (num_term > MAX_TERM_DATA) num_term = MAX_TERM_DATA;
			else if (num_term < 1) num_term = 1;
			continue;
		}

		plog_fmt("Ignoring option: %s", argv[i]);
	}


	/* Init the Metadpy if possible */
	if (Metadpy_init_name(dpy_name)) return (-1);


	/* Prepare cursor color */
	MAKE(xor, infoclr);
	Infoclr_set(xor);
	Infoclr_init_ppn(Metadpy->fg, Metadpy->bg, "xor", 0);


	/* Prepare normal colors */
	for (i = 0; i < 256; ++i)
	{
		Pixell pixel;

		MAKE(clr[i], infoclr);

		Infoclr_set(clr[i]);

		/* Acquire Angband colors */
		color_table[i][0] = angband_color_table[i][0];
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:nangband,代码行数:101,代码来源:main-x11.c


示例12: init_xaw

/*
 * Initialization function for an X Athena Widget module to Angband
 *
 * We should accept "-d<dpy>" requests in the "argv" array.  XXX XXX XXX
 */
errr init_xaw(int argc, char **argv)
{
	int i;
	Widget topLevel;
	Display *dpy;

	cptr dpy_name = "";


#ifdef USE_GRAPHICS

	cptr bitmap_file = "";
	char filename[1024];

	int pict_wid = 0;
	int pict_hgt = 0;

	char *TmpData;

#endif /* USE_GRAPHICS */

	/* Parse args */
	for (i = 1; i < argc; i++)
	{
		if (prefix(argv[i], "-d"))
		{
			dpy_name = &argv[i][2];
			continue;
		}

#ifdef USE_GRAPHICS
		if (prefix(argv[i], "-s"))
		{
			smoothRescaling = FALSE;
			continue;
		}

		if (prefix(argv[i], "-o"))
		{
			arg_graphics = GRAPHICS_ORIGINAL;
			continue;
		}

		if (prefix(argv[i], "-a"))
		{
			arg_graphics = GRAPHICS_ADAM_BOLT;
			continue;
		}

		if (prefix(argv[i], "-g"))
		{
			smoothRescaling = FALSE;
			arg_graphics = GRAPHICS_DAVID_GERVAIS;
			continue;
		}

		if (prefix(argv[i], "-b"))
		{
			use_bigtile = TRUE;
			continue;
		}

#endif /* USE_GRAPHICS */

		if (prefix(argv[i], "-n"))
		{
			num_term = atoi(&argv[i][2]);
			if (num_term > MAX_TERM_DATA) num_term = MAX_TERM_DATA;
			else if (num_term < 1) num_term = 1;
			continue;
		}

		plog_fmt("Ignoring option: %s", argv[i]);
	}


	/* Attempt to open the local display */
	dpy = XOpenDisplay(dpy_name);

	/* Failure -- assume no X11 available */
	if (!dpy) return (-1);

	/* Close the local display */
	XCloseDisplay(dpy);


#ifdef USE_XAW_LANG

	/* Support locale processing */
	XtSetLanguageProc(NULL, NULL, NULL);

#endif /* USE_XAW_LANG */


	/* Initialize the toolkit */
//.........这里部分代码省略.........
开发者ID:Falcon-peregrinus,项目名称:angband-russian,代码行数:101,代码来源:main-xaw.c


示例13:

void M2kGearAnimation::registerChannels(Bus* bus) {
	GearSequenceAnimation::registerChannels(bus);
	b_Absorber02Angle = bus->registerLocalDataChannel<double>(prefix() + ".Absorber02", 0.0);
	b_Absorber03Angle = bus->registerLocalDataChannel<double>(prefix() + ".Absorber03", 0.0);
	b_Compression = bus->registerLocalDataChannel<double>(prefix() + ".Compression", 0.0);
}
开发者ID:nsmoooose,项目名称:csp,代码行数:6,代码来源:GearAnimation.cpp


示例14: registerChannels

void GearSequenceAnimation::registerChannels(Bus* bus) {
	if (m_RetractSequence.valid()) m_RetractSequence->registerChannels(bus);
	if (m_CompressionSequence.valid()) m_CompressionSequence->registerChannels(bus);
	b_TireRotation = bus->registerLocalDataChannel<double>(prefix() + ".TireRotation", 0.0);
	b_SteeringAngle = bus->registerLocalDataChannel<double>(prefix() + ".SteeringAngle", 0.0);
}
开发者ID:nsmoooose,项目名称:csp,代码行数:6,代码来源:GearAnimation.cpp


示例15: prefix

void EOTHeader::updateEOTSize(size_t fontDataSize)
{
    prefix()->eotSize = m_buffer.size() + fontDataSize;
}
开发者ID:MYSHLIFE,项目名称:webkit,代码行数:4,代码来源:OpenTypeUtilities.cpp


示例16: verify

        ProgramRunner::ProgramRunner( const BSONObj &args ) {
            verify( !args.isEmpty() );

            string program( args.firstElement().valuestrsafe() );
            verify( !program.empty() );
            boost::filesystem::path programPath = findProgram(program);

            string prefix( "mongod-" );
            bool isMongodProgram =
                    string("mongod") == program ||
                    program.compare( 0, prefix.size(), prefix ) == 0;

            prefix = "mongos-";
            bool isMongosProgram =
                    string("mongos") == program ||
                    program.compare( 0, prefix.size(), prefix ) == 0;

#if 0
            if (isMongosProgram == "mongos") {
                _argv.push_back("valgrind");
                _argv.push_back("--log-file=/tmp/mongos-%p.valgrind");
                _argv.push_back("--leak-check=yes");
                _argv.push_back("--suppressions=valgrind.suppressions");
                //_argv.push_back("--error-exitcode=1");
                _argv.push_back("--");
            }
#endif

            _argv.push_back( programPath.string() );

            _port = -1;

            BSONObjIterator j( args );
            j.next(); // skip program name (handled above)
            while(j.more()) {
                BSONElement e = j.next();
                string str;
                if ( e.isNumber() ) {
                    stringstream ss;
                    ss << e.number();
                    str = ss.str();
                }
                else {
                    verify( e.type() == mongo::String );
                    str = e.valuestr();
                }
                if ( str == "--port" )
                    _port = -2;
                else if ( _port == -2 )
                    _port = strtol( str.c_str(), 0, 10 );
                _argv.push_back(str);
            }

            if ( ! isMongodProgram && ! isMongosProgram && program != "mongobridge" )
                _port = 0;
            else {
                if ( _port <= 0 )
                    log() << "error: a port number is expected when running " << program << " from the shell" << endl;
                verify( _port > 0 );
            }
            if ( _port > 0 ) {
                bool haveDbForPort = registry.isPortRegistered( _port );
                if ( haveDbForPort ) {
                    log() << "already have db for port: " << _port << endl;
                    verify( !haveDbForPort );
                }
            }
        }
开发者ID:Albert-B-P,项目名称:mongo,代码行数:68,代码来源:shell_utils_launcher.cpp


示例17: main

int main(int argc, char** argv) {
  if (argc != 3) {
    fprintf(stderr, "exef2paz v1.22 by asmodean\n\n");
    fprintf(stderr, "usage: %s <input.paz> <game index>\n\n", argv[0]);
    fprintf(stderr, "\t 0 = ef - the latter tale\n", argv[0]);
    fprintf(stderr, "\t 1 = eden*\n", argv[0]);
    return -1;
  }

  string        in_filename(argv[1]);
  unsigned long game_index = atol(argv[2]);

  if (game_index >= GAME_COUNT) {
    fprintf(stderr, "Unknown game index: %d\n", game_index);
    return -1;
  }

  string prefix(as::stringtol(as::get_file_prefix(in_filename, true)));

  game_info_t game_info = GAME_INFO[game_index];
  key_info_t  keys;

  for (unsigned long i = 0; !game_info.keys[i].prefix.empty(); i++)
  {
    if (prefix == game_info.keys[i].prefix)
    {
      keys = game_info.keys[i];
    }
  }

  if (keys.prefix.empty()) {
    fprintf(stderr, "%s: don't know encryption key.\n", in_filename.c_str());
    return -1;
  }

  // Hard to recognize individual sound files because they lack extension
  bool is_audio = prefix == "bgm" || prefix == "se" || prefix == "voice" || prefix == "PMvoice";
  bool is_mov   = prefix == "mov";

  int fd = as::open_or_die(in_filename, O_RDONLY | O_BINARY);  

  PAZHDR hdr;
  read(fd, &hdr, sizeof(hdr));  

  char simple_key = hdr.toc_len >> 24;

  lseek(fd, 0, SEEK_SET);
  read_unobfuscate(fd, simple_key, &hdr, sizeof(hdr));  

  Blowfish bf;  

  unsigned char* toc_buff = new unsigned char[hdr.toc_len];
  read_unobfuscate(fd, simple_key, toc_buff, hdr.toc_len);
  bf.Set_Key(keys.toc_key, sizeof(keys.toc_key));
  bf.Decrypt(toc_buff, hdr.toc_len);  

  PAZHDR2*       hdr2 = (PAZHDR2*) toc_buff;
  unsigned char* p    = (unsigned char*) (hdr2 + 1);

  unsigned char* mov_seed = NULL;

  if (is_mov)
  {
    mov_seed = p;
    p += 256;
  }

  for (unsigned long i = 0; i < hdr2->entry_count; i++)
  {
    string filename = (char*) p;
    p += filename.length() + 1;

    PAZENTRY* entry = (PAZENTRY*) p;
    p += sizeof(*entry);    

    unsigned long  len  = entry->padded_length;
    unsigned char* buff = new unsigned char[len];
    lseek(fd, entry->offset, SEEK_SET);
    read_unobfuscate(fd, simple_key, buff, len);

    string crud;

    if (filename.find(".png") != string::npos)
    {
      crud = game_info.crud.png;
    }
    else if (filename.find(".ogg") != string::npos || is_audio)
    {
      crud = game_info.crud.ogg;
    }
    else if (filename.find(".sc") != string::npos)
    {
      crud = game_info.crud.sc;
    }
    else if (filename.find(".avi") != string::npos)
    {
      crud = game_info.crud.avi;
    }

    string seed = as::stringtol(filename) + as::stringf(" %08X ", entry->length) + crud;
//.........这里部分代码省略.........
开发者ID:Emiyasviel,项目名称:Arianrhod,代码行数:101,代码来源:exef2paz.cpp


示例18: _path

    RocksEngine::RocksEngine(const std::string& path, bool durable)
        : _path(path), _durable(durable), _maxPrefix(0) {
        {  // create block cache
            uint64_t cacheSizeGB = rocksGlobalOptions.cacheSizeGB;
            if (cacheSizeGB == 0) {
                ProcessInfo pi;
                unsigned long long memSizeMB = pi.getMemSizeMB();
                if (memSizeMB > 0) {
                    double cacheMB = memSizeMB / 2;
                    cacheSizeGB = static_cast<uint64_t>(cacheMB / 1024);
                }
                if (cacheSizeGB < 1) {
                    cacheSizeGB = 1;
                }
            }
            _block_cache = rocksdb::NewLRUCache(cacheSizeGB * 1024 * 1024 * 1024LL, 6);
        }
        _maxWriteMBPerSec = rocksGlobalOptions.maxWriteMBPerSec;
        _rateLimiter.reset(
            rocksdb::NewGenericRateLimiter(static_cast<int64_t>(_maxWriteMBPerSec) * 1024 * 1024));
        // open DB
        rocksdb::DB* db;
        auto s = rocksdb::DB::Open(_options(), path, &db);
        invariantRocksOK(s);
        _db.reset(db);

        _counterManager.reset(
            new RocksCounterManager(_db.get(), rocksGlobalOptions.crashSafeCounters));
        _compactionScheduler.reset(new RocksCompactionScheduler(_db.get()));

        // open iterator
        boost::scoped_ptr<rocksdb::Iterator> iter(_db->NewIterator(rocksdb::ReadOptions()));

        // find maxPrefix
        iter->SeekToLast();
        if (iter->Valid()) {
            // otherwise the DB is empty, so we just keep it at 0
            bool ok = extractPrefix(iter->key(), &_maxPrefix);
            // this is DB corruption here
            invariant(ok);
        }

        // load ident to prefix map. also update _maxPrefix if there's any prefix bigger than
        // current _maxPrefix
        {
            boost::lock_guard<boost::mutex> lk(_identPrefixMapMutex);
            for (iter->Seek(kMetadataPrefix);
                 iter->Valid() && iter->key().starts_with(kMetadataPrefix); iter->Next()) {
                invariantRocksOK(iter->status());
                rocksdb::Slice ident(iter->key());
                ident.remove_prefix(kMetadataPrefix.size());
                // this could throw DBException, which then means DB corruption. We just let it fly
                // to the caller
                BSONObj identConfig(iter->value().data());
                BSONElement element = identConfig.getField("prefix");

                if (element.eoo() || !element.isNumber()) {
                    log() << "Mongo metadata in RocksDB database is corrupted.";
                    invariant(false);
                }

                uint32_t identPrefix = static_cast<uint32_t>(element.numberInt());
                _identPrefixMap[StringData(ident.data(), ident.size())] = identPrefix;

                _maxPrefix = std::max(_maxPrefix, identPrefix);
            }
        }

        // just to be extra sure. we need this if last collection is oplog -- in that case we
        // reserve prefix+1 for oplog key tracker
        ++_maxPrefix;

        // load dropped prefixes
        {
            rocksdb::WriteBatch wb;
            // we will use this iter to check if prefixes are still alive
            boost::scoped_ptr<rocksdb::Iterator> prefixIter(
                _db->NewIterator(rocksdb::ReadOptions()));
            for (iter->Seek(kDroppedPrefix);
                 iter->Valid() && iter->key().starts_with(kDroppedPrefix); iter->Next()) {
                invariantRocksOK(iter->status());
                rocksdb::Slice prefix(iter->key());
                prefix.remove_prefix(kDroppedPrefix.size());
                prefixIter->Seek(prefix);
                invariantRocksOK(iter->status());
                if (prefixIter->Valid() && prefixIter->key().starts_with(prefix)) {
                    // prefix is still alive, let's instruct the compaction filter to clear it up
                    uint32_t int_prefix;
                    bool ok = extractPrefix(prefix, &int_prefix);
                    invariant(ok);
                    {
                        boost::lock_guard<boost::mutex> lk(_droppedPrefixesMutex);
                        _droppedPrefixes.insert(int_prefix);
                    }
                } else {
                    // prefix is no longer alive. let's remove the prefix from our dropped prefixes
                    // list
                    wb.Delete(iter->key());
                }
            }
//.........这里部分代码省略.........
开发者ID:daveh86,项目名称:mongo-rocks,代码行数:101,代码来源:rocks_engine.cpp


示例19: prefix

void prefix(node* a){
	cout << a->value->Char;
	if (a->left != NULL)prefix(a->left);
	if (a->right != NULL)prefix(a->right);
	
}
开发者ID:ajs207,项目名称:Calc,代码行数:6,代码来源:calc2sexpr.cpp


示例20: gettbl

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ prefixcmp函数代码示例发布时间:2022-05-30
下一篇:
C++ prefetchw函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap