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

C++ pad函数代码示例

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

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



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

示例1: hexdump

void
hexdump(FILE *f, int indent, const char *p, int len)
{
    const unsigned char *cp = (const unsigned char *)p;
    char hex[16 * 3 + 1], *hp, ascii[16 + 1], *ap;
    int i, c;

    while (len) {
        hp = hex;
        ap = ascii;
        for (i = 0; len && i < 16; i++) {
            c = *cp++;
            len--;
            hp += sprintf(hp, "%02x ", c);
            *ap++ = c < 127 && c >= 32 ? c : '.';
        }
        *ap = 0;
        fprintf(f, "%s%-48s |%-16s|\n", pad(indent), hex, ascii);
    }
}
开发者ID:peadar,项目名称:hdmp,代码行数:20,代码来源:elf.c


示例2: printObject

void printObject(Object* obj, int indent) {
	switch (obj->kind) {
	case OBJ_CONSTANT:
		pad(indent);
		printf("Const %s = ", obj->name);
		printConstantValue(obj->constAttrs->value);
		break;
	case OBJ_TYPE:
		pad(indent);
		printf("Type %s = ", obj->name);
		printType(obj->typeAttrs->actualType);
		break;
	case OBJ_VARIABLE:
		pad(indent);
		printf("Var %s : ", obj->name);
		printType(obj->varAttrs->type);
		break;
	case OBJ_PARAMETER:
		pad(indent);
		if (obj->paramAttrs->kind == PARAM_VALUE)
			printf("Param %s : ", obj->name);
		else
			printf("Param VAR %s : ", obj->name);
		printType(obj->paramAttrs->type);
		break;
	case OBJ_FUNCTION:
		pad(indent);
		printf("Function %s : ", obj->name);
		printType(obj->funcAttrs->returnType);
		printf("\n");
		printScope(obj->funcAttrs->scope, indent + 4);
		break;
	case OBJ_PROCEDURE:
		pad(indent);
		printf("Procedure %s\n", obj->name);
		printScope(obj->procAttrs->scope, indent + 4);
		break;
	case OBJ_PROGRAM:
		pad(indent);
		printf("Program %s\n", obj->name);
		printScope(obj->progAttrs->scope, indent + 4);
		break;
	}
}
开发者ID:haoict,项目名称:HUST_CompilerConstructionLab,代码行数:44,代码来源:debug.c


示例3: encode_sequence

static void encode_sequence(const char *plain, int len, char *coded) {
   assert(len >= 0 && len <= 5);

   for (int block = 0; block < 8; block++) {
      int octet = get_octet(block);
      int junk = get_offset(block);

      if (octet >= len) {
         pad(&coded[block], 8 - block);
         return;
      }

      char c = shift_right(plain[octet], junk);

      if (junk < 0 && octet < len - 1) {
         c |= shift_right(plain[octet+1], 8 + junk);
      }
      coded[block] = encode_char(c);
   }
}
开发者ID:cadrian,项目名称:circus,代码行数:20,代码来源:base32.c


示例4: if

void vcat_pic::display(std::ostream &os, ht_sz row, bool do_pad) const
{
	wd_sz w = 0;
	if(row < top->height())
	{
		// we are in the top subpicture
		top->display(os,row,do_pad);
		w = top->width();
	}
	else if(row < height())
	{
		// we are in the bottom subpicture
		bottom->display(os,row-top->height(),do_pad);
		w = bottom->width();
	}

	if(do_pad)
	{
		pad(os,w,width());
	}
}
开发者ID:Adam27X,项目名称:cpp-reference-material,代码行数:21,代码来源:pic.hpp


示例5: putop

void putop(int op)
{    
	int     i;
	int seg;

    i = 0;
    while( opl[i].s )
    {
		if( opl[i].ov == (op & 255))
		{
			//seg = op & 0xFF00;
			//if (seg != 0) {
			//	fprintf(output, "%s:", segstr(op));
			//}
			ofs.write(pad(opl[i].s));
			return;
		}
		++i;
    }
    printf("DIAG - illegal opcode.\n");
}
开发者ID:jiangxilong,项目名称:Cores,代码行数:21,代码来源:Outcode.cpp


示例6: allocateMemAboveBase

