Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

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:

#include "stdafx.h"


using namespace std;
using namespace DWFCore;


#define TESTS   32
#define LOOP    66555


int dmain()
{
    char    abc[] = "abcdefgh";
    char*   p = &abc[7];
    char    buf[64] = {0};


    DWFCore::DWFString::EncodeBase64( abc, 8, buf, 64, false );
    cout << buf << endl;

    (*p)+=16;

    DWFCore::DWFString::EncodeBase64( abc, 8, buf, 64, false );
    cout << buf << endl;
    return 0;
}

int main()
{
    bool bOK = true;

    try
    {
        for (unsigned int t = 0; t < TESTS; t++)
        {
            DWFCore::DWFUUID oUUID;
            DWFCore::DWFStringKeySkipList<bool>  oList;

            for (unsigned int i = 0; i < LOOP; i++)
            {
                //if (i == 0)
                //{
                    //wcout << "(" << t << ", " << i << ") " << (const wchar_t*)oUUID.uuid(false) << "\n";
                //}

                DWFCore::DWFString zUUID = oUUID.next(false);
                if (false == oList.insert(zUUID, true))
                {
                    bOK = false;
                    wcout << "(" << t << ", " << i << ") DUPLICATE " << (const wchar_t*)zUUID << "\n";
                }
            }

            wcout << ".";
        }

        cout<<"\nOK\n";
    }
    catch (DWFCore::DWFException& ex)
    {
        wcout << ex.type() << endl;
        wcout << ex.message() << endl;
        wcout << ex.function() << endl;
        wcout << ex.file() << endl;
        wcout << ex.line() << endl;
    }

    return 0;
}

Generated on Tue May 17 12:05:10 2005 for Autodesk DWF Core Library by  doxygen 1.4.1