本文整理汇总了C++中OutBuffer类的典型用法代码示例。如果您正苦于以下问题:C++ OutBuffer类的具体用法?C++ OutBuffer怎么用?C++ OutBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OutBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: beforeSendATParticles
/* send global tuple information */
void FixedTupleListAdress::beforeSendParticles
(ParticleList& pl, OutBuffer& buf) {
std::vector<longint> atpl;
// loop over the particle list
for (ParticleList::Iterator pit(pl); pit.isValid(); ++pit) {
longint pidK = pit->id();
LOG4ESPP_DEBUG(theLogger, "send particle with pid " << pidK << ", find tuples");
// find particle that involves this particle id
GlobalTuples::const_iterator it = globalTuples.find(pidK);
if (it != globalTuples.end()) {
// first write the pid of the first particle
//toSend.push_back(pidK);
//std::cout << "write pidK "<< pidK << "\n";
buf.write(pidK);
// write the size of the vector
int s = it->second.size();
//toSend.push_back(s);
//std::cout << "write s "<< s << "\n";
buf.write(s);
atpl.reserve(s);
// iterate through vector and add pids
//std::cout << storage->getRank() << ": removing AT particles ";
for (tuple::const_iterator it2 = it->second.begin();
it2 != it->second.end(); ++it2) {
//toSend.push_back(*it2);
//std::cout << " write pid "<< *it2 << " (";
Particle* tp = storage->lookupAdrATParticle(*it2);
//std::cout << " write " << tp->getId() << " (" << tp->getPos() << ")\n";
buf.write(*tp);
atpl.push_back(*it2);
// remove AT particle from storage
storage->removeAdrATParticle(*it2);
//std::cout << " " << *it2;
}
//std::cout << "\n";
// delete this pid from the global list
globalTuples.erase(pidK);
}
}
beforeSendATParticles(atpl, buf);
}
示例2: ScopeDsymbol
void StaticAssert::semantic2(Scope *sc)
{
//printf("StaticAssert::semantic2() %s\n", toChars());
ScopeDsymbol *sd = new ScopeDsymbol();
sc = sc->push(sd);
sc->flags |= SCOPEstaticassert;
++sc->ignoreTemplates;
Expression *e = exp->ctfeSemantic(sc);
e = resolveProperties(sc, e);
sc = sc->pop();
if (!e->type->checkBoolean())
{
if (e->type->toBasetype() != Type::terror)
exp->error("expression %s of type %s does not have a boolean value", exp->toChars(), e->type->toChars());
return;
}
unsigned olderrs = global.errors;
e = e->ctfeInterpret();
if (global.errors != olderrs)
{
errorSupplemental(loc, "while evaluating: static assert(%s)", exp->toChars());
}
else if (e->isBool(FALSE))
{
if (msg)
{ HdrGenState hgs;
OutBuffer buf;
msg = msg->ctfeSemantic(sc);
msg = resolveProperties(sc, msg);
msg = msg->ctfeInterpret();
hgs.console = 1;
StringExp * s = msg->toString();
if (s)
{ s->postfix = 0; // Don't display a trailing 'c'
msg = s;
}
msg->toCBuffer(&buf, &hgs);
error("%s", buf.toChars());
}
else
error("(%s) is false", exp->toChars());
if (sc->tinst)
sc->tinst->printInstantiationTrace();
if (!global.gag)
fatal();
}
else if (!e->isBool(TRUE))
{
error("(%s) is not evaluatable at compile time", exp->toChars());
}
}
示例3: Parameters
Type *TupleDeclaration::getType()
{
/* If this tuple represents a type, return that type
*/
//printf("TupleDeclaration::getType() %s\n", toChars());
if (isexp)
return NULL;
if (!tupletype)
{
/* It's only a type tuple if all the Object's are types
*/
for (size_t i = 0; i < objects->dim; i++)
{ Object *o = (Object *)objects->data[i];
if (o->dyncast() != DYNCAST_TYPE)
{
//printf("\tnot[%d], %p, %d\n", i, o, o->dyncast());
return NULL;
}
}
/* We know it's a type tuple, so build the TypeTuple
*/
Parameters *args = new Parameters();
args->setDim(objects->dim);
OutBuffer buf;
int hasdeco = 1;
for (size_t i = 0; i < objects->dim; i++)
{ Type *t = (Type *)objects->data[i];
//printf("type = %s\n", t->toChars());
#if 0
buf.printf("_%s_%d", ident->toChars(), i);
char *name = (char *)buf.extractData();
Identifier *id = new Identifier(name, TOKidentifier);
Parameter *arg = new Parameter(STCin, t, id, NULL);
#else
Parameter *arg = new Parameter(STCin, t, NULL, NULL);
#endif
args->data[i] = (void *)arg;
if (!t->deco)
hasdeco = 0;
}
tupletype = new TypeTuple(args);
if (hasdeco)
return tupletype->semantic(0, NULL);
}
return tupletype;
}
示例4: MraAddContact
// Adds new contact
DWORD CMraProto::MraAddContact(MCONTACT hContact, DWORD dwContactFlag, DWORD dwGroupID, const CMStringA &szEmail, const CMStringW &wszCustomName, const CMStringA *szPhones, const CMString* wszAuthMessage)
{
if (szEmail.GetLength() <= 4 && !(dwContactFlag & CONTACT_FLAG_GROUP))
return 0;
dwContactFlag |= CONTACT_FLAG_UNICODE_NAME;
if (dwGroupID == -1)
dwGroupID = 0;
OutBuffer buf;
buf.SetUL(dwContactFlag);
buf.SetUL(dwGroupID);
buf.SetLPSLowerCase(szEmail);
buf.SetLPSW(wszCustomName);
buf.SetLPS((szPhones == NULL) ? "" : *szPhones);
// pack auth message
OutBuffer buf2;
buf2.SetUL(2);
buf2.SetLPSW(_T(""));//***deb possible nick here
buf2.SetLPSW((wszAuthMessage == NULL) ? _T("") : *wszAuthMessage);
buf.SetLPS(CMStringA(ptrA(mir_base64_encode(buf2.Data(), (int)buf2.Len()))));
buf.SetUL(0);
return MraSendQueueCMD(hSendQueueHandle, 0, hContact, ACKTYPE_ADDED, NULL, 0, MRIM_CS_ADD_CONTACT, buf.Data(), buf.Len());
}
示例5: return
char *Loc::toChars()
{
OutBuffer buf;
if (filename)
{
buf.printf("%s", filename);
}
if (linnum)
buf.printf("(%d)", linnum);
buf.writeByte(0);
return (char *)buf.extractData();
}
示例6: TypeInfoDeclaration_codegen
void TypeInfoDeclaration_codegen(TypeInfoDeclaration *decl, IRState *p) {
IF_LOG Logger::println("TypeInfoDeclaration_codegen(%s)",
decl->toPrettyChars());
LOG_SCOPE;
if (decl->ir->isDefined()) {
return;
}
decl->ir->setDefined();
OutBuffer mangleBuf;
mangleToBuffer(decl, &mangleBuf);
const char *mangled = mangleBuf.peekString();
IF_LOG {
Logger::println("type = '%s'", decl->tinfo->toChars());
Logger::println("typeinfo mangle: %s", mangled);
}
// Only declare the symbol if it isn't yet, otherwise the subtype of built-in
// TypeInfos (rt.typeinfo.*) may clash with the base type when compiling the
// rt.typeinfo.* modules.
const auto irMangle = getIRMangledVarName(mangled, LINKd);
llvm::GlobalVariable *gvar = gIR->module.getGlobalVariable(irMangle);
if (!gvar) {
LLType *type = DtoType(decl->type)->getPointerElementType();
// We need to keep the symbol mutable as the type is not declared as
// immutable on the D side, and e.g. synchronized() can be used on the
// implicit monitor.
gvar = declareGlobal(decl->loc, gIR->module, type, irMangle, false);
}
IrGlobal *irg = getIrGlobal(decl, true);
irg->value = gvar;
emitTypeMetadata(decl);
// check if the definition can be elided
if (!global.params.useTypeInfo || !Type::dtypeinfo ||
isSpeculativeType(decl->tinfo) || builtinTypeInfo(decl->tinfo)) {
return;
}
// define the TypeInfo global
LLVMDefineVisitor v(gvar);
decl->accept(&v);
setLinkage({TYPEINFO_LINKAGE_TYPE, supportsCOMDAT()}, gvar);
}
示例7: MraProxyAck
// Ответ на соединение с прокси
DWORD CMraProto::MraProxyAck(DWORD dwStatus, const CMStringA &szEmail, DWORD dwIDRequest, DWORD dwDataType, const CMStringA &lpszData, const CMStringA &szAddresses, MRA_GUID mguidSessionID)
{
if (szEmail.GetLength() <= 4)
return 0;
OutBuffer buf;
buf.SetUL(dwStatus);
buf.SetLPSLowerCase(szEmail);
buf.SetUL(dwIDRequest);
buf.SetUL(dwDataType);
buf.SetLPS(lpszData);
buf.SetLPS(szAddresses);
buf.SetGUID(mguidSessionID);
return MraSendCMD(MRIM_CS_PROXY_ACK, buf.Data(), buf.Len());
}
示例8: CopyNumber
// Отправка SMS
DWORD CMraProto::MraSMSW(MCONTACT hContact, const CMStringA &lpszPhone, const CMStringW &lpwszMessage)
{
CMStringA szPhoneLocal = "+" + CopyNumber(lpszPhone);
OutBuffer buf;
buf.SetUL(0);
buf.SetLPS(szPhoneLocal);
buf.SetLPSW(lpwszMessage);
/* Save phone number for ack notify after send. */
LPBYTE lpbData = (LPBYTE)mir_calloc(lpszPhone.GetLength() + sizeof(size_t));
if (NULL == lpbData)
return (0);
memcpy(lpbData, lpszPhone, lpszPhone.GetLength());
return MraSendQueueCMD(hSendQueueHandle, 0, hContact, ICQACKTYPE_SMS, lpbData, lpszPhone.GetLength(), MRIM_CS_SMS, buf.Data(), buf.Len());
}
示例9:
char *ModuleDeclaration::toChars()
{
OutBuffer buf;
if (packages && packages->dim)
{
for (size_t i = 0; i < packages->dim; i++)
{
Identifier *pid = (*packages)[i];
buf.writestring(pid->toChars());
buf.writeByte('.');
}
}
buf.writestring(id->toChars());
return buf.extractString();
}
示例10: beforeResort
void beforeResort(ParticleList &pl, OutBuffer& out) {
if (pl.size() == 1) {
beforeResortCalled = true;
int res = 42;
out.write(res);
}
}
示例11: mangle
char *mangle(Declaration *sthis)
{
OutBuffer buf;
char *id;
Dsymbol *s;
//printf("::mangle(%s)\n", sthis->toChars());
s = sthis;
do
{
//printf("mangle: s = %p, '%s', parent = %p\n", s, s->toChars(), s->parent);
if (s->ident)
{
FuncDeclaration *fd = s->isFuncDeclaration();
if (s != sthis && fd)
{
id = mangle(fd);
buf.prependstring(id);
goto L1;
}
else
{
id = s->ident->toChars();
int len = strlen(id);
char tmp[sizeof(len) * 3 + 1];
buf.prependstring(id);
sprintf(tmp, "%d", len);
buf.prependstring(tmp);
}
}
else
buf.prependstring("0");
s = s->parent;
} while (s);
// buf.prependstring("_D");
L1:
//printf("deco = '%s'\n", sthis->type->deco ? sthis->type->deco : "null");
//printf("sthis->type = %s\n", sthis->type->toChars());
FuncDeclaration *fd = sthis->isFuncDeclaration();
if (fd && (fd->needThis() || fd->isNested()))
buf.writeByte(Type::needThisPrefix());
if (sthis->type->deco)
buf.writestring(sthis->type->deco);
else
{
#ifdef DEBUG
if (!fd->inferRetType)
printf("%s\n", fd->toChars());
#endif
assert(fd && fd->inferRetType);
}
id = buf.toChars();
buf.data = NULL;
return id;
}
示例12: visit
void visit(BinExp *e)
{
/* Evaluate assign expressions left to right
*/
const char *s = NULL;
switch(e->op)
{
case TOKadd: s = "Add"; break;
case TOKmin: s = "Min"; break;
case TOKmul: s = "Mul"; break;
case TOKdiv: s = "Div"; break;
case TOKmod: s = "Mod"; break;
case TOKxor: s = "Xor"; break;
case TOKand: s = "And"; break;
case TOKor: s = "Or"; break;
case TOKpow: s = "Pow"; break;
default: break;
}
if (s)
{
Type *tb = e->type->toBasetype();
Type *t1 = e->e1->type->toBasetype();
Type *t2 = e->e2->type->toBasetype();
e->e1->accept(this);
if (t1->ty == Tarray &&
((t2->ty == Tarray && !t1->equivalent(tb)) ||
(t2->ty != Tarray && !t1->nextOf()->equivalent(e->e2->type))))
{
// Bugzilla 12780: if A is narrower than B
// A[] op B[]
// A[] op B
buf->writestring("Of");
buf->writestring(t1->nextOf()->mutableOf()->deco);
}
e->e2->accept(this);
if (t2->ty == Tarray &&
((t1->ty == Tarray && !t2->equivalent(tb)) ||
(t1->ty != Tarray && !t2->nextOf()->equivalent(e->e1->type))))
{
// Bugzilla 12780: if B is narrower than A:
// A[] op B[]
// A op B[]
buf->writestring("Of");
buf->writestring(t2->nextOf()->mutableOf()->deco);
}
buf->writestring(s);
}
else
visit((Expression *)e);
}
示例13: visit
void visit(TypeSArray *t)
{
if (!substitute(t))
store(t);
if (t->isImmutable() || t->isShared())
{
visit((Type *)t);
}
if (t->isConst())
buf.writeByte('K');
buf.printf("A%llu_", t->dim ? t->dim->toInteger() : 0);
t->next->accept(this);
}
示例14: argsCppMangle
void argsCppMangle(Parameters *arguments, int varargs)
{
size_t n = 0;
if (arguments)
{
ArgsCppMangleCtx ctx = { this, 0 };
Parameter::foreach(arguments, &argsCppMangleDg, &ctx);
n = ctx.cnt;
}
if (varargs)
buf.writestring("z");
else if (!n)
buf.writeByte('v'); // encode ( ) arguments
}
示例15: if
void writeBase36(size_t i)
{
if (i >= 36)
{
writeBase36(i / 36);
i %= 36;
}
if (i < 10)
buf.writeByte((char)(i + '0'));
else if (i < 36)
buf.writeByte((char)(i - 10 + 'A'));
else
assert(0);
}