void* IATModifier::allocateMemAboveBase(void* baseAddress, size_t size) {
	try	{
		MEMORY_BASIC_INFORMATION mbi;
		for (char* currentAddress = (char*)baseAddress;; currentAddress = (char*)mbi.BaseAddress + mbi.RegionSize) {
			mbi = process_.queryMemory(currentAddress);
			if (mbi.State != MEM_FREE) continue;
			// Walk memory region in allocation granularity steps.
			char* bruteForce = (char*)pad((unsigned int)currentAddress, 0xFFFF);
			while (bruteForce < (char*)mbi.BaseAddress + mbi.RegionSize) {
				try	{
					process_.allocMem(size, bruteForce, MEM_RESERVE | MEM_COMMIT);
					return bruteForce;
				}catch (MemoryAllocationException) {
				}
				bruteForce += 0x10000;
			}
		}
	} catch (const MemoryQueryException&) {
		return NULL;
	}
}
开发者ID:R0b3rtX99,项目名称:uberstealth,代码行数:21,代码来源:IATModifier.cpp


示例7: write_bmp

		void write_bmp(const BMP<DIB, I, D>& bmp, std::ostream& os)
		{
			typedef typename BMP<DIB, I, D>::color_type C;

			unsigned int l = bmp.dib_h.width * (bmp.dib_h.bpp / 8);
			unsigned int rowsize = ((bmp.dib_h.bpp * bmp.dib_h.width + 31) / 32) * 4;

			std::vector<D> buf(bmp.dib_h.width);
			std::vector<std::uint8_t> pad(rowsize - l);
			I i(bmp.iter);

			os << aux::write_to(bmp.bmp_h);
			os << aux::write_to(bmp.dib_h);

			for(int h = 0 ; h < bmp.dib_h.height ; ++h)
			{
				aux::transform_n(i, bmp.dib_h.width, buf.begin(), [](const C& c) { return static_cast<D>(c); });
				os << aux::write_to(*buf.begin(), l);
				os << aux::write_to(*pad.begin(), pad.size());
			}
		}
开发者ID:MaltesIndividualUsername,项目名称:VirtualMachine,代码行数:21,代码来源:io.hpp


示例8: emit_value

/* emit_value - emits an initialization for the type given by ty */
static int emit_value(int lc, Type ty, ...) {
	Value v;
	va_list ap;

	va_start(ap, ty);
	if (lc == 0)
		maxalign = 0;
	lc = pad(ty->align, lc);
	switch (ty->op) {
	case INT:      v.i = va_arg(ap, long);          break;
	case UNSIGNED: v.u = va_arg(ap, unsigned long); break;
	case FLOAT:    v.d = va_arg(ap, long double);   break;
	case POINTER:
		defpointer(va_arg(ap, Symbol));
		return lc + ty->size;
	default: assert(0);
	}
	va_end(ap);
	(*IR->defconst)(ty->op, ty->size, v);
	return lc + ty->size;
}
开发者ID:bhanug,项目名称:cdb,代码行数:22,代码来源:stab.c


示例9: dumpregs

void dumpregs(struct TrapData *td)
{	int i;
	XIOdebug("Registers dump:\n"); 
	XIOdebug("Trapdata is at %X\n",(int)td);
	for( i = 0; i< 32; i+=4)
	{	int j;
		for( j = i; j < i+4; j++)
		{	char * f;
			int fwidth;
			f = j< 10? "r%d  = %X":"r%d = %X";
			fwidth = XIOdebug(f,j,td->intregs[j]);
			pad(17,fwidth);
		}
 		XIOdebug("\n");
	}
	XIOdebug("psr = %X\n",td->PSR);
	XIOdebug("db = %X\n",td->DB);
	XIOdebug("dirbase = %X\n",td->DIRBASE);
	XIOdebug("fir = %X\n",td->FIR);
	XIOdebug("fsr = %X\n",td->FSR);
}
开发者ID:jamjr,项目名称:Helios-NG,代码行数:21,代码来源:idebug.c


示例10: elf32DumpDynamic

