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


C++ AutoArray类代码示例

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


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

示例1: couchLoadData

static void couchLoadData(PrintTextA &print) {
	CouchDB db(getTestCouch());
	db.use(DATABASENAME);


	AutoArray<Document, SmallAlloc<50> > savedDocs;

	Changeset chset(db.createChangeset());
	natural id=10000;
	JSON::Value data = db.json.factory->fromString(strdata);
	for (JSON::Iterator iter = data->getFwIter(); iter.hasItems();) {
		const JSON::KeyValue &kv= iter.getNext();
		Document doc;
		doc.edit(db.json)
				("name",kv[0])
				("age",kv[1])
				("height",kv[2])
				("_id",ToString<natural>(id,16));
		id+=14823;
		savedDocs.add(doc);
		chset.update(doc);
	}
	chset.commit(false);
	Set<StringA> uuidmap;

	for (natural i = 0; i < savedDocs.length(); i++) {
		StringA uuid = savedDocs[i]["_id"]->getStringUtf8();
//		print("%1\n") << uuid;
		uuidmap.insert(uuid);
	}
	print("%1") << uuidmap.size();

}
开发者ID:ondra-novak,项目名称:lightcouch,代码行数:33,代码来源:test_basics.cpp

示例2: startApp

int LightSpeed::AppBase::main_entry( int argc, wchar_t *argv[], ConstStrW pathname)
{
	AutoArray<ConstStrW> params;
	params.reserve(argc);
	for (int i = 0; i < argc; i++)
		params.add(ConstStrW(argv[i]));		
	appPathname = pathname;
	return startApp(Args(params));
}
开发者ID:ondra-novak,项目名称:lightspeed,代码行数:9,代码来源:app.cpp

示例3: while

void LinuxNetworkEventListener::workerProc() {

	while (!Thread::canFinish()) {
		try {
			PollBase::Result res;
			PollBase::WaitStatus wt = fdSelect.wait(nil, res);

			if (wt == PollBase::waitWakeUp) {
				while (pumpMessage());
			} else {

				AutoArray<std::pair<ISleepingObject *, natural>,SmallAlloc<32> > tocall;

				SysTime tm  = SysTime::now();
				FdData *listeners = reinterpret_cast<FdData *>(res.userData);
				for (ListenerMap::Iterator iter = listeners->listeners.getFwIter(); iter.hasItems();) {
					const FdListener &l = iter.peek();
					if (res.flags & l.waitMask) {
						tocall.add(std::make_pair(l.notify,res.flags & l.waitMask));
						listeners->listeners.erase(iter);
//						l.notify->wakeUp(con.waitMask & l.waitMask);
					} else if (l.waitTimeout.expired(tm)) {
						tocall.add(std::make_pair(l.notify,0));
						listeners->listeners.erase(iter);
	//					l.notify->wakeUp(0);
					} else {
						iter.skip();
					}
				}
				updateFdData(listeners,res.fd);

				for (natural i = 0; i < tocall.length(); i++) {
					tocall[i].first->wakeUp(tocall[i].second);
				}
			}
		} catch (const Exception &e) {
			AppBase::current().onThreadException(e);
		} catch (const std::exception &e) {
			AppBase::current().onThreadException(StdException(THISLOCATION,e));
		} catch (...) {
			AppBase::current().onThreadException(UnknownException(THISLOCATION));
		}
	}

	fdSelect.cancelAll(CleanUpProc(this));
/*	fdSelect.dropAll();
	while (fdSelect.hasItems()) {
		const LinuxFdSelect::FdInfo &con = fdSelect.getNext();
		FdData *listeners = reinterpret_cast<FdData *>(con.data);
		if (listeners) delete listeners;
		fdSelect.unset(con.fd);
	}
	*/

}
开发者ID:ondra-novak,项目名称:lightspeed,代码行数:55,代码来源:networkEventListener.cpp

示例4: flagsToDB

