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


C++ pad函数代码示例

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


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


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