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


C++ OsConfigDb::isEmpty方法代码示例

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


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

示例1: testCreators

 void testCreators()
 {
     OsConfigDb *pDb = new OsConfigDb();       // create an empty database
     CPPUNIT_ASSERT_MESSAGE("verify that it looks empty", pDb->isEmpty());
     CPPUNIT_ASSERT_MESSAGE("has zero entries", pDb->numEntries()==0);
     delete pDb;
 }
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:7,代码来源:OsConfigDbTest.cpp

示例2: SipUserAgent

StatusServer*
StatusServer::startStatusServer (
    const UtlString workingDir,
    const char* configFileName )
{
    int httpPort  = PORT_NONE;
    int httpsPort = PORT_NONE;
    int tcpPort   = PORT_NONE;
    int udpPort   = PORT_NONE;
    int tlsPort   = PORT_NONE;
    UtlString bindIp;
    UtlString defaultMaxExpiresTime;
    UtlString defaultMinExpiresTime;

    UtlString authAlgorithm;
    UtlString authQop;
    UtlString authRealm;
    UtlString authScheme;
    UtlString domainName;

    UtlBoolean isCredentialDB = TRUE;

    // if the configuration file exists, load the name value pairs
    if ( sConfigDb.loadFromFile(configFileName) == OS_SUCCESS )
    {
        Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                      "Found config file: %s", configFileName);
    } else
    {
       Os::Logger::instance().log(FAC_SIP, PRI_CRIT,
                     "Could not read config file: %s", configFileName);
       fprintf(stderr, "Could not read config file: %s", configFileName);
       exit(1);
    }

    Os::Logger::instance().log(LOG_FACILITY, PRI_INFO, "Starting - version: %s %s\n", VERSION, PACKAGE_REVISION);

    sConfigDb.get("SIP_STATUS_AUTHENTICATE_ALGORITHM", authAlgorithm);
    sConfigDb.get("SIP_STATUS_AUTHENTICATE_QOP", authQop);
    sConfigDb.get("SIP_STATUS_AUTHENTICATE_REALM", authRealm);
    sConfigDb.get("SIP_STATUS_AUTHENTICATE_SCHEME", authScheme);
    sConfigDb.get("SIP_STATUS_DOMAIN_NAME", domainName);
    sConfigDb.get("SIP_STATUS_HTTP_PORT", httpPort);
    sConfigDb.get("SIP_STATUS_HTTPS_PORT", httpsPort);
    sConfigDb.get("SIP_STATUS_MAX_EXPIRES", defaultMaxExpiresTime);
    sConfigDb.get("SIP_STATUS_MIN_EXPIRES", defaultMinExpiresTime);

    // SIP_STATUS_UDP_PORT
    udpPort = sConfigDb.getPort("SIP_STATUS_UDP_PORT") ;
    if ( udpPort == PORT_NONE )
    {
       udpPort = 5110;
    }
    Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIP_STATUS_UDP_PORT : %d", udpPort);

    // SIP_STATUS_TCP_PORT
    tcpPort = sConfigDb.getPort("SIP_STATUS_TCP_PORT") ;
    if ( tcpPort == PORT_NONE )
    {
       tcpPort = 5110;
    }
    Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIP_STATUS_TCP_PORT : %d", tcpPort);

    // SIP_STATUS_TLS_PORT
    tlsPort = sConfigDb.getPort("SIP_STATUS_TLS_PORT") ;
    if ( tlsPort == PORT_NONE )
    {
       tlsPort = 5111;
    }
    Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIP_STATUS_TLS_PORT : %d", tlsPort);

    // SIP_STATUS_BIND_IP
    sConfigDb.get("SIP_STATUS_BIND_IP", bindIp) ;
    if ((bindIp.isNull()) || !OsSocket::isIp4Address(bindIp))
    {
       bindIp = "0.0.0.0";
    }
    Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIP_STATUS_BIND_IP : %s", bindIp.data());

    UtlString separatedList;
    // Get the HTTP server Valid IP address database
    OsConfigDb* pValidIpAddressDB = new OsConfigDb();
    sConfigDb.get("SIP_STATUS_HTTP_VALID_IPS", separatedList);
    parseList ("SIP_STATUS_HTTP_VALID_IPS", separatedList, *pValidIpAddressDB);

    if( pValidIpAddressDB->isEmpty() )
    {
        delete pValidIpAddressDB;
        pValidIpAddressDB = NULL;
    }

    // Check for default values and, if not specified, set to defaults

    // SIP_STATUS_AUTHENTICATE_ALGORITHM
    if ( authAlgorithm.isNull() ) /* MD5/MD5SESS */
    {
        authAlgorithm.append("MD5");
    }
    Os::Logger::instance().log(FAC_SIP, PRI_INFO,
                  "SIP_STATUS_AUTHENTICATE_ALGORITHM : %s",
//.........这里部分代码省略.........
开发者ID:edaniels,项目名称:sipxecs,代码行数:101,代码来源:StatusServer.cpp

示例3: testManipulators

    void testManipulators()
    {
        OsConfigDb *pDb = new OsConfigDb();
        pDb->set("Key1", "Value1");
        CPPUNIT_ASSERT_MESSAGE("verify that the database is not empty", 
                               !pDb->isEmpty());
        CPPUNIT_ASSERT_MESSAGE("has one entry", pDb->numEntries()==1);
                                                                                
        // test the remove() method
        //
        // We put the following block in its own scope so that the UtlString
        // reference (stored in "value") is released as a side effect of going
        // out of scope.  Otherwise, it will look like a memory leak.
        {
            UtlString value;
                                                                                
            pDb->remove("Key1");
            CPPUNIT_ASSERT_MESSAGE("verify that it looks empty", pDb->isEmpty());
            CPPUNIT_ASSERT_MESSAGE("has zero entries", pDb->numEntries()==0);
                                                                                
            pDb->set("Key1", "Value1");   // add the entry back
            pDb->set("Key1", "Value1b");  // change the value for an existing entry
            CPPUNIT_ASSERT_MESSAGE("verify that the database is not empty", 
                                   !pDb->isEmpty());
            CPPUNIT_ASSERT_EQUAL_MESSAGE("has one entry", 1, pDb->numEntries());
                                                                                
            OsStatus res = pDb->get("Key1", value);
            CPPUNIT_ASSERT(res == OS_SUCCESS);
            CPPUNIT_ASSERT_MESSAGE("that contains the revised value", 
                value.compareTo("Value1b") == 0);
                                                                                
            pDb->set("Key2", "Value2");
            pDb->set("Key3", "Value3");
            pDb->set("Key4", "Value4");
            CPPUNIT_ASSERT_MESSAGE("check the number of entries", 
                                   pDb->numEntries()==4);
            value.remove(0);
        }
                                                                                
        // test the storeToFile() method
        pDb->storeToFile("tmpdb");         // store the config db to the file
        delete pDb;                   // delete the database
                                                                                
        // test the loadFromFile() method
        //
        // We put the following block in its own scope so that the UtlString
        // reference (stored in "value") is released as a side effect of going
        // out of scope.  Otherwise, it will look like a memory leak.
        {
            UtlString  value;
            
            pDb = new OsConfigDb();       // create an empty database
            pDb->loadFromFile("tmpdb");        // load the data from a file
        }
                                                                                
        CPPUNIT_ASSERT_MESSAGE("verify the database is not empty", 
                               !pDb->isEmpty());

        CPPUNIT_ASSERT_MESSAGE("has four entries", pDb->numEntries()==4);

        UtlString value;
        OsStatus res = pDb->get("Key1", value);
        CPPUNIT_ASSERT_MESSAGE("contains correct data", 
            res == OS_SUCCESS && value.compareTo("Value1b") == 0);

        res = pDb->get("Key2", value);
        CPPUNIT_ASSERT_MESSAGE("contains correct data",
            res == OS_SUCCESS && value.compareTo("Value2") == 0);

        res = pDb->get("Key3", value);
        CPPUNIT_ASSERT_MESSAGE("contains correct data",
            res == OS_SUCCESS && value.compareTo("Value3") == 0);

        res = pDb->get("Key4", value);
        CPPUNIT_ASSERT_MESSAGE("contains correct data",
            res == OS_SUCCESS && value.compareTo("Value4") == 0);

        delete pDb;                   // delete the database
        value.remove(0);
    }
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:80,代码来源:OsConfigDbTest.cpp

示例4: testAccessors

 void testAccessors()
 {
     OsConfigDb *pDb = new OsConfigDb();
                                                                             
     // the get() method is tested by testManipulators()
                                                                             
     // test the getNext() method
     //
     // We put the following block in its own scope so that the UtlString
     // references (stored in "name" and "value") are released as a side effect
     // of going out of scope.  Otherwise, it will look like a memory leak.
     {
         UtlString  name;
         UtlString  value;
                                                                             
         pDb->set("Key3", "Value3");   // add several entries (not in
         pDb->set("Key2", "Value2");   //  alphabetical or reverse alphabetical
         pDb->set("Key4", "Value4");   //  order
         pDb->set("Key1", "Value1");
         CPPUNIT_ASSERT_MESSAGE("verify that the database is not empty",
                                !pDb->isEmpty());
         CPPUNIT_ASSERT_MESSAGE("has four entries", pDb->numEntries()==4);
                                                                             
         OsStatus res = pDb->getNext("", name, value);      // call getNext("", ...)
         CPPUNIT_ASSERT_MESSAGE("verify that Key1/Value1", 
             res == OS_SUCCESS &&
             name.compareTo("Key1") == 0 &&     //  is returned
             value.compareTo("Value1") == 0);
                                                                             
         res = pDb->getNext("Key1", name, value);
         CPPUNIT_ASSERT_MESSAGE("call getNext(\"Key1\", ...)",
             res == OS_SUCCESS &&               //  verify that Key2/Value2
             name.compareTo("Key2") == 0 &&     //  is returned
             value.compareTo("Value2") == 0);
                                                                             
         res = pDb->getNext("Key2", name, value);
         CPPUNIT_ASSERT_MESSAGE("call getNext(\"Key2\", ...)", 
             res == OS_SUCCESS &&               //  verify that Key3/Value3
             name.compareTo("Key3") == 0 &&     //  is returned
             value.compareTo("Value3") == 0);
                                                                             
         res = pDb->getNext("Key3", name, value);
         CPPUNIT_ASSERT_MESSAGE("call getNext(\"Key3\", ...)", 
             res == OS_SUCCESS &&
             name.compareTo("Key4") == 0 &&
             value.compareTo("Value4") == 0);
     
         res = pDb->getNext("Key4", name, value);
         CPPUNIT_ASSERT_MESSAGE("call getNext(\"Key4\", ...)", 
              res == OS_NO_MORE_DATA &&
              name.compareTo("") == 0 &&
              value.compareTo("") == 0);
                                                                             
         res = pDb->getNext("XXX", name, value);
         CPPUNIT_ASSERT_MESSAGE("call getNext with a key not in the database and verify",
             res == OS_NOT_FOUND &&         
             name.compareTo("") == 0 &&      //  that empty strings are
            value.compareTo("") == 0);       //  returned for the next name
                                             //  and value pair.
                                                                             
         delete pDb;                               // delete the database
         name.remove(0);
         value.remove(0);
     }
 }
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:65,代码来源:OsConfigDbTest.cpp


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