当前位置: 首页>>代码示例>>C++>>正文


C++ UtlHashMap::entries方法代码示例

本文整理汇总了C++中UtlHashMap::entries方法的典型用法代码示例。如果您正苦于以下问题:C++ UtlHashMap::entries方法的具体用法?C++ UtlHashMap::entries怎么用?C++ UtlHashMap::entries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UtlHashMap的用法示例。


在下文中一共展示了UtlHashMap::entries方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getOneRowByNameTest

   void getOneRowByNameTest()
   {
      SipDbTestContext sipDbTestContext(TEST_DATA_DIR "/locationdata",
                                        TEST_WORK_DIR "/locationdata"
                                                 );
      sipDbTestContext.inputFile("dummy_loc_db.xml" );
      
      LocationDB* pLocDb = LocationDB::getInstance("dummy_loc_db");
      UtlHashMap hashmap;
      CPPUNIT_ASSERT( !pLocDb->getRowByName( "Washington", hashmap ) );
      CPPUNIT_ASSERT( pLocDb->getRowByName( "Ottawa", hashmap ) );
      CPPUNIT_ASSERT( hashmap.entries() == 4 );

      UtlString* pTempString;
      UtlString key;
      key = "name";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "Ottawa", pTempString->data() );
      
      key = "description";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "One crazy location", pTempString->data() );
      
      key = "locationcode";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "613", pTempString->data() );

      key = "subnets";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "172.30.0.0/16,22.22.22.22/32", pTempString->data() );

      // get a second location row
      CPPUNIT_ASSERT( pLocDb->getRowByName( "Quebec", hashmap ) );
      CPPUNIT_ASSERT( hashmap.entries() == 4 );

      key = "name";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "Quebec", pTempString->data() );
      
      key = "description";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "Happy 400th anniversary", pTempString->data() );
      
      key = "locationcode";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "418", pTempString->data() );

      key = "subnets";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( SPECIAL_IMDB_NULL_VALUE, pTempString->data() );
   }
开发者ID:LordGaav,项目名称:sipxecs,代码行数:59,代码来源:LocationDbTest.cpp

示例2: getOneRowByLocationCodeTest

   void getOneRowByLocationCodeTest()
   {
      SipDbTestContext sipDbTestContext(TEST_DATA_DIR "/locationdata",
                                        TEST_WORK_DIR "/locationdata"
                                                 );
      sipDbTestContext.inputFile("dummy_loc_db.xml" );
      
      LocationDB* pLocDb = LocationDB::getInstance("dummy_loc_db");
      UtlHashMap hashmap;
      CPPUNIT_ASSERT( !pLocDb->getRowByLocationCode( "5144", hashmap ) );
      CPPUNIT_ASSERT( pLocDb->getRowByLocationCode( "514", hashmap ) );
      CPPUNIT_ASSERT( hashmap.entries() == 4 );

      UtlString* pTempString;
      UtlString key;
      key = "name";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "Montreal", pTempString->data() );
      
      key = "description";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "Go Habs Go!", pTempString->data() );
      
      key = "locationcode";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "514", pTempString->data() );

      key = "subnets";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "10.10.10.0/24,11.11.11.0/24,12.12.12.0/24", pTempString->data() );
   }
开发者ID:LordGaav,项目名称:sipxecs,代码行数:35,代码来源:LocationDbTest.cpp

示例3: if

