File: nc-query-utils.cpp

package info (click to toggle)
yuma123 2.13-1
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 22,364 kB
  • sloc: ansic: 185,010; cpp: 10,966; python: 7,902; sh: 2,631; makefile: 1,179; xml: 807; exp: 759; perl: 70
file content (46 lines) | stat: -rw-r--r-- 1,676 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// ---------------------------------------------------------------------------|
// Yuma Test Harness includes
// ---------------------------------------------------------------------------|
#include "test/support/nc-query-util/nc-query-utils.h"

// ---------------------------------------------------------------------------|
// STD Includes 
// ---------------------------------------------------------------------------|
#include <boost/xpressive/xpressive.hpp>
#include <boost/lexical_cast.hpp>

// ---------------------------------------------------------------------------|
// Boost Test Framework
// ---------------------------------------------------------------------------|
#include <boost/test/unit_test.hpp>

// ---------------------------------------------------------------------------|
// Global namespace usage
// ---------------------------------------------------------------------------|
using namespace std;

// ---------------------------------------------------------------------------|
namespace YumaTest
{

// ---------------------------------------------------------------------------|
string extractMessageIdStr( const std::string& query )
{
    using namespace boost::xpressive;

    sregex re = sregex::compile( "message-id=\"(\\d+)\"" ); 
    smatch what;

    // find a whole word
    BOOST_REQUIRE_MESSAGE( regex_search( query, what, re ), 
                           "Invalid XML Query - No message-id!" );
    return what[1];
}

// ---------------------------------------------------------------------------|
uint16_t extractMessageId( const std::string& query )
{
    return boost::lexical_cast<uint16_t>( extractMessageIdStr( query ) );
}

}