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


C++ StringPool类代码示例

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


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

示例1: urlDecode

	String urlDecode(const char* in, int inLen, StringPool& sp) {
		//XXX: dangerous (potentially exploitable) codepath; please audit
		char* ch = sp.beginAdd(inLen); //output size will never exceed input size
		int len = doURLDecode(in, inLen, ch);
		sp.endAdd(len);
		return {ch,len};
	}
开发者ID:xaxaxa,项目名称:cppsp,代码行数:7,代码来源:stringutils.C

示例2: TEST

TEST(StringPoolTest, SortAndMaintainIndexesInReferences) {
    StringPool pool;

    StringPool::Ref ref = pool.makeRef(u"z");
    StringPool::StyleRef ref2 = pool.makeRef(StyleString{ {u"a"} });
    StringPool::Ref ref3 = pool.makeRef(u"m");

    EXPECT_EQ(*ref, u"z");
    EXPECT_EQ(0u, ref.getIndex());

    EXPECT_EQ(*(ref2->str), u"a");
    EXPECT_EQ(1u, ref2.getIndex());

    EXPECT_EQ(*ref3, u"m");
    EXPECT_EQ(2u, ref3.getIndex());

    pool.sort([](const StringPool::Entry& a, const StringPool::Entry& b) -> bool {
        return a.value < b.value;
    });


    EXPECT_EQ(*ref, u"z");
    EXPECT_EQ(2u, ref.getIndex());

    EXPECT_EQ(*(ref2->str), u"a");
    EXPECT_EQ(0u, ref2.getIndex());

    EXPECT_EQ(*ref3, u"m");
    EXPECT_EQ(1u, ref3.getIndex());
}
开发者ID:OchSept,项目名称:platform_frameworks_base,代码行数:30,代码来源:StringPool_test.cpp

示例3: _parseFieldList

void _parseFieldList (const char *str, StringPool &props, StringPool &columns)
{
   QS_DEF(Array<char>, prop);
   QS_DEF(Array<char>, column);
   BufferScanner scanner(str);

   props.clear();
   columns.clear();
   scanner.skipSpace();

   while (!scanner.isEOF())
   {
      scanner.readWord(prop, " ,");
      scanner.skipSpace();
      scanner.readWord(column, " ,");
      scanner.skipSpace();

      props.add(prop.ptr());
      columns.add(column.ptr());
      
      if (scanner.isEOF())
         break;
      
      if (scanner.readChar() != ',')
         throw BingoError("_parseFieldList(): comma expected");
      scanner.skipSpace();
   }
}
开发者ID:epam,项目名称:Indigo,代码行数:28,代码来源:bingo_oracle_util.cpp

示例4: readCB

		void readCB(bool success) {
			if(unlikely(!success)) {
				destruct();
				return;
			}
			//if((sp=thr._stringPoolPool.tryGet())==nullptr) sp=new StringPool();
			if((resp=thr._responsePool.tryGet())) resp->init(this->s,&sp);
			else resp=new Response(this->s,&sp);
			
			//keepAlive=true;
			auto it=req.headers.find("connection");
			if(it!=req.headers.end() && (*it).value=="close")keepAlive=false;
			else keepAlive=true;
			resp->headers.insert({"Connection", keepAlive?"keep-alive":"close"});
			
			/*char* date=sp.beginAdd(32);
			tm time;
			gmtime_r(&thr.curClockTime.tv_sec,&time);
			int l=rfctime(time,date);
			if(l>32)l=32;
			sp.endAdd(l);
			*/
			resp->headers.insert({"Date", sp.addString(thr.curRFCTime)});
			
			thr.performanceCounters.totalRequestsReceived++;
			try {
				thr.handleRequest(req,*resp,{&handler::finalize,this});
			} catch(exception& ex) {
				thr.handleError(req,*resp,ex,{&handler::finalize,this});
			}
			
		}
开发者ID:Dinesh-Ramakrishnan,项目名称:workspace,代码行数:32,代码来源:server.C

示例5:

TypeManager::TypeManager(StringPool &strings)
 : strings_(strings),
   voidType_(nullptr),
   implicitVoidType_(nullptr),
   uncheckedType_(nullptr),
   metaFunctionType_(nullptr),
   overloadedFunctionType_(nullptr),
   primitiveTypes_(),
   char_type_(nullptr),
   char_array_(nullptr),
   const_char_array_(nullptr),
   float_type_(nullptr),
   float3_array_(nullptr),
   const_float3_array_(nullptr)
{
  atom_String_ = strings.add("String");
  atom_Float_ = strings.add("Float");
  atom_any_ = strings.add("any");
  atom_Function_ = strings.add("Function");
  atom_bool_ = strings.add("bool");
}
开发者ID:LittleKu,项目名称:sourcepawn,代码行数:21,代码来源:type-manager.cpp

示例6: flatten

status_t XMLNode::flatten(const sp<AaptFile>& dest,
        bool stripComments, bool stripRawValues) const
{
    StringPool strings;
    Vector<uint32_t> resids;
    
    // First collect just the strings for attribute names that have a
    // resource ID assigned to them.  This ensures that the resource ID
    // array is compact, and makes it easier to deal with attribute names
    // in different namespaces (and thus with different resource IDs).
    collect_resid_strings(&strings, &resids);

    // Next collect all remainibng strings.
    collect_strings(&strings, &resids, stripComments, stripRawValues);

#if 0  // No longer compiles
    NOISY(printf("Found strings:\n");
        const size_t N = strings.size();
        for (size_t i=0; i<N; i++) {
            printf("%s\n", String8(strings.entryAt(i).string).string());
        }
    );
开发者ID:bincker,项目名称:Webkey,代码行数:22,代码来源:XMLNode.cpp

示例7: append_debug_tables

static void append_debug_tables(SmxBuilder *builder, StringPool &pool, RefPtr<SmxNameTable> names, SymbolList &nativeList)
{
  // We use a separate name table for historical reasons that are no longer
  // necessary. In the future we should just alias this to ".names".
  RefPtr<SmxNameTable> dbgnames = new SmxNameTable(".dbg.strings");
  RefPtr<SmxDebugInfoSection> info = new SmxDebugInfoSection(".dbg.info");
  RefPtr<SmxDebugLineSection> lines = new SmxDebugLineSection(".dbg.lines");
  RefPtr<SmxDebugFileSection> files = new SmxDebugFileSection(".dbg.files");
  RefPtr<SmxDebugSymbolsSection> symbols = new SmxDebugSymbolsSection(".dbg.symbols");
  RefPtr<SmxDebugNativesSection> natives = new SmxDebugNativesSection(".dbg.natives");
  RefPtr<SmxTagSection> tags = new SmxTagSection(".tags");

  stringlist *dbgstrs = get_dbgstrings();

  // State for tracking which file we're on. We replicate the original AMXDBG
  // behavior here which excludes duplicate addresses.
  ucell prev_file_addr = 0;
  const char *prev_file_name = nullptr;

  // Add debug data.
  for (stringlist *iter = dbgstrs; iter; iter = iter->next) {
    if (iter->line[0] == '\0')
      continue;

    DebugString str(iter->line);
    switch (str.kind()) {
      case 'F':
      {
        ucell codeidx = str.parse();
        if (codeidx != prev_file_addr) {
          if (prev_file_name) {
            sp_fdbg_file_t &entry = files->add();
            entry.addr = prev_file_addr;
            entry.name = dbgnames->add(pool, prev_file_name);
          }
          prev_file_addr = codeidx;
        }
        prev_file_name = str.skipspaces();
        break;
      }

      case 'L':
      {
        sp_fdbg_line_t &entry = lines->add();
        entry.addr = str.parse();
        entry.line = str.parse();
        break;
      }

      case 'S':
      {
        sp_fdbg_symbol_t sym;
        sp_fdbg_arraydim_t dims[sDIMEN_MAX];

        sym.addr = str.parse();
        sym.tagid = str.parse();

        str.skipspaces();
        str.expect(':');
        char *name = str.skipspaces();
        char *nameend = str.skipto(' ');
        Atom *atom = pool.add(name, nameend - name);

        sym.codestart = str.parse();
        sym.codeend = str.parse();
        sym.ident = (char)str.parse();
        sym.vclass = (char)str.parse();
        sym.dimcount = 0;
        sym.name = dbgnames->add(atom);

        info->header().num_syms++;

        str.skipspaces();
        if (str.getc() == '[') {
          info->header().num_arrays++;
          for (char *ptr = str.skipspaces(); *ptr != ']'; ptr = str.skipspaces()) {
            dims[sym.dimcount].tagid = str.parse();
            str.skipspaces();
            str.expect(':');
            dims[sym.dimcount].size = str.parse();
            sym.dimcount++;
          }
        }

        symbols->add(&sym, sizeof(sym));
        symbols->add(dims, sizeof(dims[0]) * sym.dimcount);
        break;
      }
    }
  }

  // Add the last file.
  if (prev_file_name) {
    sp_fdbg_file_t &entry = files->add();
    entry.addr = prev_file_addr;
    entry.name = dbgnames->add(pool, prev_file_name);
  }

  // Build the tags table.
  for (constvalue *constptr = tagname_tab.next; constptr; constptr = constptr->next) {
//.........这里部分代码省略.........
开发者ID:LittleKu,项目名称:sourcepawn,代码行数:101,代码来源:sc6.cpp

示例8: combinePathChroot

	String combinePathChroot(String p1, String p2, StringPool& sp) {
		char* tmp = sp.beginAdd(p1.length() + p2.length());
		int l = combinePathChroot(p1.data(), p2.data(), tmp);
		sp.endAdd(l);
		return {tmp,l};
	}
开发者ID:xaxaxa,项目名称:cppsp,代码行数:6,代码来源:stringutils.C

示例9: runFile

int VirtualMachine::runFile(ByteCodeFileReader& reader){
	int header = reader.readHeader();

	if(header != ('E' + 'D' + 'D' + 'I')){
		cout << "Not an EDDI compiled file" << endl;
		return 1;
	}

	StringPool pool;

	int strings = reader.readInt();

	cout << "String pool size = " << strings << endl;

	for(int i = 0; i < strings; i++){
		int index = reader.readInt();
		string value = reader.readLitteral();

		pool.add(index, value);
	}

	vector<Instruction> instructions;
	int current = 0;

	map<int, int> branches;

	while(reader.hasMore()){
		ByteCode bytecode = reader.readByteCode();

		if(bytecode == LABEL){
			int branche = reader.readInt();

			branches[branche] = current;
		} else {
			Instruction instruction;
			instruction.bytecode = bytecode;
	
			if(instruction.bytecode > LABEL && instruction.bytecode <= JUMP_IF_NOT){
				instruction.operand = reader.readInt();	
			}

			instructions.push_back(instruction);
			++current;
		}	
	}

	Stack stack;
	Variables variables;

	int programCounter = 0;

	while(true){
		Instruction instruction = instructions[programCounter];
		ByteCode bytecode = instruction.bytecode;
		
		programCounter++;

		switch(bytecode){
			case LDCS:
			case LDCI:
				stack.push(instruction.operand);

				break;
			case PRINTI:
				cout << stack.pop() << endl;

				break;
			case PRINTS:
				cout << pool.get(stack.pop()) << endl;

				break;
			case SSTORE:
			case ISTORE:{
				unsigned int variable = (unsigned int) instruction.operand;
				
				variables.assign(variable, stack.pop());
				
				break;
			}
			case SLOAD:
			case ILOAD:{
				unsigned int variable = (unsigned int) instruction.operand;

				stack.push(variables.get(variable));	
				
				break;
			}
			case IADD:{
				int rhs = stack.pop();
				int lhs = stack.pop();
				
				stack.push(lhs + rhs);
				
				break;
			}
			case ISUB:{
				int rhs = stack.pop();
				int lhs = stack.pop();
				
				stack.push(lhs - rhs);
//.........这里部分代码省略.........
开发者ID:wichtounet,项目名称:eddivm,代码行数:101,代码来源:VirtualMachine.cpp

示例10: main

int main()
{
	StringPool Test;
	Test.GetId("kvala");
	Test.GetId("doom");
	Test.GetId("k");
	Test.GetId("do");
	Test.GetId("fffv");
	Test.GetId("fbfdgf");
	Test.GetId("dsdfd");
	Test.GetId("dosdcd");
	Test.GetId("kvfddfdf");
	Test.GetId("dfsf");

	cout << Test.GetWord(Test.GetId("dsdfd")) << endl;

	return 0;
}
开发者ID:ANkoR911,项目名称:Sem_Two_Task_two,代码行数:18,代码来源:StringPool.cpp

示例11: handleStatic

		void handleStatic(staticPage* Sp) {
			Response& resp(*this->resp);
			(_staticPage=Sp)->retain();
			try {
				int bufferL = resp.buffer.length();
				if(Sp->mime.length()>0)resp.headers["Content-Type"]=Sp->mime;
				{
					char* tmps = sp.beginAdd(22);
					int l = itoa64(Sp->fileLen, tmps);
					sp.endAdd(l);
					resp.headers.insert({"Content-Length", { tmps, l }});
					StreamWriter sw(resp.buffer);
					resp.serializeHeaders(sw);
				}
				if(Sp->fileLen>=CPPSP_SENDFILE_MIN_SIZE) {
					_sendFileOffset=0;
					s.sendAll(resp.buffer.data()+bufferL,resp.buffer.length()-bufferL,
						MSG_MORE, { &handler::sendHeadersCB, this });
				} else {
					String data=Sp->data;
					iov[0]= {resp.buffer.data()+bufferL, (size_t)(resp.buffer.length()-bufferL)};
					iov[1]= {data.data(), (size_t)data.length()};
					resp.outputStream->writevAll(iov, data.length()<=0?1:2, { &handler::writevCB, this });
				}
			} catch(exception& ex) {
				Sp->release();
				server->handleError(req,resp,ex,{&handler::finalize,this});
			}
		}
开发者ID:Safe3,项目名称:workspace,代码行数:29,代码来源:server.C

示例12: cleanup

		//deallocate resources after a request has been completed
		void cleanup() {
			server->performanceCounters.totalRequestsFinished++;
			thr.performanceCounters.totalRequestsFinished++;
			req.reset();
			resp->reset();
			thr._responsePool.put(resp);
			resp=nullptr;
			sp.clear();
		}
开发者ID:Safe3,项目名称:workspace,代码行数:10,代码来源:server.C

示例13: handleStatic

		void handleStatic(staticPage* Sp) {
			Response& resp(*this->resp);
			try {
				String data=Sp->data;
				int bufferL = resp.buffer.length();
				if(Sp->mime.length()>0)resp.headers["Content-Type"]=Sp->mime;
				{
					char* tmps = sp.beginAdd(16);
					int l = itoa(data.length(), tmps);
					sp.endAdd(l);
					resp.headers.insert({"Content-Length", { tmps, l }});
					StreamWriter sw(resp.buffer);
					resp.serializeHeaders(sw);
				}
				iov[0]= {resp.buffer.data()+bufferL, (size_t)(resp.buffer.length()-bufferL)};
				iov[1]= {data.data(), (size_t)data.length()};
				resp.outputStream->writevAll(iov, 2, { &handler::writevCB, this });
			} catch(exception& ex) {
				thr.handleError(req,resp,ex,{&handler::finalize,this});
			}
		}
开发者ID:Dinesh-Ramakrishnan,项目名称:workspace,代码行数:21,代码来源:server.C

示例14: finalize

		void finalize() {
			thr.performanceCounters.totalRequestsFinished++;
			if(resp->closed) {
				destruct(); return;
			}
			req.reset();
			resp->reset();
			thr._responsePool.put(resp);
			resp=nullptr;
			sp.clear();
			if(keepAlive) {
				req.init(s,&sp);
				if(req.readRequest({&handler::readCB,this})) readCB(true);
			} else {
				s.shutdown(SHUT_WR);
				buf=(uint8_t*)malloc(4096);
				s.repeatRead(buf,4096,{&handler::sockReadCB,this});
			}
		}
开发者ID:Dinesh-Ramakrishnan,项目名称:workspace,代码行数:19,代码来源:server.C

示例15: ragnarok

static void PatriciaNode::ragnarok()
//----------------------------------
{
    _nodePool.ragnarok();
    _stringPool.ragnarok();
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:6,代码来源:patricia.cpp


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