Use "std::map" instead of "propertySet" in url class.
This commit is contained in:
parent
5915ca4e34
commit
e760842265
@ -130,26 +130,23 @@ const string url::build() const
|
|||||||
oss << urlUtils::encode(m_path);
|
oss << urlUtils::encode(m_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector <ref <const propertySet::property> > params
|
|
||||||
= m_params.getPropertyList();
|
|
||||||
|
|
||||||
if (!params.empty())
|
if (!m_params.empty())
|
||||||
{
|
{
|
||||||
if (m_path.empty())
|
if (m_path.empty())
|
||||||
oss << "/";
|
oss << "/";
|
||||||
|
|
||||||
oss << "?";
|
oss << "?";
|
||||||
|
|
||||||
for (unsigned int i = 0 ; i < params.size() ; ++i)
|
for (std::map <string, string>::const_iterator it = m_params.begin() ;
|
||||||
|
it != m_params.end() ; ++it)
|
||||||
{
|
{
|
||||||
const ref <const propertySet::property> prop = params[i];
|
if (it != m_params.begin())
|
||||||
|
|
||||||
if (i != 0)
|
|
||||||
oss << "&";
|
oss << "&";
|
||||||
|
|
||||||
oss << urlUtils::encode(prop->getName());
|
oss << urlUtils::encode((*it).first);
|
||||||
oss << "=";
|
oss << "=";
|
||||||
oss << urlUtils::encode(prop->getValue <string>());
|
oss << urlUtils::encode((*it).second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +264,7 @@ void url::parse(const string& str)
|
|||||||
portNum = UNSPECIFIED_PORT;
|
portNum = UNSPECIFIED_PORT;
|
||||||
|
|
||||||
// Extract parameters
|
// Extract parameters
|
||||||
m_params.removeAllProperties();
|
m_params.clear();
|
||||||
|
|
||||||
if (!params.empty())
|
if (!params.empty())
|
||||||
{
|
{
|
||||||
@ -300,7 +297,7 @@ void url::parse(const string& str)
|
|||||||
name = urlUtils::decode(name);
|
name = urlUtils::decode(name);
|
||||||
value = urlUtils::decode(value);
|
value = urlUtils::decode(value);
|
||||||
|
|
||||||
m_params.setProperty(name, value);
|
m_params[name] = value;
|
||||||
|
|
||||||
if (pos != string::npos)
|
if (pos != string::npos)
|
||||||
++pos;
|
++pos;
|
||||||
@ -393,13 +390,13 @@ void url::setPath(const string& path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const propertySet& url::getParams() const
|
const std::map <string, string>& url::getParams() const
|
||||||
{
|
{
|
||||||
return (m_params);
|
return (m_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
propertySet& url::getParams()
|
std::map <string, string>& url::getParams()
|
||||||
{
|
{
|
||||||
return (m_params);
|
return (m_params);
|
||||||
}
|
}
|
||||||
|
@ -164,29 +164,29 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
|
|||||||
vmime::utility::url u1("", "");
|
vmime::utility::url u1("", "");
|
||||||
|
|
||||||
VASSERT_EQ("1.1", true, parseHelper(u1, "proto://host/path?p1=v1&p2=v2"));
|
VASSERT_EQ("1.1", true, parseHelper(u1, "proto://host/path?p1=v1&p2=v2"));
|
||||||
VASSERT_EQ("1.2", "v1", u1.getParams().getProperty <vmime::string>("p1"));
|
VASSERT_EQ("1.2", "v1", u1.getParams()["p1"]);
|
||||||
VASSERT_EQ("1.3", "v2", u1.getParams().getProperty <vmime::string>("p2"));
|
VASSERT_EQ("1.3", "v2", u1.getParams()["p2"]);
|
||||||
VASSERT_EQ("1.4", "/path", u1.getPath());
|
VASSERT_EQ("1.4", "/path", u1.getPath());
|
||||||
|
|
||||||
vmime::utility::url u2("", "");
|
vmime::utility::url u2("", "");
|
||||||
|
|
||||||
VASSERT_EQ("2.1", true, parseHelper(u2, "proto://host/path?p1=v1&p2"));
|
VASSERT_EQ("2.1", true, parseHelper(u2, "proto://host/path?p1=v1&p2"));
|
||||||
VASSERT_EQ("2.2", "v1", u2.getParams().getProperty <vmime::string>("p1"));
|
VASSERT_EQ("2.2", "v1", u2.getParams()["p1"]);
|
||||||
VASSERT_EQ("2.3", "p2", u2.getParams().getProperty <vmime::string>("p2"));
|
VASSERT_EQ("2.3", "p2", u2.getParams()["p2"]);
|
||||||
VASSERT_EQ("2.4", "/path", u2.getPath());
|
VASSERT_EQ("2.4", "/path", u2.getPath());
|
||||||
|
|
||||||
vmime::utility::url u3("", "");
|
vmime::utility::url u3("", "");
|
||||||
|
|
||||||
VASSERT_EQ("3.1", true, parseHelper(u3, "proto://host/?p1=v1&p2=v2"));
|
VASSERT_EQ("3.1", true, parseHelper(u3, "proto://host/?p1=v1&p2=v2"));
|
||||||
VASSERT_EQ("3.2", "v1", u3.getParams().getProperty <vmime::string>("p1"));
|
VASSERT_EQ("3.2", "v1", u3.getParams()["p1"]);
|
||||||
VASSERT_EQ("3.3", "v2", u3.getParams().getProperty <vmime::string>("p2"));
|
VASSERT_EQ("3.3", "v2", u3.getParams()["p2"]);
|
||||||
VASSERT_EQ("3.4", "", u3.getPath());
|
VASSERT_EQ("3.4", "", u3.getPath());
|
||||||
|
|
||||||
vmime::utility::url u4("", "");
|
vmime::utility::url u4("", "");
|
||||||
|
|
||||||
VASSERT_EQ("4.1", true, parseHelper(u4, "proto://host/path?p1=%3D&%3D=v2"));
|
VASSERT_EQ("4.1", true, parseHelper(u4, "proto://host/path?p1=%3D&%3D=v2"));
|
||||||
VASSERT_EQ("4.2", "=", u4.getParams().getProperty <vmime::string>("p1"));
|
VASSERT_EQ("4.2", "=", u4.getParams()["p1"]);
|
||||||
VASSERT_EQ("4.3", "v2", u4.getParams().getProperty <vmime::string>("="));
|
VASSERT_EQ("4.3", "v2", u4.getParams()["="]);
|
||||||
VASSERT_EQ("4.4", "/path", u4.getPath());
|
VASSERT_EQ("4.4", "/path", u4.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,14 +211,17 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
|
|||||||
VASSERT_EQ("2", "proto://host", static_cast <vmime::string>(u2));
|
VASSERT_EQ("2", "proto://host", static_cast <vmime::string>(u2));
|
||||||
|
|
||||||
vmime::utility::url u3("proto", "host");
|
vmime::utility::url u3("proto", "host");
|
||||||
u3.getParams().setProperty("p1", "v1");
|
u3.getParams()["p1"] = "v1";
|
||||||
VASSERT_EQ("3.1", "proto://host/?p1=v1",
|
VASSERT_EQ("3.1", "proto://host/?p1=v1",
|
||||||
static_cast <vmime::string>(u3));
|
static_cast <vmime::string>(u3));
|
||||||
u3.getParams().setProperty("p2", "v2");
|
u3.getParams()["p2"] = "v2";
|
||||||
VASSERT_EQ("3.2", "proto://host/?p1=v1&p2=v2",
|
VASSERT_EQ("3.2", "proto://host/?p1=v1&p2=v2",
|
||||||
static_cast <vmime::string>(u3));
|
static_cast <vmime::string>(u3));
|
||||||
u3.getParams().setProperty("&", "=");
|
|
||||||
VASSERT_EQ("3.3", "proto://host/?p1=v1&p2=v2&%26=%3D",
|
// Test special characters
|
||||||
|
u3.getParams().clear();
|
||||||
|
u3.getParams()["&"] = "=";
|
||||||
|
VASSERT_EQ("3.3", "proto://host/?%26=%3D",
|
||||||
static_cast <vmime::string>(u3));
|
static_cast <vmime::string>(u3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,13 +162,13 @@ public:
|
|||||||
*
|
*
|
||||||
* @return parameters
|
* @return parameters
|
||||||
*/
|
*/
|
||||||
const propertySet& getParams() const;
|
const std::map <string, string>& getParams() const;
|
||||||
|
|
||||||
/** Return the parameters of the URL.
|
/** Return the parameters of the URL.
|
||||||
*
|
*
|
||||||
* @return parameters
|
* @return parameters
|
||||||
*/
|
*/
|
||||||
propertySet& getParams();
|
std::map <string, string>& getParams();
|
||||||
|
|
||||||
/** Build a string URL from this object.
|
/** Build a string URL from this object.
|
||||||
*/
|
*/
|
||||||
@ -196,7 +196,7 @@ private:
|
|||||||
|
|
||||||
string m_path;
|
string m_path;
|
||||||
|
|
||||||
propertySet m_params;
|
std::map <string, string> m_params;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user