LightSpeed::StringA flagsToDB(const LightSpeed::JSON::INode &nd) {
	using namespace LightSpeed;
	if (nd.getType() == JSON::ndString) return nd.getStringUtf8();
	AutoArray<char, SmallAlloc<256> > buff;
	ConstStrA comma(",");
	ConstStrA div = comma.head(0);
	for(natural i = 0; i < nd.getEntryCount(); i++) {
		buff.append(div);
		div = comma;
		buff.append(nd[i].getString());
	}
	return buff;

}
开发者ID:ondra-novak,项目名称:jsonrpcserver,代码行数:14,代码来源:db.cpp

示例5: get

	void get(ReadIterator & source, PlanetNodeStatusMessageData &d)
	{
		get(source,d.m_x);
		get(source,d.m_z);
		get(source,d.m_loaded);

		AutoArray<uint32> temp;
		get(source,temp);
		d.m_servers=temp.get();

		AutoArray<int> temp2;
		get(source,temp2);
		d.m_subscriptionCounts=temp2.get();							
	}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:14,代码来源:PlanetNodeStatusMessage.cpp

示例6: put

	void put(ByteStream & target, const PlanetNodeStatusMessageData &d)
	{
		put(target,d.m_x);
		put(target,d.m_z);
		put(target,d.m_loaded);

		AutoArray<uint32> temp;
		temp.set(d.m_servers);
		put(target,temp);

		AutoArray<int> temp2;
		temp2.set(d.m_subscriptionCounts);
		put(target,temp2);
	}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:14,代码来源:PlanetNodeStatusMessage.cpp

示例7: setState

bool WinHttpStream::enumHeaders( IEnumHeaders &enumHdr )
{
	setState(stReadResponse);

	AutoArray<char> buffer;
	buffer.resize(1000);
	DWORD size = (DWORD)buffer.length();
	while (!HttpQueryInfoA(hHTTPConn,HTTP_QUERY_RAW_HEADERS,
		buffer.data(),&size,0)) {
			DWORD res = GetLastError();
			if (res == ERROR_INSUFFICIENT_BUFFER) {
				buffer.resize(size);
			} else {
				throw ErrNoWithDescException(THISLOCATION,GetLastError(),
					"Cannot retrieve headers from the request");
			}
	}
	buffer.resize(size);

	AutoArray<char>::SplitIterator iter=buffer.split((char)0);
	TextParser<char> parser;
	while (iter.hasItems()) {
		ConstStrA line = iter.getNext();
		if (parser("%1 : %2",line)) {
			ConstStrA field = parser[1].str();
			ConstStrA value = parser[2].str();
			if(enumHdr(field, value)) return true;
		}
	}

	return false;


}
开发者ID:xsmart,项目名称:lightspeed,代码行数:34,代码来源:winhttp.cpp

示例8: dbOrderFromJSON

LightSpeed::StringA dbOrderFromJSON(const LightSpeed::JSON::INode &nd) {
	using namespace LightSpeed;
	AutoArray<char, SmallAlloc<256> > buff;
	for (natural i = 0; i < nd.getEntryCount();i++) {
		ConstStrA fld = nd[i].getStringUtf8();
		if (fld.empty() || fld == ConstStrA('^') || fld.find('`') != naturalNull)
			  throw ErrorMessageException(THISLOCATION, "Unacceptable field name");
		if (i) buff.append(ConstStrA(", "));
		if (fld[0] == '^') {
			buff.add('`');buff.append(fld.offset(1));buff.add('`');
			buff.append(ConstStrA(" DESC"));
		} else {
			buff.add('`');buff.append(fld);buff.add('`');
			buff.append(ConstStrA(" ASC"));
		}
	}
	return ConstStrA(buff);
}
开发者ID:ondra-novak,项目名称:jsonrpcserver,代码行数:18,代码来源:db.cpp

示例9: reader

