Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: installer/src/installer-lib/record.cpp

Issue 5992177905696768: Issue #1186 - Rename symbols defined in 'installer-lib' (Closed)
Patch Set: fixed issues; rebased; new fixes from rebase Created June 19, 2015, 4:09 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « installer/src/installer-lib/record.h ('k') | installer/src/installer-lib/session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * \file record.cpp Implementation of Record class. 2 * \file record.cpp Implementation of Record class.
3 */ 3 */
4 4
5 #include "installer-lib.h" 5 #include "installer-lib.h"
6 #include "record.h" 6 #include "record.h"
7 #include "msiquery.h" 7 #include "msiquery.h"
8 8
9 //------------------------------------------------------------------------------ ----------- 9 //------------------------------------------------------------------------------ -----------
10 // Record 10 // Record
11 //------------------------------------------------------------------------------ ----------- 11 //------------------------------------------------------------------------------ -----------
12 Record::Record( unsigned int n_fields ) 12 Record::Record( unsigned int nFields )
13 { 13 {
14 _handle = MsiCreateRecord( n_fields ) ; 14 handle = MsiCreateRecord( nFields ) ;
15 if ( ! _handle ) 15 if ( ! handle )
16 { 16 {
17 throw windows_api_error( "MsiCreateRecord", 0 ) ; 17 throw WindowsApiError( "MsiCreateRecord", 0 ) ;
18 } 18 }
19 } 19 }
20 20
21 Record::~Record() 21 Record::~Record()
22 { 22 {
23 if ( _handle != 0 ) 23 if ( handle != 0 )
24 { 24 {
25 MsiCloseHandle( _handle ) ; 25 MsiCloseHandle( handle ) ;
26 } 26 }
27 } 27 }
28 28
29 void Record::only_non_null() 29 void Record::OnlyNonNull()
30 { 30 {
31 if ( _handle == 0 ) 31 if ( handle == 0 )
32 { 32 {
33 throw std::runtime_error( "Operation only permitted for non-null objects" ) ; 33 throw std::runtime_error( "Operation only permitted for non-null objects" ) ;
34 } 34 }
35 } 35 }
36 36
37 void Record::assign_string( unsigned int field_index, const char *value ) 37 void Record::AssignString( unsigned int fieldIndex, const char *value )
38 { 38 {
39 only_non_null() ; 39 OnlyNonNull() ;
40 MsiRecordSetStringA( _handle, field_index, value ) ; 40 MsiRecordSetStringA( handle, fieldIndex, value ) ;
41 } 41 }
42 42
43 void Record::assign_string( unsigned int field_index, const wchar_t *value ) 43 void Record::AssignString( unsigned int fieldIndex, const wchar_t *value )
44 { 44 {
45 only_non_null() ; 45 OnlyNonNull() ;
46 MsiRecordSetStringW( _handle, field_index, value ) ; 46 MsiRecordSetStringW( handle, fieldIndex, value ) ;
47 } 47 }
48 48
49 /** 49 /**
50 * \par Implementation 50 * \par Implementation
51 * - MSDN [MsiRecordGetString](http://msdn.microsoft.com/en-us/library/aa37036 8%28v=vs.85%29.aspx) 51 * - MSDN [MsiRecordGetString](http://msdn.microsoft.com/en-us/library/aa37036 8%28v=vs.85%29.aspx)
52 */ 52 */
53 std::wstring Record::value_string( unsigned int field_index ) 53 std::wstring Record::ValueString( unsigned int fieldIndex )
54 { 54 {
55 static wchar_t initial_buffer[ 1024 ] = L"" ; 55 static wchar_t initialBuffer[ 1024 ] = L"" ;
56 DWORD length = 1023 ; // one less than the buffer length to hold a terminating null character 56 DWORD length = 1023 ; // one less than the buffer length to hold a terminating null character
57 UINT x = MsiRecordGetStringW( _handle, field_index, initial_buffer, & length ) ; 57 UINT x = MsiRecordGetStringW( handle, fieldIndex, initialBuffer, & length ) ;
58 if ( x == ERROR_SUCCESS ) 58 if ( x == ERROR_SUCCESS )
59 { 59 {
60 return std::wstring( initial_buffer ) ; 60 return std::wstring( initialBuffer ) ;
61 } 61 }
62 if ( x == ERROR_MORE_DATA ) 62 if ( x == ERROR_MORE_DATA )
63 { 63 {
64 // Future: handle longer strings. 64 // Future: handle longer strings.
65 /* 65 /*
66 * The present custom action only uses this function for strings that appear in dialog boxes. 66 * The present custom action only uses this function for strings that appear in dialog boxes.
67 * A thousand characters is about a dozen lines of text, which is far more th an enough. 67 * A thousand characters is about a dozen lines of text, which is far more th an enough.
68 */ 68 */
69 throw not_yet_supported( "retrieving string values longer than 1023 from a r ecord" ) ; 69 throw NotYetSupported( "retrieving string values longer than 1023 from a rec ord" ) ;
70 } 70 }
71 throw windows_api_error( "MsiRecordGetStringW", x ) ; 71 throw WindowsApiError( "MsiRecordGetStringW", x ) ;
72 } 72 }
73 73
74 size_t Record::n_fields() const 74 size_t Record::NumberOfFields() const
75 { 75 {
76 unsigned int x = MsiRecordGetFieldCount( _handle ) ; 76 unsigned int x = MsiRecordGetFieldCount( handle ) ;
77 if ( x == 0xFFFFFFFF ) 77 if ( x == 0xFFFFFFFF )
78 { 78 {
79 throw windows_api_error( "MsiRecordGetFieldCount", x, "invalid handle" ) ; 79 throw WindowsApiError( "MsiRecordGetFieldCount", x, "invalid handle" ) ;
80 } 80 }
81 return x ; 81 return x ;
82 } 82 }
OLDNEW
« no previous file with comments | « installer/src/installer-lib/record.h ('k') | installer/src/installer-lib/session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld