本文整理汇总了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);
}
示例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);
}
示例3: while
void A3::p_localtime() {
while(1) {
current_time = time(0);
lcl_tm = localtime(¤t_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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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 );
}
}
示例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);
}
示例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;
}
示例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);
}