RefPtr<SourceFile>
SourceManager::open(ReportingContext &cc, const char *path)
{
  Atom *atom = strings_.add(path);
  AtomMap<RefPtr<SourceFile>>::Insert p = file_cache_.findForAdd(atom);
  if (p.found())
    return p->value;

  FileReader reader(cc, path);
  if (!reader.isValid())
    return nullptr;

  uint32_t length;
  AutoArray<char> chars;
  if (!reader.read(chars.address(), &length))
    return nullptr;

  RefPtr<SourceFile> file = new SourceFile(chars.forget(), length, path);
  file_cache_.add(p, atom, file);
  return file;
}
开发者ID:LittleKu,项目名称:sourcepawn,代码行数:21,代码来源:source-manager.cpp

示例10: postMessage

	integer ServiceApp::postMessage(ConstStrA command, const Args & args, SeqFileOutput output)
	{

		if (instance->imOwner()) return onMessage(command,args,output);

		AutoArrayStream<char, StaticAlloc<65536> > buffer;
		if (args.length() > 127) return onCommandLineError(args);
		buffer.write((char)(args.length()));
		buffer.copy(command.getFwIter());
		buffer.write(0);
		for(natural i = 0, cnt = args.length();i < cnt;i++){
			buffer.copy(WideToUtf8Reader<ConstStrW::Iterator>(args[i].getFwIter()));
			buffer.write(0);
		}
		AutoArray<byte,SmallAlloc<4096> > replybuff;
		replybuff.resize(instance->getReplyMaxSize());
		natural sz = instance->request(buffer.data(), buffer.length(), replybuff.data(), replybuff.length(), timeout);
		if (sz < sizeof(integer))
			throw ErrorMessageException(THISLOCATION,String("Invalid reply"));
		else {
			integer res = *reinterpret_cast<integer *>(replybuff.data());
			ConstStrA msg(reinterpret_cast<char *>(replybuff.data()+sizeof(integer)),sz - sizeof(integer));
			output.copy(msg.getFwIter());
			return res;
		}
	}
开发者ID:ondra-novak,项目名称:lightspeed,代码行数:26,代码来源:serviceapp.cpp

示例11: setup

 void setup(unsigned int npatl)
 {
         if ( npatl > maxpatl )
         {
                 ABstraight = AutoArray<u_int64_t>(RestMatch<sse4>::getRestWords(npatl,seedl));
                 Bstraight = ABstraight.get();
                 ABreverse = AutoArray<u_int64_t>(RestMatch<sse4>::getRestWords(npatl,seedl));
                 Breverse = ABreverse.get();
                 maxpatl = npatl;
         }
         if ( npatl != patl )
         {
                 patl = npatl;
                 numrestwords = RestMatch<sse4>::getRestWords(patl,seedl);
                 fullrestwords = RestMatch<sse4>::getFullRestWords(patl, seedl);
                 fracrestsyms = RestMatch<sse4>::getFracRestSyms(patl, seedl, fullrestwords);
                 straighttextrestoffset = RestMatch<sse4>::getTextRestOffset(patl, seedl, false);
                 reversetextrestoffset = RestMatch<sse4>::getTextRestOffset(patl, seedl, true);
                 straightmatchoffset = RestMatch<sse4>::getMatchOffset(patl, seedl, false);
                 reversematchoffset = RestMatch<sse4>::getMatchOffset(patl, seedl, true);                        
         }
 }
开发者ID:gt1,项目名称:REAL,代码行数:22,代码来源:RestWordBuffer.hpp

