当前位置: 首页>>代码示例>>C++>>正文


C++ Prefix类代码示例

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


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

示例1: CreateInstruction

Instruction* Jcc::CreateInstruction(unsigned char* memLoc, Processor* proc) {
	unsigned char* opLoc = memLoc;
	char buf[65];
	std::string inst;

	Prefix* pre = Prefix::GetPrefix(memLoc);
	unsigned int preSize = 0;
	unsigned int opcodeOffset = 0;

	Instruction* newJcc = 0;

	if(pre) {
		opLoc += preSize = pre->GetLength();
	}

	unsigned int val = (int)*(opLoc + 1);
	if(*opLoc == TWO_BYTE_OPCODE) {
		preSize++;
		opLoc++;
		opcodeOffset = TWO_BYTE_OFFSET;
		val = (int)*(opLoc + 1) + ((int)*(opLoc + 2) << 8);
	}

	Operand* src = 0;

	switch(*opLoc - opcodeOffset) {

		case JA:
		case JAE:
		case JB:
		case JBE:
		case JCXZ:
		case JE:
		case JG:
		case JGE:
		case JL:
		case JLE:
		case JNE:
		case JNO:
		case JNP:
		case JNS:
		case JO:
		case JP:
		case JS:

			GETINST(preSize + 1 + (opcodeOffset == TWO_BYTE_OFFSET ? 2 : 1));
			src = new ImmediateOperand(val, opcodeOffset == TWO_BYTE_OFFSET ? 2 : 1);
			snprintf(buf, 65, "%s %s", _GetStr(*opLoc - opcodeOffset), src->GetDisasm().c_str());
			newJcc = new Jcc(pre, buf, inst, (unsigned char)*opLoc - opcodeOffset);
			newJcc->SetOperand(Operand::SRC, src);
			break;

		default:
			break;

	}

	return newJcc;
}
开发者ID:rdnelson,项目名称:Libra,代码行数:59,代码来源:Jcc.cpp

示例2: AddEntry

void AddEntry(Prefix& prefix, const string& suffix)
{
	if (prefix.size() == PREFIX_LENGTH) {
		dictionary[prefix].push_back(suffix);
		prefix.pop_front();
	}
	prefix.push_back(suffix);
}
开发者ID:vvolis,项目名称:MarkovWriter,代码行数:8,代码来源:Main.cpp

示例3: add

// add: add word to suffix list, update prefix
void add(Prefix& prefix, const string& s)
{
	if (prefix.size() == NPREF) {
		statetab[prefix].push_back(s);
		prefix.pop_front();
	}
	prefix.push_back(s);
}
开发者ID:nickkachur,项目名称:coursework,代码行数:9,代码来源:markov++_list_prefixes.cpp

示例4: add

 void add(Prefix& prefix, string& new_word)
 {
      if(prefix.size() == prefix_len_)
      {
          state_list[prefix].push_back(new_word);
          prefix.pop_front();
      } 
      prefix.push_back(new_word);
 }
开发者ID:ebott,项目名称:boneyard,代码行数:9,代码来源:component.hpp

示例5: CreateInstruction

Instruction* In::CreateInstruction(Memory::MemoryOffset& memLoc, Processor* proc) {
	Memory::MemoryOffset opLoc = memLoc;
	char buf[65];
	std::string inst;

	Prefix* pre = Prefix::GetPrefix(memLoc);
	unsigned int preSize = 0;
	Instruction* newIn = 0;

	if(pre) {
		opLoc += preSize = pre->GetLength();
	}

	switch(*opLoc) {
		case IN_AL_IMM8:
		case IN_AX_IMM8:
		{
			eRegisters reg = *opLoc == IN_AL_IMM8 ? REG_AL : REG_AX;
			Operand* src = new ImmediateOperand(*(opLoc + 1), 1, (opLoc + 1).getOffset());
			Operand* dst = new RegisterOperand(reg, proc);
			GETINST(preSize + 2);
			snprintf(buf, 65, "IN %s, %s",reg == REG_AX ? "AX" : "AL", src->GetDisasm().c_str());

			newIn = new In(pre, buf, inst, (int)*opLoc);
			newIn->SetOperand(Operand::SRC, src);
			newIn->SetOperand(Operand::DST, dst);
			break;
		}
		case IN_AL_DX:
		case IN_AX_DX:
		{
			eRegisters reg = *opLoc == IN_AL_DX ? REG_AL : REG_AX;
			Operand* src = new RegisterOperand(REG_DX, proc);
			Operand* dst = new RegisterOperand(reg, proc);
			GETINST(preSize + 1);
			snprintf(buf, 65, "IN %s, DX", reg == REG_AX ? "AX" : "AL");
			newIn = new In(pre, buf, inst, (int)*opLoc);
			newIn->SetOperand(Operand::SRC, src);
			newIn->SetOperand(Operand::DST, dst);
			break;
		}
	}

	return newIn;

}
开发者ID:DarrenStahl,项目名称:Libra,代码行数:46,代码来源:In.cpp