OsStatus
ManageNotificationsWebCGI::getManageNotificationsUI(UtlString* out)
{
    // Construct the status message
    UtlString statusStr = "&nbsp";
    if( m_status == ADD_NOTIFICATION_SUCCESS )
        statusStr = "Email address added successfully" ;
    else if( m_status == EDIT_NOTIFICATION_SUCCESS )
        statusStr = "Email address modified successfully" ;
    else if( m_status == DELETE_NOTIFICATION_SUCCESS )
        statusStr = "Email address deleted successfully" ;
    else if( m_status == DELETE_NOTIFICATION_FAILED )
        statusStr = "Failed to delete the email address. Please try again." ;

    UtlString dynamicHtml =  HTML_BEGIN \
                            WEBPAGE_SNIPPET1 \
                            "Manage Notifications" \
                            WEBPAGE_SNIPPET2 \
                            "notify_by_email_page.htm" \
                            WEBPAGE_SNIPPET3 ;


    MailboxManager* pMailboxManager = MailboxManager::getInstance();

    if( TRUE ) // email notification is always enabled now
    {
        // Get the list of contacts
        UtlBoolean contactsFound = FALSE ;

        UtlHashMap contactsHashDictionary;
        pMailboxManager->getNotificationContactList (
            m_mailboxIdentity,
            &contactsHashDictionary );

        if( contactsHashDictionary.entries() > 0 )
        {
            // Get the sorted contacts list
            // Get the sorted list of contacts.
            UtlSortedList* contactList = (UtlSortedList*) contactsHashDictionary.
                    findValue( new UtlString("sortedcontacts") );

            if (contactList != NULL)
            {
                if( contactList->entries() > 0)
                {
                    contactsFound = TRUE ;

                    // Add code for displaying the status and
                    // the table header for listing the contacts.
                    dynamicHtml +=  statusStr +
                                WEBPAGE_SNIPPET4 +
                                "<tr> \n" \
                                  "<th>Email Address</th>\n" \
                                  "<th width=\"15%\">Edit</th>\n" \
                                  "<th width=\"15%\">Delete</th>\n" \
                                "</tr>\n" ;
                }

                while( contactList->entries() > 0 )
                {

                    UtlString* rwAddress =
                        (UtlString*) contactList->removeAt(0);
                    UtlString address = rwAddress->data();

                    if( contactsHashDictionary.findValue( rwAddress ) != NULL )
                    {
                        UtlHashMap* contactDetails = (UtlHashMap*) contactsHashDictionary.
                                                findValue( rwAddress );

                        // Construct the HTML code
                        UtlString htmlCode ;
                        getNotificationsUIHtmlCode( address, contactDetails, htmlCode ) ;
                        dynamicHtml += htmlCode ;
                    }

                }
                delete contactList ;
            }
        }

        if( !contactsFound )
        {
            statusStr += "<br><br>Notifications can be sent to your email when you receive a new voicemail.<br>Click on the button below to specify your email address";
            dynamicHtml += statusStr + "</td></tr>" ;
        }

        dynamicHtml +=  "</table>\n" \
                        "</td></tr>\n" \
                        "<tr>\n" \
                            "<td colspan=\"2\"> \n" \
                               "<form action=\"" + m_cgiUrl + "\" method=\"post\">\n" \
                               "<input type=\"hidden\" name=\"action\" value=\"getaddnotificationui\">\n" \
                               "<input type=\"hidden\" name=\"fromweb\" value=\"yes\">\n" \
                               "<input type=\"submit\" value=\"Add Notification\">\n" \
                               "</form>\n" \
                            "</td> \n" \
                        "</tr> \n" ;
    }
    else
//.........这里部分代码省略.........
开发者ID:chemeris,项目名称:sipxecs,代码行数:101,代码来源:ManageNotificationsWebCGI.cpp

示例4: stateSetting

   void stateSetting()
   {
      FileTestContext testContext(TEST_DATA_DIR "processState",
            TEST_WORK_DIR "processState");

      // copy test files into testContext structure
      testContext.inputFile("newprocess.xml");
      testContext.inputFile("another-process.xml");
      testContext.inputFile("notherprocess.sh");

      UtlString exePath;
      testContext.workingFilePath("notherprocess.sh", exePath);
      chmod(exePath.data(), S_IREAD | S_IWRITE | S_IEXEC);

      testContext.setSipxDir(SipXecsService::VarDirType, "var");
      testContext.setSipxDir(SipXecsService::LogDirType);

      UtlHashMap status;
      SipxProcessManager::getInstance()->getProcessStateAll(status);

      size_t existingProcesses = status.entries();

      UtlString path;
      SipxProcess* process1;
      SipxProcess* process2;

      testContext.inputFilePath("newprocess.xml", path);
      CPPUNIT_ASSERT((process1 = SipxProcess::createFromDefinition(path)));
      testContext.inputFilePath("another-process.xml", path);
      CPPUNIT_ASSERT((process2 = SipxProcess::createFromDefinition(path)));
      OsTask::delay(1 * OsTime::MSECS_PER_SEC); // give task some time to get up and running

      ASSERT_STR_EQUAL("New", process1->data());
      ASSERT_STR_EQUAL("1.0.0", process1->mVersion.data());

      CPPUNIT_ASSERT_EQUAL(SipxProcess::pDisabled->name(), process1->GetCurrentState()->name());
      CPPUNIT_ASSERT_EQUAL(SipxProcess::pDisabled->name(), process1->mpDesiredState->name());
      CPPUNIT_ASSERT(!process1->isEnabled());

      ASSERT_STR_EQUAL("Nother", process2->data());
      ASSERT_STR_EQUAL("1.0.0", process2->mVersion.data());

      ASSERT_STR_EQUAL(SipxProcess::pDisabled->name(), process2->GetCurrentState()->name());
      ASSERT_STR_EQUAL(SipxProcess::pDisabled->name(), process2->mpDesiredState->name());

      // set the expected version ourselves, since no-one else can in unit test!
      UtlString newCfgVersion("1.0.0");
      process1->setConfigurationVersion(newCfgVersion);
      UtlString currCfgVersion;
      process2->getConfigurationVersion(currCfgVersion);
      OsSysLog::add(FAC_SUPERVISOR, PRI_DEBUG,
                    "process2 config version = %s", currCfgVersion.data());

      process1->enable();
      process2->enable();

      int retries = 5;
      while ( retries-- &&
            !(process1->GetCurrentState()->name()==SipxProcess::pRunning->name() &&
              process2->GetCurrentState()->name()==SipxProcess::pConfigurationMismatch->name()) )
      {
         OsTask::delay(1 * OsTime::MSECS_PER_SEC);
      }

      OsSysLog::add(FAC_SUPERVISOR, PRI_DEBUG,
                    "test that process2 does not start until config version is set");
      ASSERT_STR_EQUAL(SipxProcess::pConfigurationMismatch->name(), process2->GetCurrentState()->name());

      process2->setConfigurationVersion(newCfgVersion);
      retries = 5;
      while ( retries-- && strcmp(process2->GetCurrentState()->name(),SipxProcess::pRunning->name()) )
      {
         OsTask::delay(1 * OsTime::MSECS_PER_SEC);
      }

      CPPUNIT_ASSERT(process1->isEnabled());
      CPPUNIT_ASSERT(process2->isEnabled());
      ASSERT_STR_EQUAL(SipxProcess::pRunning->name(), process1->mpDesiredState->name());

      ASSERT_STR_EQUAL(SipxProcess::pRunning->name(), process1->GetCurrentState()->name());
      ASSERT_STR_EQUAL(SipxProcess::pRunning->name(), process2->GetCurrentState()->name());

      SipxProcessManager::getInstance()->getProcessStateAll(status);

      CPPUNIT_ASSERT_EQUAL(existingProcesses + 2U, status.entries());
      UtlString* statusValue;

      UtlString process1name("New");
      CPPUNIT_ASSERT(statusValue = dynamic_cast<UtlString*>(status.findValue(&process1name)));
      ASSERT_STR_EQUAL("Running", statusValue->data());

      UtlString process2name("Nother");
      CPPUNIT_ASSERT(statusValue = dynamic_cast<UtlString*>(status.findValue(&process2name)));
      ASSERT_STR_EQUAL("Running", statusValue->data());

      process2->shutdown();
      CPPUNIT_ASSERT(process2->isEnabled());

      ASSERT_STR_EQUAL(SipxProcess::pRunning->name(), process2->mpDesiredState->name());

//.........这里部分代码省略.........
开发者ID:chemeris,项目名称:sipxecs,代码行数:101,代码来源:SipxProcessStateTest.cpp

示例5: execute

   virtual bool execute(const HttpRequestContext& requestContext, ///< request context
                        UtlSList& params,                         ///< request param list
                        void* userData,                           ///< user data
                        XmlRpcResponse& response,                 ///< request response
                        ExecutionStatus& status
                        )
      {
         UtlString* dbName = dynamic_cast<UtlString*>(params.at(0));

         if (dbName && !dbName->isNull())
         {
            OsReadLock lock(*ConfigRPC::spDatabaseLock);

            ConfigRPC* db = ConfigRPC::find(*dbName);
            if (db)
            {
               status = db->mCallback->accessAllowed(requestContext, ConfigRPC_Callback::Set);
               if ( XmlRpcMethod::OK == status )
               {
                  // read in the dataset
                  OsConfigDb dataset;
                  OsStatus datasetStatus = db->load(dataset);
                  if ( OS_SUCCESS == datasetStatus )
                  {
                     // get the list of names that the request is asking for
                     UtlContainable* secondParam = params.at(1);
                     if ( secondParam )
                     {
                        UtlHashMap* paramList = dynamic_cast<UtlHashMap*>(secondParam);
                        if (paramList)
                        {
                           /*
                            * Iterate over the requested name/value pairs
                            */
                           UtlHashMapIterator params(*paramList);
                           UtlContainable* nextParam = NULL;
                           size_t paramsSet = 0;

                           while (    XmlRpcMethod::OK == status
                                  && (nextParam = params())
                                  )
                           {
                              UtlString* name = dynamic_cast<UtlString*>(params.key());
                              if ( name )
                              {
                                 UtlString* value = dynamic_cast<UtlString*>(params.value());
                                 if (value)
                                 {
                                    dataset.set(*name, *value);
                                    paramsSet++;
                                 }
                                 else
                                 {
                                    UtlString faultMsg;
                                    faultMsg.append("parameter name '");
                                    faultMsg.append(*name);
                                    faultMsg.append("' value is not a string");
                                    response.setFault(ConfigRPC::invalidType, faultMsg.data());
                                    status = XmlRpcMethod::FAILED;
                                 }
                              }
                              else
                              {
                                 UtlString faultMsg;
                                 faultMsg.append("parameter number ");
                                 char paramIndex[10];
                                 sprintf(paramIndex,"%zu", paramsSet + 1);
                                 faultMsg.append(paramIndex);
                                 faultMsg.append(" name is not a string");
                                 response.setFault(ConfigRPC::invalidType, faultMsg.data());
                                 status = XmlRpcMethod::FAILED;
                              }
                           }

                           if ( XmlRpcMethod::OK == status )
                           {
                              if (OS_SUCCESS == db->store(dataset))
                              {
                                 UtlInt numberSet(paramList->entries());
                                 response.setResponse(&numberSet);
                              }
                              else
                              {
                                 response.setFault( ConfigRPC::storeFailed
                                                   ,"error storing dataset"
                                                   );
                                 status = XmlRpcMethod::FAILED;
                              }
                           }
                        }
                        else
                        {
                           // The second parameter was not a list
                           response.setFault( ConfigRPC::invalidType
                                             ,"second parameter is not a struct"
                                             );
                           status = XmlRpcMethod::FAILED;
                        }
                     }
                     else // no parameter names specified
//.........这里部分代码省略.........
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:101,代码来源:ConfigRPC.cpp

示例6: fileExecute


//.........这里部分代码省略.........
                        }
                    }
                }
                else if (strcasecmp(token, "set") == 0)
                {
                    token = strtok(NULL, " ");
                    if (token == NULL)
                    {
                        fileError(1, line);
                    }
                    else
                    {
                        Url url(token);                
                        token = strtok(NULL, " ");
                        if (token == NULL)
                        {
                            fileError(2, line);
                        }               
                        else
                        {
                            DataSet = token;
                            UtlHashMap parameters;
                            char *key;
                            char *value;
                            while (token != NULL)
                            {
                                key = strtok(NULL, " ");
                                if (key == NULL)
                                {
                                    break;
                                }
                                value = strtok(NULL, " ");
                                if (value == NULL)
                                {
                                    fileError(3, line);
                                    break;
                                }
                                parameters.insertKeyAndValue(new UtlString(key), new UtlString(value));
                            }
                            int entries = parameters.entries();
                    
                            if (entries != 0 || (entries%2) == 0)
                            {
                                requestSet(url, parameters);
                                parameters.destroyAll();
                            }
                        }
                    }
                }
                else if (strcasecmp(token, "delete") == 0)
                {
                    token = strtok(NULL, " ");
                    if (token == NULL)
                    {
                        fileError(1, line);
                    }
                    else
                    {
                        Url url(token);                
                        token = strtok(NULL, " ");
                        if (token == NULL)
                        {
                            fileError(2, line);
                        }
                        else
                        {
                            DataSet = token;
                            UtlSList names;
                            while (token != NULL)
                            {
                                token = strtok(NULL, " ");
                                if (token != NULL)
                                {
                                    names.append(new UtlString(token));
                                }
                            }
                            requestDelete(url, names);
                            names.destroyAll();                             
                        }
                    }
                }
                else
                {
                    fprintf(stderr, "Unknown RPC request %s - ignoring line\n", token);
                }
                if (bSingleStep)
                {
                    getchar();
                }
            }
        }
        while ( bRepeatFile );
        fclose(fp);
    }
    else
    {
        fprintf(stderr, "Can't open %s\n", inputFile);
        exit(1);
    }
}
开发者ID:mranga,项目名称:sipxecs,代码行数:101,代码来源:configrpc.cpp


注:本文中的UtlHashMap::entries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。