void
elf32DumpDynamic(FILE *f, const Elf32_Dyn *dyn, int indent)
{
	const char *padding = pad(indent);
	static const char *tagNames[] = {
	    "DT_NULL",
	    "DT_NEEDED",
	    "DT_PLTRELSZ",
	    "DT_PLTGOT",
	    "DT_HASH",
	    "DT_STRTAB",
	    "DT_SYMTAB",
	    "DT_RELA",
	    "DT_RELASZ",
	    "DT_RELAENT",
	    "DT_STRSZ",
	    "DT_SYMENT",
	    "DT_INIT",
	    "DT_FINI",
	    "DT_SONAME",
	    "DT_RPATH",
	    "DT_SYMBOLIC",
	    "DT_REL",
	    "DT_RELSZ",
	    "DT_RELENT",
	    "DT_PLTREL",
	    "DT_DEBUG",
	    "DT_TEXTREL",
	    "DT_JMPREL",
	    "DT_BIND_NOW"
	};
#ifndef DT_COUNT
#define DT_COUNT (sizeof tagNames / sizeof tagNames[0])
#endif
	fprintf(f, "%stag: %d (%s)\n", padding, dyn->d_tag,
	    dyn->d_tag >= 0 && dyn->d_tag <= DT_COUNT ?
	    tagNames[dyn->d_tag] : "(unknown)");
	fprintf(f, "%sword/addr: %d (%x)\n",
	    padding, dyn->d_un.d_val, dyn->d_un.d_val);
}
开发者ID:peadar,项目名称:hdmp,代码行数:40,代码来源:elf.c


示例11: putop

void putop(Instruction *insn,int op, int len)
{    
	int     i;
	char buf[100];

    i = 0;
//    while( opl[i].mnem )
//    {
//		if( opl[i].opcode == (op & 0x1FF))
//		{
			//seg = op & 0xFF00;
			//if (seg != 0) {
			//	fprintf(output, "%s:", segstr(op));
			//}
			if (len) {
				if (len <= 16) {
					switch(len) {
					case 1:	sprintf_s(buf, sizeof(buf), "%s.b", insn->mnem); break;
					case 2:	sprintf_s(buf, sizeof(buf), "%s.c", insn->mnem); break;
					case 4:	sprintf_s(buf, sizeof(buf), "%s.h", insn->mnem); break;
					case 8:	sprintf_s(buf, sizeof(buf), "%s", insn->mnem); break;
					}
				}
				else {
					if (len != 'w' && len!='W')
						sprintf_s(buf, sizeof(buf), "%s.%c", insn->mnem, len);
					else
						sprintf_s(buf, sizeof(buf), "%s", insn->mnem);
				}
			}
			else
				sprintf_s(buf, sizeof(buf), "%s", insn->mnem);
			ofs.write(pad(buf));
			return;
//		}
//		++i;
//    }
    printf("DIAG - illegal opcode (%d).\n", op);
}
开发者ID:robfinch,项目名称:Cores,代码行数:39,代码来源:Outcode.cpp


示例12: printEntries

    void printEntries(std::ostream &o, const std::vector<Entry *> &entries, const std::string &indent, double parent_time) {
      if (parent_time <= 0.0) {
        parent_time = 0.0;
        for (size_t i = 0; i < entries.size(); ++i) {
          parent_time += entries[i]->time;
        }
      }
      double t_tot = 0.0;
      for (size_t i = 0; i < entries.size(); ++i) {
        const Entry *entry = entries[i];

        std::ostringstream r;
        r << indent;
        std::string str = names[entry->id];
        if (str.empty()) {
          r << "(" << entry->id << ")";
        } else {
          r << str;
        }
        r << " ";
        std::string pad(r.str().size(), ' ');
        r << " - exectime: " << entry->time << "s (" << (entry->time * 100.0 / parent_time) << "%)" << std::endl;
        if (entry->allocTotal || entry->memoryDiff) {
          r << pad << " - alloc: " << formatMemory(entry->allocTotal) << " delta: " << formatMemory(entry->memoryDiff) << std::endl;
          r << pad << " - alloc blks:";
          for (int i = 0; i < 32; i++) { if (entry->delta_blk_cnt_total[i]) r << ' ' << ((1 << (i - 1)) + 1) << '-' << (1 << i) << ':' << entry->delta_blk_cnt_total[i]; }
          r << std::endl;
          r << pad << " - delta blks:";
          for (int i = 0; i < 32; i++) { if (entry->delta_blk_cnt_curr[i]) r << ' ' << ((1 << (i - 1)) + 1) << '-' << (1 << i) << ':' << entry->delta_blk_cnt_curr[i]; }
          r << std::endl;
        }
        o << r.str();
        t_tot += entry->time;
        if (entry->children.size()) printEntries(o, entry->children, indent + "   ", entry->time);
      }
      if (t_tot < parent_time) {
        o << indent << "*** unaccounted: " << (parent_time - t_tot) << "s   (" << (100.0 - t_tot * 100.0 / parent_time) << "%)" << std::endl;
      }
    }
