mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
THRIFT-1275. cpp: always prefix namespaces with ' ::'
Ensures no accidental namespace clashes. Patch: Adam Simpkins git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1159729 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
887ff756cb
commit
0b7eeb5975
@ -3737,10 +3737,17 @@ void t_cpp_generator::generate_serialize_list_element(ofstream& out,
|
||||
* @return Namespaces
|
||||
*/
|
||||
string t_cpp_generator::namespace_prefix(string ns) {
|
||||
// Always start with "::", to avoid possible name collisions with
|
||||
// other names in one of the current namespaces.
|
||||
//
|
||||
// We also need a leading space, in case the name is used inside of a
|
||||
// template parameter. "MyTemplate<::foo::Bar>" is not valid C++,
|
||||
// since "<:" is an alternative token for "[".
|
||||
string result = " ::";
|
||||
|
||||
if (ns.size() == 0) {
|
||||
return "";
|
||||
return result;
|
||||
}
|
||||
string result = "";
|
||||
string::size_type loc;
|
||||
while ((loc = ns.find(".")) != string::npos) {
|
||||
result += ns.substr(0, loc);
|
||||
|
Loading…
Reference in New Issue
Block a user