searchengine/cpix/tsrc/cpixunittest/src/testutils.cpp
changeset 0 671dee74050a
child 3 ae3f1779f6da
equal deleted inserted replaced
-1:000000000000 0:671dee74050a
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <dirent.h>
       
    19 #include <errno.h>
       
    20 #include <wchar.h>
       
    21 #include <stddef.h>
       
    22 
       
    23 #include <iostream>
       
    24 #include <sstream>
       
    25 #include <fstream>
       
    26 
       
    27 #include "cpixidxdb.h"
       
    28 
       
    29 #include "itk.h"
       
    30 
       
    31 #include "config.h"
       
    32 
       
    33 
       
    34 
       
    35 #include "testutils.h"
       
    36 
       
    37 std::wstring GetItemId(int itemIndex)
       
    38 {
       
    39     using namespace std;
       
    40 
       
    41     wostringstream 
       
    42         id; 
       
    43 
       
    44     if (itemIndex == 0)
       
    45         {
       
    46             id << (wchar_t)'a';
       
    47         }
       
    48     else
       
    49         {
       
    50             // smallest first 
       
    51             while (itemIndex > 0) {
       
    52                 id << (wchar_t)('a'+(itemIndex%10));
       
    53                 itemIndex/=10; 
       
    54             }
       
    55         }
       
    56 
       
    57     return id.str(); 
       
    58 }
       
    59 
       
    60 
       
    61 int GetItemIndex(const wchar_t * itemId)
       
    62 {
       
    63     int 
       
    64         ret = 0, 
       
    65         exp = 1;
       
    66 
       
    67     size_t
       
    68         length = wcslen(itemId);
       
    69 
       
    70     for (size_t i = 0; i < length; ++i) {
       
    71         if ( itemId[i] >= 'a' && itemId[i] < 'a'+10) {
       
    72             ret += (itemId[i]-'a') * exp; 
       
    73             exp*=10; 
       
    74         } else {
       
    75             // TODO: Panic
       
    76             return -1; 
       
    77         }
       
    78     }
       
    79 
       
    80     return ret; 
       
    81 }
       
    82 
       
    83 
       
    84 
       
    85 void PrintHit(cpix_Document * doc,
       
    86               Itk::TestMgr * testMgr)
       
    87 {
       
    88     using namespace std;
       
    89 
       
    90     const wchar_t
       
    91         * value = cpix_Document_getFieldValue(doc,
       
    92                                               LCPIX_DOCUID_FIELD);
       
    93 
       
    94     // path-case: if it looks like path starting with a drive letter
       
    95     // and a colon-separator, then get rid of the drive letter to be
       
    96     // able to pass test cases both on the phone and the emulator
       
    97     wstring
       
    98         docUid(value);
       
    99     if (docUid.length() > 2
       
   100         && docUid[1] == L':')
       
   101         {
       
   102             docUid[0] = L'!';
       
   103         }
       
   104 
       
   105     ITK_EXPECT(testMgr, value != NULL, "DOCUID field not found");
       
   106 
       
   107     fprintf(stdout,
       
   108             "DOC (%S): ",
       
   109             docUid.c_str());
       
   110     
       
   111     value = cpix_Document_getFieldValue(doc,
       
   112                                         LCPIX_EXCERPT_FIELD);
       
   113     
       
   114     ITK_EXPECT(testMgr, value != NULL, "EXCERPT field not found");
       
   115     
       
   116     fprintf(stdout,
       
   117             "%S\n",
       
   118             value);
       
   119 }
       
   120 
       
   121 
       
   122 void PrintHits(cpix_Hits    * hits,
       
   123                Itk::TestMgr * testMgr)
       
   124 {
       
   125     CustomPrintHits(hits,
       
   126                     testMgr,
       
   127                     &PrintHit);
       
   128 }
       
   129 
       
   130 
       
   131 void CustomPrintHits(cpix_Hits    * hits,
       
   132                      Itk::TestMgr * testMgr,
       
   133                      void        (* printHitFunc)(cpix_Document *, Itk::TestMgr *))
       
   134 {
       
   135     using namespace std;
       
   136 
       
   137     int32_t
       
   138         hitCount = cpix_Hits_length(hits);
       
   139 
       
   140     if (cpix_Failed(hits))
       
   141         {
       
   142             ITK_EXPECT(testMgr,
       
   143                        false,
       
   144                        "Failed to get number of hits");
       
   145             cpix_ClearError(hits);
       
   146             return;
       
   147         }
       
   148 
       
   149     cout << "Number of hits: " << hitCount << endl;
       
   150 
       
   151     cpix_Document
       
   152         doc;
       
   153 
       
   154     for (int32_t i = 0; i < hitCount; ++i)
       
   155         {
       
   156             cpix_Hits_doc(hits,
       
   157                           i,
       
   158                           &doc);
       
   159 
       
   160             if (cpix_Failed(hits))
       
   161                 {
       
   162                     ITK_EXPECT(testMgr,
       
   163                                false,
       
   164                                "Failed to get doc %d",
       
   165                                i);
       
   166                     cpix_ClearError(hits);
       
   167                     break;
       
   168                 }
       
   169             // OBS PrintHit(&doc,
       
   170             printHitFunc(&doc,
       
   171                          testMgr);
       
   172         }
       
   173 }
       
   174 
       
   175 
       
   176 
       
   177 
       
   178 IdxUtil::IdxUtil()
       
   179     : idxDb_(NULL),
       
   180       schemaId_(0)
       
   181 {
       
   182     ;
       
   183 }
       
   184 
       
   185 void IdxUtil::init(bool create) throw (Itk::PanicExc)
       
   186 {
       
   187     cpix_Result
       
   188         result;
       
   189 
       
   190     if (create)
       
   191         {
       
   192             cpix_IdxDb_defineVolume(&result,
       
   193                                     qualBaseAppClass(),
       
   194                                     idxDbPath());
       
   195 
       
   196             if (cpix_Succeeded(&result))
       
   197                 {
       
   198                     idxDb_ = cpix_IdxDb_openDb(&result,
       
   199                                                qualBaseAppClass(),
       
   200                                                cpix_IDX_CREATE);
       
   201                 }
       
   202         }
       
   203     else
       
   204         {
       
   205             idxDb_ = cpix_IdxDb_openDb(&result,
       
   206                                        qualBaseAppClass(),
       
   207                                        cpix_IDX_OPEN);
       
   208         }
       
   209     
       
   210     if (idxDb_ == NULL)
       
   211         {
       
   212             wchar_t
       
   213                 report[256];
       
   214 
       
   215             cpix_Error_report(result.err_,
       
   216                               report,
       
   217                               sizeof(report) / sizeof(wchar_t));
       
   218 
       
   219             ITK_PANIC("Could not create/open idx db '%s' for '%s - %S'",
       
   220                       idxDbPath(),
       
   221                       qualBaseAppClass(),
       
   222                       report);
       
   223         }
       
   224 
       
   225     schemaId_ = addSchema();
       
   226 }
       
   227 
       
   228 void IdxUtil::reload() throw (Itk::PanicExc)
       
   229 {
       
   230     cpix_Result
       
   231         result;
       
   232 
       
   233     cpix_IdxDb_releaseDb(idxDb_);
       
   234     idxDb_ = NULL; 
       
   235     schemaId_ = NULL; 
       
   236     
       
   237     idxDb_ = cpix_IdxDb_openDb(&result,
       
   238                                qualBaseAppClass(),
       
   239                                cpix_IDX_OPEN);
       
   240 	
       
   241     if (idxDb_ == NULL)
       
   242         {
       
   243             ITK_PANIC("Could not reopen idx db '%s' for '%s'",
       
   244                       idxDbPath(),
       
   245                       qualBaseAppClass());
       
   246         }
       
   247 	
       
   248     schemaId_ = addSchema(); 
       
   249 }
       
   250 
       
   251 void IdxUtil::recreate() throw (Itk::PanicExc)
       
   252 {
       
   253     cpix_Result
       
   254         result;
       
   255 
       
   256     cpix_IdxDb_releaseDb(idxDb_);
       
   257     idxDb_ = NULL; 
       
   258     schemaId_ = NULL; 
       
   259 	
       
   260     cpix_IdxDb_defineVolume(&result,
       
   261                             qualBaseAppClass(),
       
   262                             idxDbPath());
       
   263     if (cpix_Succeeded(&result))
       
   264         {
       
   265             idxDb_ = cpix_IdxDb_openDb(&result,
       
   266                                        qualBaseAppClass(),
       
   267                                        cpix_IDX_CREATE);
       
   268         }
       
   269 	
       
   270     if (idxDb_ == NULL)
       
   271         {
       
   272             ITK_PANIC("Could not reopen idx db '%s' for '%s'",
       
   273                       idxDbPath(),
       
   274                       qualBaseAppClass());
       
   275         }
       
   276 
       
   277     schemaId_ = addSchema(); 	
       
   278 }
       
   279 
       
   280 void IdxUtil::flush() throw (Itk::PanicExc) 
       
   281 {
       
   282 	cpix_IdxDb_flush( idxDb_ );
       
   283 	
       
   284     if ( cpix_Failed( idxDb_ ) )
       
   285     {
       
   286 		ITK_PANIC("Could not flush idx db '%s' for '%s'",
       
   287 				  idxDbPath(),
       
   288 				  qualBaseAppClass());
       
   289     }
       
   290 }
       
   291 
       
   292 void IdxUtil::close() throw() 
       
   293 {
       
   294 	if ( idxDb_ ) 
       
   295 	{
       
   296 		cpix_IdxDb_releaseDb(idxDb_);
       
   297 		idxDb_ = 0; 
       
   298 	}
       
   299 }
       
   300 
       
   301 IdxUtil::~IdxUtil() throw()
       
   302 {
       
   303 	close(); 
       
   304 }
       
   305 
       
   306 
       
   307 void IdxUtil::printHits(cpix_Hits    * hits,
       
   308                         Itk::TestMgr * testMgr,
       
   309                         bool           allowFailure)
       
   310 {
       
   311     using namespace std;
       
   312 
       
   313     int32_t
       
   314         hitCount = cpix_Hits_length(hits);
       
   315 
       
   316     if (cpix_Failed(hits))
       
   317         {
       
   318             ITK_EXPECT(testMgr,
       
   319                        false,
       
   320                        "Failed to get number of hits");
       
   321             cpix_ClearError(hits);
       
   322             return;
       
   323         }
       
   324 
       
   325     cout << "Number of hits: " << hitCount << endl;
       
   326 
       
   327     cpix_Document
       
   328         doc;
       
   329 
       
   330     for (int32_t i = 0; i < hitCount; ++i)
       
   331         {
       
   332             cpix_Hits_doc(hits,
       
   333                           i,
       
   334                           &doc);
       
   335 
       
   336             if (cpix_Failed(hits))
       
   337                 {
       
   338                     if (allowFailure)
       
   339                         {
       
   340                             printf("Failed to get doc %d - updated index?\n",
       
   341                                    i);
       
   342                         }
       
   343                     else
       
   344                         {
       
   345                             ITK_EXPECT(testMgr,
       
   346                                        false,
       
   347                                        "Failed to get doc %d",
       
   348                                        i);
       
   349                         }
       
   350 
       
   351                     cpix_ClearError(hits);
       
   352                     break;
       
   353                 }
       
   354             printHit(&doc,
       
   355                         testMgr);
       
   356         }
       
   357 }
       
   358 
       
   359 
       
   360 cpix_IdxDb * IdxUtil::idxDb()
       
   361 {
       
   362     return idxDb_;
       
   363 }
       
   364 
       
   365 
       
   366 SchemaId IdxUtil::schemaId()
       
   367 {
       
   368     return schemaId_;
       
   369 }
       
   370     
       
   371 
       
   372 void IdxUtil::printHit(cpix_Document * doc,
       
   373                        Itk::TestMgr   * testMgr)
       
   374 {
       
   375     using namespace std;
       
   376 
       
   377     std::wstring
       
   378         idStr(getIdStr(doc,
       
   379                        testMgr));
       
   380 
       
   381     fprintf(stdout, 
       
   382     		"DOC (%S): ",
       
   383     		idStr.c_str());
       
   384        
       
   385     const wchar_t 
       
   386         * value = cpix_Document_getFieldValue(doc,
       
   387 												LCPIX_EXCERPT_FIELD);
       
   388     
       
   389     ITK_EXPECT(testMgr, value != NULL, "EXCERPT field not found");
       
   390     
       
   391     fprintf(stdout, 
       
   392     		"%S\n",
       
   393     		value);
       
   394 }
       
   395 
       
   396 
       
   397 
       
   398 /****
       
   399  * SmsIdxUtil
       
   400  */
       
   401 SmsIdxUtil::SmsIdxUtil(const char * qbac)
       
   402     : qbac_(qbac)
       
   403 {
       
   404     ;
       
   405 }
       
   406 
       
   407 
       
   408 SmsIdxUtil::~SmsIdxUtil() throw ()
       
   409 {
       
   410     ;
       
   411 }
       
   412 
       
   413 
       
   414 const char * SmsIdxUtil::qualBaseAppClass() const
       
   415 {
       
   416     return qbac_.c_str();
       
   417 }
       
   418 
       
   419 
       
   420 const char * SmsIdxUtil::idxDbPath() const
       
   421 {
       
   422     return NULL;
       
   423 }
       
   424 
       
   425 
       
   426 cpix_FieldDesc SmsSchema[] = {
       
   427 
       
   428     // NOTE: in an actual SMS schema, you would probably not want to
       
   429     // store fields "to", "from" and "folder".
       
   430 
       
   431     {
       
   432         LTO_FIELD,                                     // name_
       
   433         cpix_STORE_YES | cpix_INDEX_UNTOKENIZED,      // cfg_
       
   434     },
       
   435     {
       
   436         LFROM_FIELD,                                   // name_
       
   437         cpix_STORE_YES | cpix_INDEX_UNTOKENIZED,      // cfg_
       
   438     },
       
   439     {
       
   440         LFOLDER_FIELD,                                 // name_
       
   441         cpix_STORE_YES | cpix_INDEX_UNTOKENIZED,      // cfg_
       
   442     },
       
   443     {
       
   444         LBODY_FIELD,                                   // name_
       
   445         cpix_STORE_NO | cpix_INDEX_TOKENIZED,         // cfg_
       
   446     },
       
   447     
       
   448 };
       
   449 
       
   450 
       
   451 
       
   452 SchemaId SmsIdxUtil::addSchema() throw (Itk::PanicExc)
       
   453 {
       
   454     SchemaId
       
   455         rv = cpix_IdxDb_addSchema(idxDb(),
       
   456                                   SmsSchema,
       
   457                                   sizeof(SmsSchema)/sizeof(cpix_FieldDesc));
       
   458     if (cpix_Failed(idxDb()))
       
   459         {
       
   460             cpix_ClearError(idxDb());
       
   461             ITK_PANIC("Failed to add SMS schema");
       
   462         }
       
   463 
       
   464     return rv;
       
   465 }
       
   466 
       
   467 
       
   468 void SmsIdxUtil::deleteSms(size_t         id,
       
   469                            Itk::TestMgr * testMgr)
       
   470 {
       
   471     std::wstring
       
   472         docUid = GetItemId(id);
       
   473 
       
   474     int32_t
       
   475         result = cpix_IdxDb_deleteDocuments(idxDb(),
       
   476                                             docUid.c_str());
       
   477 
       
   478 
       
   479     ITK_EXPECT(testMgr,
       
   480                cpix_Succeeded(idxDb()),
       
   481                "Failed to delete by %S",
       
   482                docUid.c_str());
       
   483 
       
   484     if (cpix_Succeeded(idxDb()))
       
   485         {
       
   486             ITK_MSG(testMgr,
       
   487                     "Deleted %d items by %S",
       
   488                     result,
       
   489                     docUid.c_str());
       
   490         }
       
   491 }
       
   492 
       
   493 
       
   494 void SmsIdxUtil::indexSms(size_t          id,
       
   495                           const wchar_t * body,
       
   496                           cpix_Analyzer * analyzer,
       
   497                           Itk::TestMgr   * testMgr,
       
   498                           bool            update)
       
   499 {
       
   500     using namespace std;
       
   501 
       
   502     wstring 
       
   503         docUid = GetItemId(id); 
       
   504     
       
   505     /* TEMP
       
   506        currently we are going to use the full SMS body as excerpt
       
   507        for testing purposes, but otherwise this piece of code could
       
   508        do excerpt generation.
       
   509     wchar_t
       
   510         excerpt[128];
       
   511     cpix_EPIState
       
   512         epiState;
       
   513     size_t
       
   514         maxWords = 6,
       
   515         bufSize = sizeof(excerpt) / sizeof(wchar_t);
       
   516     cpix_init_EPIState(&epiState);
       
   517     cpix_getExcerptOfWText(excerpt,
       
   518                            body,
       
   519                            &maxWords,
       
   520                            &bufSize,
       
   521                            &epiState);
       
   522     */
       
   523 
       
   524     const wchar_t
       
   525         * fields[4];
       
   526     fields[0] = L"+3585553412"; // to
       
   527     fields[1] = L"+3585559078"; // from
       
   528     fields[2] = L"inbox";       // folder
       
   529     fields[3] = body;           // body
       
   530     
       
   531     void (*op)(cpix_IdxDb*,
       
   532                SchemaId,
       
   533                const wchar_t*,
       
   534                const char*,
       
   535                const wchar_t*,
       
   536                const wchar_t*,
       
   537                const wchar_t**,
       
   538                cpix_Analyzer*) = &cpix_IdxDb_add2;
       
   539     const char
       
   540         * okFormatStr = "Indexed SMS %d",
       
   541         * failureStr = "Failed to index SMS";
       
   542 
       
   543     if (update)
       
   544         {
       
   545             op = &cpix_IdxDb_update2;
       
   546             okFormatStr = "Updated SMS %d";
       
   547             failureStr = "Failed to update SMS";
       
   548         }
       
   549 
       
   550     op(idxDb(),
       
   551        schemaId(),
       
   552        docUid.c_str(),    // doc uid
       
   553        SMSAPPCLASS,       // app class
       
   554        // TEMP excerpt,           // excerpt
       
   555        body,              // (as) excerpt
       
   556        NULL,              // app id
       
   557        fields,            // fields
       
   558        analyzer);
       
   559     
       
   560     if (cpix_Succeeded(idxDb()))
       
   561         {
       
   562             ITK_MSG(testMgr,
       
   563                     okFormatStr,
       
   564                     id);
       
   565         }
       
   566     else
       
   567         {
       
   568             wchar_t
       
   569                 report[256];
       
   570             cpix_Error_report(idxDb()->err_,
       
   571                               report,
       
   572                               sizeof(report) / sizeof(wchar_t)); 
       
   573            
       
   574             ITK_EXPECT(testMgr,
       
   575                        false,
       
   576                        "%s %d: %S",
       
   577                        failureStr,
       
   578                        id,
       
   579                        report);
       
   580 
       
   581             cpix_ClearError(idxDb());
       
   582         }
       
   583 }
       
   584 
       
   585 
       
   586 std::wstring SmsIdxUtil::getIdStr(cpix_Document * doc,
       
   587                                   Itk::TestMgr  * testMgr)
       
   588 {
       
   589     const wchar_t
       
   590         * value = cpix_Document_getFieldValue(doc,
       
   591                                               LCPIX_DOCUID_FIELD);
       
   592 
       
   593     ITK_EXPECT(testMgr, value != NULL, "DOCUID field not found");
       
   594 
       
   595     std::wstring
       
   596         rv(value);
       
   597 
       
   598     rv += L", line ";
       
   599 
       
   600     wchar_t
       
   601         dummy[32];
       
   602     snwprintf(dummy,
       
   603               sizeof(dummy) / sizeof(wchar_t),
       
   604               L"%d",
       
   605               GetItemIndex(value) + 1);
       
   606 
       
   607     rv += dummy;
       
   608 
       
   609     return rv;
       
   610 }
       
   611 
       
   612 
       
   613 /****
       
   614  * FileIdxUtil
       
   615  */
       
   616 FileIdxUtil::~FileIdxUtil() throw ()
       
   617 {
       
   618     ;
       
   619 }
       
   620 
       
   621 
       
   622 void FileIdxUtil::indexFile(const char    * path,
       
   623                             cpix_Analyzer * analyzer,
       
   624                             Itk::TestMgr  * testMgr)
       
   625 {
       
   626     wchar_t
       
   627         wpath[256];
       
   628 
       
   629     size_t
       
   630         res = mbstowcs(wpath,
       
   631                        path,
       
   632                        sizeof(wpath) / sizeof(wchar_t) - 1);
       
   633     ITK_ASSERT(testMgr,
       
   634                //res >= 0,
       
   635 			   1,
       
   636                "mbstowcs failed, errno: %d",
       
   637                errno);
       
   638     wpath[sizeof(wpath) / sizeof(wchar_t) - 1] = wchar_t(0);
       
   639 
       
   640     /* THIS IS ALSO POSSIBLE
       
   641     cpix_IdxDb_add2(idxDb(),
       
   642                     schemaId(),
       
   643                     wpath,                   // docUid,
       
   644                     TEXTAPPCLASS,            // app class
       
   645                     NULL,                    // excerpt file parser defined
       
   646                     NULL,                    // app id
       
   647                     (const wchar_t**)&field, // fields: { cpix_FILTERID_FIELD }
       
   648                     analyzer);
       
   649     */
       
   650 
       
   651 
       
   652     // Using here the non-schema based addition method
       
   653     // o creating document
       
   654     // o populating it
       
   655     // o adding it
       
   656     // NOTE: app class, excerpt and mime type have to be defined
       
   657     // here, but this is using the file parser functionality
       
   658     // inside Cpix, which re-defines these anyway
       
   659     cpix_Result
       
   660         result;
       
   661     cpix_Document
       
   662         * doc = cpix_Document_create(&result,
       
   663                                      wpath,          // docUid,
       
   664                                      NULL,           // app class
       
   665                                      NULL,           // excerpt (file parser d)
       
   666                                      NULL);          // mime type
       
   667 
       
   668     wchar_t
       
   669         report[512];
       
   670     
       
   671     if (cpix_Failed(&result))
       
   672         {
       
   673             cpix_Error_report(result.err_,
       
   674                               report,
       
   675                               sizeof(report)/sizeof(wchar_t));
       
   676             ITK_EXPECT(testMgr,
       
   677                        false,
       
   678                        "Failed to create document %S: %S",
       
   679                        wpath,
       
   680                        report);
       
   681             cpix_ClearError(&result);
       
   682             return;
       
   683         }
       
   684 
       
   685     cpix_Field
       
   686         filterIdField;
       
   687 
       
   688     cpix_Field_initialize(&filterIdField,
       
   689                           LCPIX_FILTERID_FIELD,
       
   690                           LCPIX_FILEPARSER_FID,
       
   691                           cpix_STORE_YES | cpix_INDEX_NO);
       
   692                    
       
   693     if (cpix_Failed(&filterIdField))
       
   694         {
       
   695             cpix_Error_report(filterIdField.err_,
       
   696                               report,
       
   697                               sizeof(report)/sizeof(wchar_t));
       
   698             ITK_EXPECT(testMgr,
       
   699                        false,
       
   700                        "Failed to create field");
       
   701             cpix_ClearError(&filterIdField);
       
   702             cpix_Document_destroy(doc);
       
   703             return;
       
   704         }
       
   705 
       
   706     cpix_Document_add(doc,
       
   707                       &filterIdField);
       
   708 
       
   709     if (cpix_Failed(doc))
       
   710         {
       
   711             cpix_Error_report(doc->err_,
       
   712                               report,
       
   713                               sizeof(report)/sizeof(wchar_t));
       
   714             ITK_EXPECT(testMgr,
       
   715                        false,
       
   716                        "Failed to add field to doc");
       
   717             cpix_ClearError(doc);
       
   718             cpix_Document_destroy(doc);
       
   719             cpix_Field_release(&filterIdField);
       
   720             // at this point reader is owned by field already
       
   721             return;
       
   722         }
       
   723 
       
   724     cpix_IdxDb_add(idxDb(),
       
   725                    doc,
       
   726                    analyzer);
       
   727 
       
   728     if (cpix_Failed(idxDb()))
       
   729         {
       
   730             cpix_Error_report(idxDb()->err_,
       
   731                               report,
       
   732                               sizeof(report)/sizeof(wchar_t));
       
   733             ITK_EXPECT(testMgr,
       
   734                        false,
       
   735                        "Failed to index document %S: %S\n",
       
   736                        wpath,
       
   737                        report);
       
   738             cpix_ClearError(idxDb());
       
   739         }
       
   740     else
       
   741         {
       
   742             wpath[0] = '!';
       
   743             ITK_MSG(testMgr,
       
   744                     "Indexed file: %S",
       
   745                     wpath);
       
   746         }
       
   747 
       
   748     cpix_Document_destroy(doc);
       
   749 }
       
   750 
       
   751 
       
   752 cpix_FieldDesc FileSchema[] = {
       
   753     {
       
   754     		LCPIX_FILTERID_FIELD,                  // name_
       
   755         cpix_STORE_YES | cpix_INDEX_NO,       // cfg_
       
   756     }
       
   757 };
       
   758 
       
   759 
       
   760 const char * FileIdxUtil::qualBaseAppClass() const
       
   761 {
       
   762     return FILE_QBASEAPPCLASS;
       
   763 }
       
   764 
       
   765 
       
   766 const char * FileIdxUtil::idxDbPath() const
       
   767 {
       
   768     return NULL;
       
   769 }
       
   770 
       
   771 
       
   772 SchemaId FileIdxUtil::addSchema() throw (Itk::PanicExc)
       
   773 {
       
   774     return cpix_IdxDb_addSchema(idxDb(),
       
   775                                 FileSchema,
       
   776                                 sizeof(FileSchema)/sizeof(cpix_FieldDesc));
       
   777 }
       
   778 
       
   779 
       
   780 std::wstring FileIdxUtil::getIdStr(cpix_Document * doc,
       
   781                                    Itk::TestMgr  * testMgr)
       
   782 {
       
   783     const wchar_t
       
   784         * value = cpix_Document_getFieldValue(doc,
       
   785                                               LCPIX_DOCUID_FIELD);
       
   786     ITK_EXPECT(testMgr, value != NULL, "DOCUID field not found");
       
   787 
       
   788     std::wstring
       
   789         rv(value);
       
   790 
       
   791     rv[0] = '!';
       
   792 
       
   793     return rv;
       
   794 }
       
   795 
       
   796 
       
   797 
       
   798 VolumeFileIdxUtil::VolumeFileIdxUtil(const MVFTest * mvfTest)
       
   799         : mvfTest_(mvfTest)
       
   800 {
       
   801     ;
       
   802 }
       
   803 
       
   804 
       
   805 VolumeFileIdxUtil::~VolumeFileIdxUtil() throw ()
       
   806 {
       
   807     ;
       
   808 }
       
   809 
       
   810 
       
   811 const char * VolumeFileIdxUtil::qualBaseAppClass() const
       
   812 {
       
   813     return mvfTest_->qualifiedBaseAppClass_;
       
   814 }
       
   815 
       
   816 
       
   817 const char * VolumeFileIdxUtil::idxDbPath() const
       
   818 {
       
   819     return mvfTest_->idxDbPath_;
       
   820 }
       
   821