开发者ID:BlueLabelStudio,项目名称:blender,代码行数:39,代码来源:timing.cpp


示例13: cmd_score

mixed cmd_score(string cmd, string str, object actor){
    mapping stats;
    int i;
    string *attributes;

    stats = actor->query_stats();
    attributes = map_indices(stats);
    i = sizeof(attributes);

    str = actor->query_Name() + "\n";

    while(i--){
	str += "%^BOLD%^%^CYAN%^"+pad(capitalize(attributes[i])+": ", 15)+"%^RESET%^"+stats[attributes[i]]+"\n";
    }
    #ifdef ASTARIA_CLONE
	str += "hp "+actor->query_health()+" / "+actor->query_max_health()+"\n";
    #else
    str += actor->query_diagram();
    #endif
    actor->message(str);
    return 1;
}
开发者ID:hambone20,项目名称:mudlib,代码行数:22,代码来源:cmd_score.c


示例14: modulePrefix

static inline std::string modulePrefix(module_t m, message_t msgType)
{
    if(m == MODULES_ALL) {
        switch(msgType) {
        case MSG_TRACE:
            return "[trace]   ";
        case MSG_DEBUG:
            return "[debug]   ";
        case MSG_INFO:
            return "[info]    ";
        case MSG_WARNING:
            return "[warning] ";
        case MSG_ERROR:
            return "[error]   ";
        case MSG_FATAL:
            return "[fatal]   ";
        default:
            return "[...]     ";
        }
    }
    return pad(std::string(1, '[') + moduleToString(m) + "] ");
}
开发者ID:nctan,项目名称:quneiform,代码行数:22,代码来源:log.cpp


示例15: pad

extern void *__construct_new_array(void *block,ConstructorDestructor ctor,ConstructorDestructor dtor,size_t size,size_t n)
{
	char	*ptr;

	if((ptr=(char *)block)!=0L)
	{
		size_t *p = (size_t *)ptr;
		//	store number of allocated objects and size of one object at the beginnig of the allocated block
		p[0]=size;
		p[1]=n;
		ptr+=ARRAY_HEADER_SIZE;

		if(ctor)
		{	//	call constructor to initialize array
			__partial_array_destructor pad(ptr,size,n,dtor);
			char	*p;

			for(pad.i=0,p=(char *)ptr; pad.i<n; pad.i++,p+=size) CTORCALL_COMPLETE(ctor,p);
		}
	}
	return ptr;	//	return pointer to first object;
}
开发者ID:reynoldsbd3,项目名称:robot-d5,代码行数:22,代码来源:NewArray.cpp


示例16: LineBufferCPU

void LineBufferCPU(int inH, int inW, int padH, int padW, int kH, int kW, int stride, float *kernel, float *dataIn, float *dataOut){
  int paddedH = inH+2*padH;
  int paddedW = inW+2*padW;
  float *padded = malloc(paddedH*paddedW*sizeof(float));
  pad(inH,inW,padH,padW,dataIn,padded); 
  int outH = (paddedH-kH) + 1;
  int outW = (paddedW-kW) + 1;
  float **lb = malloc(outH*outW*sizeof(float*));
  for (int i=0; i<outH*outW; i++) lb[i] = malloc(kH*kW*sizeof(float));
  lineBuffer(paddedH,paddedW,kH,kW,stride,padded,lb);
  print_2d_data(padded, "PADDED",paddedH,paddedW);
  free(padded);
  for (int i=0; i<outH*outW; i++) {
    dataOut[i] = 0;
    for(int j=0; j<kH*kW;j++) {
      dataOut[i] += kernel[j] *lb[i][j];
    }
  }
  for (int i=0; i<outH*outW; i++) free(lb[i]);
  free(lb);
  
}
开发者ID:rdaly525,项目名称:LineBuffer,代码行数:22,代码来源:LineBufferCpuCode.c


示例17: mSourceMesh

