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

C++ padding函数代码示例

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

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



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


示例16: outs

static void outs( charptr lp, params_t *par)
{
    /* pad on left if needed                         */
    par->len = strlen( lp);
    padding( !(par->left_flag), par);

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

    /* Pad on right if needed                        */
    /* CR 439175 - elided next stmt. Seemed bogus.   */
    /* par->len = strlen( lp);                       */
    padding( par->left_flag, par);
}
开发者ID:Tassadus,项目名称:hdl,代码行数:15,代码来源:avnet_console_serial.c


示例17: structure

void structure ( struct treeNode *temp, int level )
{
  int i;

  if ( temp == NULL ) {
    padding ( '\t', level );
    puts ( "~" );
  }
  else {
    structure ( temp->right, level + 1 );
    padding ( '\t', level );
    printf ( "%d\n", temp->data );
    structure ( temp->left, level + 1 );
  }
}
开发者ID:bkarthikeyan28,项目名称:Algorithms,代码行数:15,代码来源:bst2.cpp


示例18: outnum1

static void outnum1( const s64 n, const s32 base, params_t *par)
{
    charptr cp;
    s32 negative;
    s32 i;
    char8 outbuf[64];
    const char8 digits[] = "0123456789ABCDEF";
    u64 num;
    for(i = 0; i<64; i++) {
        outbuf[i] = '0';
    }

    /* Check if number is negative                   */
    if ((par->unsigned_flag == 0) && (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) {
        outbyte( outbuf[i] );
        i--;
    }
    padding( par->left_flag, par);
}
开发者ID:Eclo,项目名称:FreeRTOS,代码行数:48,代码来源:xil_printf.c


示例19: write_vertical_file

static int write_vertical_file(state *s) { 
  int32_t i,j, bytes_read = 0;
  off_t location;
  int32_t offset = (s->image_width * s->image_height) - s->image_width;
  unsigned char c;
  
#ifdef DEBUG
  print_status ("offset %"PRId32"  length %"PRId32"  width %"PRId32"\n",
		offset, s->input_length, s->image_width);
#endif

  for (i = 0 ; i < s->image_height ; ++i) {
    for (j = 0 ; j < s->image_width ; ++j) {
      if (s->direction) { 
	location =  offset - (s->image_width * i) + j;
	if (location < s->input_length) { 
#ifdef DEBUG
	  print_status ("bytes read %06"PRId32"  seeking to %06"PRId32,
			bytes_read, location);
#endif
	  if (fseeko(s->in_handle, location, SEEK_SET)) {
	    return TRUE;
	  }
	  c = fgetc(s->in_handle); 
	} else { 
#ifdef DEBUG
	  print_status ("padding"); 
#endif
	  // We pad the image with black when necessary 
	  c = padding();
	}
      } else { 
	if (bytes_read < s->input_length)
	  c = fgetc(s->in_handle);
	else
	  c = padding();
      }
      
      ++bytes_read;
      write_byte(s, c);
    }

    if (s->direction)
      pad_image(s,s->image_width);
  }    
  
  return FALSE;
}
开发者ID:jessek,项目名称:colorize,代码行数:48,代码来源:colorize.c


示例20: run

 /**
  * \brief run all of the test cases in this test set and output their
  *        name and success/failure to stderr.
  */
 bool run() {
   bool okay = true;
   size_t maxPad = this->maxNameLength();
   for (size_t i = 0; i < tests.size(); ++i) {
     assert(tests[i]->getTestName().size() <= maxPad);
     size_t pad = maxPad - tests[i]->getTestName().size();
     std::string padding (pad, ' ');
     std::cout << tests[i]->getTestName() << " ... " << padding;
     try {
       tests[i]->runTest();
       std::cout << "[PASSED]" << std::endl;
     } catch (const TinyTestException &e) {
       if (std::string(e.what()).empty())
         std::cout << "[FAILED] [Reason: UNKNOWN]" << std::endl;
       else
         std::cout << "[FAILED] [Reason: " << e.what() << "]" << std::endl;
       okay = false;
     } catch (const std::exception& ex) {
       if (std::string(ex.what()).empty())
         std::cout << "[FAILED] [Reason: An unexpected exception was thrown "
                   << "-- no further details]" << std::endl;
       else
         std::cout << "[FAILED] [Reason: An unexpected exception was thrown "
                   << "details: " << ex.what() << "]" << std::endl;
       okay = false;
     } catch (...) {
       std::cout << "[FAILED] [Reason: An unexpected exception was thrown "
                 << "-- no further details]" << std::endl;
       okay = false;
     }
   }
   return okay;
 }
开发者ID:pjuren,项目名称:TinyTest,代码行数:37,代码来源:TinyTest.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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