示例12: command

	bool ServiceApp::processRequest(const void *request)
	{
		const char *p = reinterpret_cast<const char*>(request);
		natural count = *p++;
		ConstStrA command(p);
		p += command.length() + 1;
		AutoArray<String,StaticAlloc<256> > params;
		AutoArray<ConstStrW,StaticAlloc<256> > wparams;
		for(natural i = 0;i < count;i++){
			ConstStrA param(p);
			p += param.length() + 1;
			params.add(String(param));
			wparams.add(ConstStrW(params[i]));
		}
		AutoArray<byte> output;
		output.resize(instance->getReplyMaxSize());
		SeqOutputBuffer fakeout(output.data() + sizeof (integer), output.length() - sizeof (integer));
		fakeout.setStaticObj();
		integer res = -1;
		bool stop = false;
		SeqFileOutput out(&fakeout);
		try {
			res = onMessage(command, wparams, out);
			stop = command == ConstStrA(stopCmd);
		}
		catch(std::exception & e){
			TextOut<SeqFileOutput> msg(out);
			msg("%1") << e.what();
			res = -1;
		}
		try {
			*reinterpret_cast<integer*>(output.data()) = res;
			instance->sendReply(output.data(), fakeout.length() + sizeof (integer));
		}
		catch(...){
		}
		return !stop;
	}
开发者ID:ondra-novak,项目名称:lightspeed,代码行数:38,代码来源:serviceapp.cpp

示例13: fillRange

        static AutoArray<u_int64_t> fillRange(
                std::vector < std::pair < std::string, u_int64_t > > const & ranges
                )
        {
                AutoArray<u_int64_t> AB ( (ranges.at(ranges.size()-1).second+1+63)/64 );

                for ( u_int64_t i = 0; i < (ranges.at(ranges.size()-1).second+1+63)/64; ++i )
                        AB[i] = 0;

                Rank::BitWriter8 W(AB.get());
                
                for ( unsigned int j = 0; j+1 < ranges.size(); ++j )
                {
                        u_int64_t len = ranges[j+1].second-ranges[j].second;
                        W.writeBit(true);
                        for ( u_int64_t i = 1; i < len; ++i )
                                W.writeBit(false);
                }
                W.writeBit(true);
                
                W.flush();
                
                return AB;
        }
开发者ID:gt1,项目名称:REAL,代码行数:24,代码来源:RangeVector.hpp

示例14: runReduce

ConstValue LocalView::runReduce(const ConstValue &rows) const {

	AutoArray<KeyAndDocId, SmallAlloc<256> > keylist;
	AutoArray<ConstValue, SmallAlloc<256> > values;
	keylist.reserve(rows.length());
	values.reserve(rows.length());
	for (JSON::ConstIterator iter = rows->getFwConstIter(); iter.hasItems();) {
		const JSON::ConstValue &v = iter.getNext();
		keylist.add(KeyAndDocId(v["key"],v["id"].getStringA()));
		values.add(v["value"]);
	}
	return reduce(keylist,values,false);

}
开发者ID:ondra-novak,项目名称:lightcouch,代码行数:14,代码来源:localView.cpp

示例15: index_VBO

static void index_VBO(
	const vector<vec4> & in_vertices,
	const vector<vec2> & in_uvs,
	const vector<vec3> & in_normals,
	AutoArray<unsigned short> & out_indices,
	AutoArray<vec4> & out_vertices,
	AutoArray<vec2> & out_uvs,
	AutoArray<vec3> & out_normals
)
{
	map<PackedVertex,unsigned short> VertexToOutIndex;

	// For each input vertex
	unsigned int numVertices = in_vertices.size();
	for (unsigned int i = 0; i < numVertices; i++)
	{
		PackedVertex packed;
		packed.position = in_vertices[i];
		packed.uv = in_uvs[i];
		packed.normal = in_normals[i];
		
		// Try to find a similar vertex in out_XXXX
		unsigned short index;
		bool found = get_similar_vertex_index(packed, VertexToOutIndex, index);

		if(found)
		{
			// A similar vertex is already in the VBO, use it instead !
			out_indices.Push(index);
		}
		else
		{
			out_vertices.Push(in_vertices[i]);
			out_uvs.Push(in_uvs[i]);
			out_normals.Push(in_normals[i]);
			unsigned short newindex = (unsigned short) out_vertices.Count() - 1;
			out_indices.Push(newindex);
			VertexToOutIndex[packed] = newindex;
		}
	}
}
开发者ID:Vavassor,项目名称:meteor,代码行数:41,代码来源:MeshLoading.cpp


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