//-----------------------------------------------------------------------------
ImplicitMesh::ImplicitMesh(SimpleMesh * mesh) : mSourceMesh(mesh), mData(NULL)
{
  // Loop through all vertices in the mesh to determine the smallest
  // bounding box needed
  Vector3<float> pMin((std::numeric_limits<float>::max)(), (std::numeric_limits<float>::max)(), (std::numeric_limits<float>::max)());
  Vector3<float> pMax(-(std::numeric_limits<float>::max)(), -(std::numeric_limits<float>::max)(), -(std::numeric_limits<float>::max)());
  const std::vector<SimpleMesh::Vertex>& verts = mSourceMesh->GetVerts();
  for(unsigned int i=0; i < verts.size(); i++){
    const SimpleMesh::Vertex &v = verts.at(i);
    for (int j = 0; j < 3; j++) {
      if (pMin[j] > v.pos[j]) pMin[j] = v.pos[j];
      if (pMax[j] < v.pos[j]) pMax[j] = v.pos[j];
    }
  }

  // Pad with 0.1 to get around border issues
  Vector3<float> pad(0.1, 0.1, 0.1);
  pMin -= pad;
  pMax += pad;
  mBox = Bbox(pMin, pMax);
  std::cout << "Bounding box of implicit mesh: " << mBox << std::endl;
}
开发者ID:eriol726,项目名称:TNM079,代码行数:23,代码来源:ImplicitMesh.cpp


示例18: parent

void VCXYPad_Test::copy()
{
    QWidget w;

    VCFrame parent(&w, m_doc);
    VCXYPad pad(&parent, m_doc);
    pad.setCaption("Dingdong");
    QSize size(80, 80);
    QPointF pt(50, 30);
    pad.m_area->setPosition(pt);

    VCXYPadFixture xyf1(m_doc);
    xyf1.setHead(GroupHead(1,5));
    pad.appendFixture(xyf1);

    VCXYPadFixture xyf2(m_doc);
    xyf2.setHead(GroupHead(2,7));
    pad.appendFixture(xyf2);

    VCXYPadFixture xyf3(m_doc);
    xyf3.setHead(GroupHead(3,9));
    pad.appendFixture(xyf3);

    VCXYPad* copy = qobject_cast<VCXYPad*> (pad.createCopy(&parent));
    QVERIFY(copy != NULL);
    QCOMPARE(copy->m_fixtures.size(), 3);
    QVERIFY(copy->m_fixtures[0] == xyf1);
    QVERIFY(copy->m_fixtures[1] == xyf2);
    QVERIFY(copy->m_fixtures[2] == xyf3);

    QVERIFY(&copy->m_fixtures[0] != &xyf1);
    QVERIFY(&copy->m_fixtures[1] != &xyf2);
    QVERIFY(&copy->m_fixtures[2] != &xyf3);

    QCOMPARE(copy->m_area->position(), pt);
    QCOMPARE(copy->size(), pad.size());
    QCOMPARE(copy->caption(), QString("Dingdong"));
}
开发者ID:Babbsdrebbler,项目名称:qlcplus,代码行数:38,代码来源:vcxypad_test.cpp


示例19: get_name

string dsp::PlotFactory::help()
{
    unsigned ia, maxlen = 0;
    for (ia=0; ia < agents.size(); ia++) {
        if (get_name(ia).length() > maxlen) {
            maxlen = get_name(ia).length();
        }
    }

    maxlen += 2;
    string result;

    for (ia=0; ia < agents.size(); ia++) {
        result += pad(maxlen, get_name(ia)) +
                  "[" +
                  agents[ia]->get_shortcut() +
                  "]  " +
                  get_description(ia) +
                  "\n";
    }

    return result;
}
开发者ID:steve-ord,项目名称:dspsr,代码行数:23,代码来源:PlotFactory.C


示例20: create_and_secure

/*---------------------------------------------------------------------------*/
static int
create_and_secure(void)
{
  struct hdr *chdr;
  int hdr_len;
  
  hdr_len = create();
  if(hdr_len < 0) {
    return FRAMER_FAILED;
  }
  
  packetbuf_compact();
  if(!NETSTACK_LLSEC.on_frame_created()) {
    PRINTF("contikimac-framer: securing failed\n");
    return FRAMER_FAILED;
  }
  
  chdr = (struct hdr *)(((uint8_t *) packetbuf_dataptr()) - sizeof(struct hdr));
  chdr->len = packetbuf_datalen();
  pad();
  
  return hdr_len;
}
开发者ID:200018171,项目名称:contiki,代码行数:24,代码来源:contikimac-framer.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ padding函数代码示例发布时间:2022-05-30
下一篇:
C++ packstr函数代码示例发布时间: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