-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinaryRDL.cpp
More file actions
99 lines (75 loc) · 1.64 KB
/
BinaryRDL.cpp
File metadata and controls
99 lines (75 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
BinaryRDL.cpp - Implementation of BinaryRDL.
Jason Hood, 2 & 3 December, 2009.
*/
#include "BinaryRDL.h"
#include "internal.h"
#include <cstdlib>
#include <cstdarg>
void BinaryRDL::add_node( int node, int len )
{
int new_size = size + 8 + len;
if (new_size > capacity)
{
capacity = new_size;
char* temp = new char[capacity];
memcpy( temp, brdl, size );
delete[] brdl;
brdl = temp;
data.c = brdl + size;
}
size = new_size;
*data.i++ = node;
*data.i++ = len;
}
void BinaryRDL::TRA( UINT tra, UINT mask )
{
add_node( TRANode, 8 );
*data.i++ = tra; // TextRenderAttributes
*data.i++ = mask;
}
void BinaryRDL::style( USHORT style )
{
add_node( StyleNode, 2 );
*data.s++ = style;
}
void BinaryRDL::para()
{
add_node( ParagraphNode, 2 ); // ignores it if it's zero; use 2 to keep
*data.s++ = 0; // word (wchar_t) alignment
}
void BinaryRDL::string( LPCWSTR str )
{
int len = (wcslen( str ) + 1) * sizeof(WCHAR);
add_node( TextNode, len );
memcpy( data.w, str, len );
data.c += len;
}
void BinaryRDL::string( LPCSTR str )
{
mbstowcs( wstrbuf, str, *wstrlen );
string( wstrbuf );
}
void BinaryRDL::strid( UINT id )
{
GetString( RSRC, id, wstrbuf, *wstrlen );
string( wstrbuf );
}
void BinaryRDL::printf( LPCWSTR fmt, ... )
{
va_list args;
va_start( args, fmt );
_vsnwprintf( wstrbuf, *wstrlen, fmt, args );
va_end( args );
string( wstrbuf );
}
void BinaryRDL::printf( UINT ifmt, ... )
{
WCHAR fmt[128];
GetString( RSRC, ifmt, fmt, 128 );
va_list args;
va_start( args, ifmt );
_vsnwprintf( wstrbuf, *wstrlen, fmt, args );
va_end( args );
string( wstrbuf );
}