Thursday, September 23, 2010
Friday, September 17, 2010
Wednesday, September 15, 2010
SYSTEMTIME Structure
http://msdn.microsoft.com/en-us/library/ms724950(VS.85).aspx
typedef struct _SYSTEMTIME { WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME, *PSYSTEMTIME;
Constants
|
3.14159L // long double 6.02e23f // float
'z' 'p' "Hello world" "How do you do?"
\n
newline \r
carriage return \t
tab \v
vertical tab \b
backspace \f
form feed (page feed) \a
alert (beep) \'
single quote (') \"
double quote (") \?
question mark (?) \\
backslash (\)
For example:
1
2
3
4
'\n' '\t' "Left \t Right" "one\ntwo\nthree"
More at link.
fmod
double fmod ( double numerator, double denominator ); float fmod ( float numerator, float denominator ); long double fmod ( long double numerator, long double denominator );
COleDatTime::COleDateTime
COleDateTime( ) throw( ); COleDateTime( const VARIANT& varSrc ) throw( ); COleDateTime( DATE dtSrc ) throw( ); COleDateTime( time_t timeSrc ) throw( ); COleDateTime( __time64_t timeSrc ) throw( ); COleDateTime( const SYSTEMTIME& systimeSrc ) throw( ); COleDateTime( const FILETIME& filetimeSrc ) throw( ); COleDateTime( int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec ) throw( ); COleDateTime( WORD wDosDate, WORD wDosTime ) throw( ); COleDateTime( const DBTIMESTAMP& dbts ) throw();
Re: Time DBTIMESTAMP
http://msdn.microsoft.com/en-us/library/c3zzz087(v=VS.80).aspx
Function for getting the DBTIMESTAMP.
bool GetAsDBTIMESTAMP( DBTIMESTAMP& dbts ) const throw();
The fraction time is from 0 to 999,999,999.Not really sure what good this does since you can only get it for the current time and any translation of time rounds to the nearest second.DBTIMESTAMPThe DBTIMESTAMP structure typedef is defined as follows:
typedef struct tagDBTIMESTAMP { SHORT year; USHORT month; USHORT day; USHORT hour; USHORT minute; USHORT second; ULONG fraction } DBTIMESTAMP;Members
- year
- The year (0 to 9999) is measured from 0 A.D.
- month
- The month ranges from 1 to 12 representing January through December.
- day
- The day ranges from 1 to a maximum of 31, depending on the number of days in the month.
- hour
- The hour ranges from 0 to 23.
- minute
- The minute ranges from 0 to 59.
- second
- The second ranges from 0 to 59.
- fraction
- The fraction represents billionths of a second ranging from 0 to 999,999,999.
Time DBTIMESTAMP
The DBTIMESTAMP structure typedef is defined as follows:
typedef struct tagDBTIMESTAMP { SHORT year; USHORT month; USHORT day; USHORT hour; USHORT minute; USHORT second; ULONG fraction } DBTIMESTAMP;
Members
- year
- The year (0 to 9999) is measured from 0 A.D.
- month
- The month ranges from 1 to 12 representing January through December.
- day
- The day ranges from 1 to a maximum of 31, depending on the number of days in the month.
- hour
- The hour ranges from 0 to 23.
- minute
- The minute ranges from 0 to 59.
- second
- The second ranges from 0 to 59.
- fraction
- The fraction represents billionths of a second ranging from 0 to 999,999,999.
Tuesday, September 07, 2010
DATE Delta
OLE Date/Time
The time structure is has greater resolution:'yyyy-mm-dd hh:mm:ss[.999]
'hh:mm:ss[.9999999]
Time Management, Conversion of system time to CTime
Friday, September 03, 2010
Static Variables
class C { static int i; static int j; static int k; static int l; static int m; static int n; static int p; static int q; static int r; static int s; static int f() { return 0; } int a; public: C() { a = 0; } };
C c; int C::i = C::f(); // initialize with static member function int C::j = C::i; // initialize with another static data member int C::k = c.f(); // initialize with member function from an object int C::l = c.j; // initialize with data member from an object int C::s = c.a; // initialize with nonstatic data member int C::r = 1; // initialize with a constant value
class Y : private C {} y; int C::m = Y::f(); int C::n = Y::r; int C::p = y.r; // error int C::q = y.f(); // error
Asserts, Exceptions
Can the error be managed?Yes - throw exception and handle it.No - use assert.
Can you write a unit test that is able to throw the exception?Exception example:
Yes - exception
No - assert
Are you protecting against a coding error?
Yes - assert
No - exception
Are you protecting against 'normal program' (i.e. file not writable etc.):
Yes - exception
No - assert
try { throw CSomeOtherException(); } catch(...) { // Handle all exceptions // Respond (perhaps only partially) to exception throw; // Pass exception to some other handler }
Tuesday, August 31, 2010
CArray Members
CString Methods at MSDN
BSTR GetBSTR()
{
_bstr_t bstr1(_T("This is the test string."));
BSTR bstr; bstr = bstr1.copy();
return bstr;
}
CComBSTR GetComBSTR()
{
CComBSTR bstr("This is the test string.");
return bstr;
}
void CVbsDlg::ShowBSTR(BSTR bstr)
{
_bstr_t bstrStart(bstr);
CString s;
s.Format(_T("%s"), (LPCTSTR)bstrStart); AfxMessageBox(s);
}
COleDateTime:: Format
DATE Description and Use
Friday, August 27, 2010
CArray CString Example
#include <Afxwin.h>
#include <Afxtempl.h>
void main()
{
CString l_strValue;
CArray<CString,CString> l_CArray;
for(int i=0;i< 20; i++)
{//Use the CString format function to create different values
l_strValue.Format("Value %d",i);
//Add the formatted CString to CArray
l_CArray.Add(l_strValue);}
}
#include <Afxwin.h>
#include <Afxtempl.h>
void main()
{
CString l_strValue;
CArray<CString,CString> l_CArray;
for(int i=0;i< 20; i++)
{//Use the CString format function to create different values
l_strValue.Format("Value %d",i);
//Add the formatted CString to CArray
l_CArray.Add(l_strValue);}
//This part takes care of accessing and printing the data from CArray
CString l_strGetVal;
for(i=0;i<=l_CArray.GetUpperBound();i++)
{
l_strGetVal = l_CArray.GetAt(i);
printf("%s\n",l_strGetVal);
}
}
l_CArray.RemoveAll() //This will remove all the elements from CArray
l_CArray.RemoveAt(10); //This will remove the 10th element from CArray