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


C++ padding函数代码示例

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


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

示例1: outnum

static void outnum(unsigned int num, const long base)
{
	char* cp;
	int negative;
	char outbuf[32];
	const char digits[] = "0123456789ABCDEF";

	/* Check if number is negative                    */
	/* NAK 2009-07-29 Negate the number only if it is not a hex value. */
	if ((int)num < 0L && base != 16L) {
		negative = 1;
		num = -num;
	}
	else
		negative = 0;

	/* Build number (backwards) in outbuf             */
	cp = outbuf;
	do {
		*cp++ = digits[(int)(num % base)];
	} while ((num /= base) > 0);
	if (negative)
		*cp++ = '-';
	*cp-- = 0;

	/* Move the converted number to the buffer and    */
	/* add in the padding where needed.               */
	len = strlen(outbuf);
	padding(!left_flag);
	while (cp >= outbuf)
		out_char(*cp--);
	padding(left_flag);
}
开发者ID:ChaiSoft,项目名称:ChaiOS,代码行数:33,代码来源:printf.cpp

示例2: outnum

static void outnum( const long n, const long base, params_t *par)
{
    charptr cp;
    int negative;
    char outbuf[32];
    const char digits[] = "0123456789ABCDEF";
    unsigned long num;

    /* Check if number is negative                   */
    if (base == 10 && n < 0L) {
        negative = 1;
        num = -(n);
    }
    else{
        num = (n);
        negative = 0;
    }

    /* Build number (backwards) in outbuf            */
    cp = outbuf;
    do {
        *cp++ = digits[(int)(num % base)];
    } while ((num /= base) > 0);
    if (negative)
        *cp++ = '-';
    *cp-- = 0;

    /* Move the converted number to the buffer and   */
    /* add in the padding where needed.              */
    par->len = strlen(outbuf);
    padding( !(par->left_flag), par);
    while (cp >= outbuf)
        OS_PUTCHAR( *cp--);
    padding( par->left_flag, par);
}
开发者ID:Tassadus,项目名称:hdl,代码行数:35,代码来源:avnet_console_serial.c

示例3: while

void A3::p_localtime() {
	while(1) {
		current_time = time(0);
		lcl_tm = localtime(&current_time);
		cout << getpid() << " - Current Time - " << padding(lcl_tm->tm_hour,2) << ":" << padding(lcl_tm->tm_min,2) << ":" << padding(lcl_tm->tm_sec,2) << endl;
		sleep(1);
	}
}
开发者ID:Wooklien,项目名称:Operation-Systems,代码行数:8,代码来源:A3.cpp

示例4: print_rule

void print_rule(const EtalisEventNode* temp_event)
{
    padding(' ',4) ;
    printf("New Rule ->\n");
    padding(' ',14);
    printf("+Label: %s\n",temp_event->childNode->label);
    padding(' ',14);
    printf("+Complex Event: %s/%d\n",temp_event->event.name,temp_event->event.arity);
    padding(' ',14);
    printf("+Final Operator: %s\n",temp_event->childNode->name);
    if(temp_event->childNode->condition != NULL)
    {
        padding(' ',14);
        printf("+Node Condition: %s\n",temp_event->childNode->condition);
    }
    if(temp_event->childNode->window_size != 0)
    {
        padding(' ',14);
        printf("+Sliding Window Size: %f sec\n",temp_event->childNode->window_size);
    }
    else
    {
        padding(' ',14);
        printf("+Sliding Window Size: Unlimited\n");
    }
    padding(' ',14);
    printf("[email protected]: %s/%d\n",temp_event->childNode->leftChild->event.name,temp_event->childNode->leftChild->event.arity);
    if(temp_event->childNode->op_type == binary)
    {
        padding(' ',14);
        printf("[email protected]: %s/%d\n",temp_event->childNode->rightChild->event.name,temp_event->childNode->rightChild->event.arity);
    }

}
开发者ID:sspider,项目名称:etalis,代码行数:34,代码来源:events.c

示例5: printTree

void printTree(Node* root, int depth) {
	if (root == NULL) {
		padding(depth);
		printf("~\n");
	} else {
		printTree(root->right, depth + 1);
		padding(depth);
		printf("%d\n", root->data);
		printTree(root->left, depth + 1);
	}
}
开发者ID:meyerben,项目名称:cs2050,代码行数:11,代码来源:prelab9.c

示例6: unit_test_int

void unit_test_int(const char* msg, long long attendu, long long obtenu) {
	int len = strlen(msg);
	printf("%s", msg);
	if (attendu == obtenu) {
		padding(80 - len - 4);
		printf("[OK]\n");
	} else {
		padding(80 - len - 7);
		printf("[ERROR]\n");
		printf("Attendu : %ld, Obtenu : %ld\n", attendu, obtenu);
	}
}
开发者ID:TacOS-team,项目名称:tacos,代码行数:12,代码来源:unittest.c

示例7: QFontMetrics

QPainterPath CompassFloatItem::backgroundShape() const
{
    QRectF contentRect = this->contentRect();
    QPainterPath path;
    int fontheight = QFontMetrics( font() ).ascent();
    int compassLength = static_cast<int>( contentRect.height() ) - 5 - fontheight;

    path.addEllipse( QRectF( QPointF( marginLeft() + padding() + ( contentRect.width() - compassLength ) / 2,
                                      marginTop() + padding() + 5 + fontheight ),
                             QSize( compassLength, compassLength ) ).toRect() );
    return path;
}
开发者ID:KDE,项目名称:marble,代码行数:12,代码来源:CompassFloatItem.cpp

示例8: displayTree

void displayTree(Node* root, int depth){
    if (root == NULL) {
        padding (' ', depth);
        printf("-\n");
    }
    else {
        displayTree(root->right, depth+1);
        padding(' ', depth);
        printf ( "%d\n", root->data);
        displayTree(root->left, depth+1);
    }
}
开发者ID:RaymondLC92,项目名称:Basic-C-Projects,代码行数:12,代码来源:main.c

示例9: unit_test_str

void unit_test_str(const char* msg, const char* attendu, const char* obtenu) {
	int len = strlen(msg);
	printf("%s", msg);
	if (strcmp(attendu, obtenu) == 0) {
		padding(80 - len - 4);
		printf("[OK]\n");
	} else {
		padding(80 - len - 7);
		printf("[ERROR]\n");
		printf("Attendu : %s, Obtenu : %s\n", attendu, obtenu);
	}
}
开发者ID:TacOS-team,项目名称:tacos,代码行数:12,代码来源:unittest.c

示例10: structure

void structure(BST* root, int level) {
    int i;

    if (root == NULL) {
        padding('\t', level);
        puts("~");
    } else {
        structure(root->right, level+1);
        padding('\t', level);
        printf("%d\n", root->data);
        structure(root->left, level+1);
    }
}
开发者ID:PercyODI,项目名称:SentimentAnalysis,代码行数:13,代码来源:preLab10.c

示例11: serialise

std::string DatFile::serialise(const std::string &key, const std::string &value)
{
	std::string output;
	output.append(key);
	output.append(padding(1));
	output.append(std::string(1,char(2)));
	output.append(padding(1));
	output.append(nullPad(value));
	if(output.length() > 128)
		output = output.substr(0,128);
	else
		output.append(padding(128 - output.length()));
	return output;
}
开发者ID:irv,项目名称:FU-NW-HD5,代码行数:14,代码来源:datfile.cpp

示例12: printBaum

void printBaum ( struct baum *root, int level )
{
	int i;
	if ( root == NULL ) {
		padding ( '\t', level );
		puts ( "~" );
	}
	else {
		printBaum ( root->rechts, level + 1 );
		padding ( '\t', level );
		printf ( "%d\n", root->wert );
		printBaum ( root->links, level + 1 );
	}
}
开发者ID:FriedrichF,项目名称:SystemnaheProgrammierung,代码行数:14,代码来源:main.c

示例13: outs

static void outs( char * lp)
{
	/* pad on left if needed                          */
	len = strlen((const char *)lp);
	padding( !left_flag);

	/* Move string to the buffer                      */
	while (*lp && num2--)
		out_char( *lp++);

	/* Pad on right if needed                         */
	len = strlen((const char *)lp);
	padding( left_flag);
}
开发者ID:jeehunseo,项目名称:j_guider_kernel,代码行数:14,代码来源:printf.c

示例14: contentRect

QPainterPath ProgressFloatItem::backgroundShape() const
{
    QPainterPath path;

    if ( active() ) {
        // Circular shape if active, invisible otherwise
        QRectF rect = contentRect();
        qreal width = rect.width();
        qreal height = rect.height();
        path.addEllipse( marginLeft() + 2 * padding(), marginTop() + 2 * padding(), width, height );
    }

    return path;
}
开发者ID:Earthwings,项目名称:marble,代码行数:14,代码来源:ProgressFloatItem.cpp

示例15: outnum

static void outnum( const s32 n, const s32 base, struct params_s *par)
{
    charptr cp;
    s32 negative;
	s32 i;
    char8 outbuf[32];
    const char8 digits[] = "0123456789ABCDEF";
    u32 num;
    for(i = 0; i<32; i++) {
	outbuf[i] = '0';
    }

    /* Check if number is negative                   */
    if ((base == 10) && (n < 0L)) {
        negative = 1;
		num =(-(n));
    }
    else{
        num = n;
        negative = 0;
    }

    /* Build number (backwards) in outbuf            */
    i = 0;
    do {
		outbuf[i] = digits[(num % base)];
		i++;
		num /= base;
    } while (num > 0);

    if (negative != 0) {
		outbuf[i] = '-';
		i++;
	}

    outbuf[i] = 0;
    i--;

    /* Move the converted number to the buffer and   */
    /* add in the padding where needed.              */
    par->len = (s32)strlen(outbuf);
    padding( !(par->left_flag), par);
    while (&outbuf[i] >= outbuf) {
#ifdef STDOUT_BASEADDRESS
	outbyte( outbuf[i] );
		i--;
#endif
}
    padding( par->left_flag, par);
}
开发者ID:AfterRace,项目名称:SoC_Project,代码行数:50,代码来源:xil_printf.c


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