UUID/UUID.cpp

This sample program demonstates uuid generation with the DWFCore::DWFUUID class and was used as a smoke test for algorithm implementation and duplicate detection.

Also shown in the sample:

00001 //
00002 //  Copyright (c) 2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 #include "stdafx.h"
00023 
00024 
00025 using namespace std;
00026 using namespace DWFCore;
00027 
00028 
00029 #define TESTS   32
00030 #define LOOP    66555
00031 
00032 
00033 int dmain()
00034 {
00035     char    abc[] = "abcdefgh";
00036     char*   p = &abc[7];
00037     char    buf[64] = {0};
00038 
00039 
00040     DWFCore::DWFString::EncodeBase64( abc, 8, buf, 64, false );
00041     cout << buf << endl;
00042 
00043     (*p)+=16;
00044 
00045     DWFCore::DWFString::EncodeBase64( abc, 8, buf, 64, false );
00046     cout << buf << endl;
00047     return 0;
00048 }
00049 
00050 int main()
00051 {
00052         bool bOK = true;
00053 
00054         for (unsigned int t = 0; t < TESTS; t++)
00055         {
00056             DWFCore::DWFUUID oUUID;
00057             DWFCore::DWFStringKeySkipList<bool>  oList;
00058 
00059             for (unsigned int i = 0; i < LOOP; i++)
00060             {
00061                 //if (i == 0)
00062                 //{
00063                     //wcout << "(" << t << ", " << i << ") " << (const wchar_t*)oUUID.uuid(false) << "\n";
00064                 //}
00065 
00066                 DWFCore::DWFString zUUID = oUUID.next(false);
00067                 if (false == oList.insert(zUUID, true))
00068                 {
00069                     bOK = false;
00070                     wcout << "(" << t << ", " << i << ") DUPLICATE " << (const wchar_t*)zUUID << "\n";
00071                 }
00072             }
00073 
00074             wcout << ".";
00075         }
00076 
00077         cout<<"\nOK\n";
00078    
00079     return 0;
00080 }

Generated on Tue Jan 6 22:39:28 2009 for Autodesk DWF Core Library by  doxygen 1.4.5