示例6: CreateInstruction

Instruction* Out::CreateInstruction(unsigned char* memLoc, Processor* proc) {
	unsigned char* opLoc = memLoc;
	char buf[65];
	std::string inst;

	Prefix* pre = Prefix::GetPrefix(memLoc);
	unsigned int preSize = 0;
	Instruction* newOut = 0;

	if(pre) {
		opLoc += preSize = pre->GetLength();
	}

	switch(*opLoc) {
		case OUT_IMM8_AL:
		case OUT_IMM8_AX:
		{
			eRegisters reg = *opLoc == OUT_IMM8_AL ? REG_AL : REG_AX;
			Operand* dst = new ImmediateOperand(*(opLoc + 1), 1);
			Operand* src = new RegisterOperand(reg, proc);
			GETINST(preSize + 2);
			snprintf(buf, 65, "OUT %s, %s", dst->GetDisasm().c_str(), reg == REG_AX ? "AX" : "AL");

			newOut = new Out(pre, buf, inst, (int)*opLoc);
			newOut->SetOperand(Operand::SRC, src);
			newOut->SetOperand(Operand::DST, dst);
			break;
		}
		case OUT_DX_AL:
		case OUT_DX_AX:
		{
			eRegisters reg = *opLoc == OUT_DX_AL ? REG_AL : REG_AX;
			Operand* dst = new RegisterOperand(REG_DX, proc);
			Operand* src = new RegisterOperand(reg, proc);
			GETINST(preSize + 1);
			snprintf(buf, 65, "OUT DX, %s", reg == REG_AX ? "AX" : "AL");
			newOut = new Out(pre, buf, inst, (int)*opLoc);
			newOut->SetOperand(Operand::SRC, src);
			newOut->SetOperand(Operand::DST, dst);
			break;
		}
	}

	return newOut;

}
开发者ID:rdnelson,项目名称:Libra,代码行数:46,代码来源:Out.cpp

示例7: generate

// generate: produce output, one word per line
void generate(int nwords)
{
	Prefix prefix;
	int i;

	for (i = 0; i < NPREF; i++)
		add(prefix, NONWORD);
	for (i = 0; i < nwords; i++) {
		vector<string>& suf = statetab[prefix];
		const string& w = suf[rand() % suf.size()];
		if (w == NONWORD)
			break;
		cout << w << "\n";
		prefix.pop_front();	// advance
		prefix.push_back(w);
	}
}
开发者ID:nickkachur,项目名称:coursework,代码行数:18,代码来源:markov++_list_prefixes.cpp

示例8: QDialog

GameDialog::GameDialog(QWidget *parent, QString path, corelib *lib) :
    QDialog(parent),
    ui(new Ui::GameDialog),
    _path (path)
{
	Prefix *prefix = new Prefix (this, path, lib);
    ui->setupUi(this);
    //setting the UI
    if (qApp->arguments().length() > 1)
		  ui->lblIcon->setPixmap(QPixmap(path + "/icon"));
	else
	   ui->lblIcon->setPixmap(getIcoFromDisc());

    ui->lblIcon->setText("");
    ui->lblName->setText(tr("A Microsoft Windows(r) application is found on this disc. <br><br><b>%1</b><br><br> Would you like to install it? ").arg(prefix->name()));
    ui->lblDesc->setText(prefix->note());

}
开发者ID:Zhbert,项目名称:winegame,代码行数:18,代码来源:gamedialog.cpp

示例9: CreateInstruction

Instruction* Cwd::CreateInstruction(Memory::MemoryOffset& memLoc, Processor*) {
    Memory::MemoryOffset opLoc = memLoc;
    char buf[65];
    std::string inst;

    Prefix* pre = Prefix::GetPrefix(memLoc);
    unsigned int preSize = 0;

    if(pre) {
        opLoc += preSize = pre->GetLength();
    }

    if(*opLoc == CWD) {
        snprintf(buf, 65, "CWD");
        GETINST(preSize + 1);
        return new Cwd(pre, buf, inst, (int)*opLoc);
    }
    return 0;
}
开发者ID:DarrenStahl,项目名称:Libra,代码行数:19,代码来源:Cwd.cpp

示例10: SetupCacheEntry

static void
SetupCacheEntry(LookupCacheV4* aLookupCache,
                const nsCString& aCompletion,
                bool aNegExpired = false,
                bool aPosExpired = false)
{
  FullHashResponseMap map;

  Prefix prefix;
  prefix.FromPlaintext(aCompletion);

  CachedFullHashResponse* response = map.LookupOrAdd(prefix.ToUint32());

  response->negativeCacheExpirySec =
    aNegExpired ? EXPIRED_TIME_SEC : NOTEXPIRED_TIME_SEC;
  response->fullHashes.Put(GeneratePrefix(aCompletion, COMPLETE_SIZE),
                           aPosExpired ? EXPIRED_TIME_SEC : NOTEXPIRED_TIME_SEC);

  aLookupCache->AddFullHashResponseToCache(map);
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:20,代码来源:TestCaching.cpp

示例11: generate

   void generate(int ows, size_t pl)
   {
      outwords_ = ows;
      prefix_len_ = pl;
      string buff;
      Prefix prefix;
      for(size_t j=0; j < prefix_len_; ++j)
         {
            prefix.push_back("\n");
         }

      ifstream infile (filename_);

      while(!getline(infile,buff).eof())
      {
         parse_words(prefix, buff);
      }

      gen_output();
   }
开发者ID:ebott,项目名称:boneyard,代码行数:20,代码来源:component.hpp

示例12: TEST

// This testcase check if an cache entry whose negative cache time is expired
// and it doesn't have any postive cache entries in it, it should be removed
// from cache after calling |Has|.
TEST(UrlClassifierCaching, NegativeCacheExpireV2)
{
  _PrefixArray array = { GeneratePrefix(NEG_CACHE_EXPIRED_URL, 8) };
  UniquePtr<LookupCacheV2> cache = SetupLookupCache<LookupCacheV2>(array);

  nsCOMPtr<nsICryptoHash> cryptoHash = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID);

  MissPrefixArray misses;
  Prefix* prefix = misses.AppendElement(fallible);
  prefix->FromPlaintext(NEG_CACHE_EXPIRED_URL);

  AddCompleteArray dummy;
  cache->AddGethashResultToCache(dummy, misses, EXPIRED_TIME_SEC);

  // Ensure it is in cache in the first place.
  EXPECT_EQ(cache->IsInCache(prefix->ToUint32()), true);

  // It should be removed after calling Has API.
  TestCache<LookupCacheV2>(NEG_CACHE_EXPIRED_URL, true, false, false, cache.get());
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:23,代码来源:TestCaching.cpp

示例13: GenerateText

void GenerateText(int wordCount, ofstream& outFile)
{
	Prefix prefix;
	int i;
	for (i = 0; i < PREFIX_LENGTH; i++){
		AddEntry(prefix, NONWORD);
	}
		
	for (i = 0; i < wordCount; i++) {
		vector<string>& suffix = dictionary[prefix]; 
		const string& word = suffix[rand() % suffix.size()];
		if (word == NONWORD){
			break;
		}
			
		outFile << word << " ";
		//shift the prefix by a word, to keep generating.
		prefix.pop_front();
		prefix.push_back(word);
	}
}
开发者ID:vvolis,项目名称:MarkovWriter,代码行数:21,代码来源:Main.cpp

示例14: getPrefixFromWC

Prefix getPrefixFromWC(VEC coord)
{
	Prefix pfx;
	Orientation ori(SYMMETRY_HEXAGONAL);

	if (coord.y > 0)
	{
		if (!(coord * VEC(COS30, -SIN30) > 0 && coord.x>0)){
			ori.rotate(VP);
			pfx.rotate(VP);
		}
	} else {
		ori.rotate(VN);
		pfx.rotate(VN);
	}

	VEC vertexpoint_[3];
	double dist[3];
	vertexpoint_[0] = ori.getWCFromOC(VEC(0, 0)) - coord;
	vertexpoint_[1] = ori.getWCFromOC(VEC(COS30, -SIN30)) - coord;
	vertexpoint_[2] = ori.getWCFromOC(VEC(COS30, SIN30)) - coord;

	for (int i=0; i<3; i++)
		dist[i] = vertexpoint_[i]*vertexpoint_[i];
	

	if (dist[1] < dist[0])
		pfx.rotate((dist[2]<dist[1])? FN: FP);
	else if (dist[2] < dist[0])
		pfx.rotate(FN);


	for (int i=0; i<3; i++)
	{
		if (ori.getOCFromWC(coord).x > COS30)
			return Prefix();
	}

	return pfx;		
}
开发者ID:gralm,项目名称:symmetry,代码行数:40,代码来源:symmetryObject.cpp

示例15: test

void SymmetryObject::test()
{

	Prefix diff;
	edge edgeA, edgeB;

	/*edgeA.fr.index = 0;
	edgeA.fr.Pfx;
	edgeA.to.index = FACE_CENTERED;
	edgeA.to.Pfx.rotate(FN);

	edgeB.fr.index = FACE_CENTERED;
	edgeB.fr.Pfx.rotate(FN);
	edgeB.to.index = 0;
	edgeB.to.Pfx.rotate(FN);*/

	
	edgeA.fr.index = 0;
	//edgeA.fr.Pfx;
	edgeA.to.index = 0;
	edgeA.to.Pfx.rotate(FN);
	edgeA.to.Pfx.rotate(VN);


	cout << "edgeA: ";
	 edgeA.print();
	 cout << endl;
	//cout << "edgeB: " << edgeB.toString() << endl;

	if (edgeA.isOppositeOf(edgeA, &diff))
	{
		cout << "is opposite: ";
		diff.print();
		cout << endl;
	} else {
		cout << "not opposite" << endl;
	}
}
开发者ID:gralm,项目名称:symmetry,代码行数:38,代码来源:symmetryObject.cpp


注:本文中的Prefix类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。