eget URI support
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace std::tr1;
|
||||
@@ -283,3 +284,39 @@ epics::pvData::FieldConstPtr GetFieldRequesterImpl::getField()
|
||||
Lock lock(m_pointerMutex);
|
||||
return m_field;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO invalid characters check, etc.
|
||||
bool URI::parse(const string& uri, URI& result)
|
||||
{
|
||||
const string prot_end("://");
|
||||
string::const_iterator prot_i = search(uri.begin(), uri.end(),
|
||||
prot_end.begin(), prot_end.end());
|
||||
if( prot_i == uri.end() || prot_i == uri.begin() )
|
||||
return false;
|
||||
|
||||
result.protocol.reserve(distance(uri.begin(), prot_i));
|
||||
transform(uri.begin(), prot_i,
|
||||
back_inserter(result.protocol),
|
||||
::tolower); // protocol is icase
|
||||
|
||||
advance(prot_i, prot_end.length());
|
||||
if ( prot_i == uri.end() )
|
||||
return false;
|
||||
|
||||
string::const_iterator path_i = find(prot_i, uri.end(), '/');
|
||||
result.host.assign(prot_i, path_i);
|
||||
|
||||
string::const_iterator fragment_i = find(path_i, uri.end(), '#');
|
||||
if ( fragment_i != uri.end() )
|
||||
result.fragment.assign(fragment_i+1, uri.end());
|
||||
|
||||
string::const_iterator query_i = find(path_i, fragment_i, '?');
|
||||
result.path.assign(path_i, query_i);
|
||||
if( query_i != fragment_i )
|
||||
result.query.assign(++query_i, fragment_i);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user