Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
f0d7e5cf
Commit
f0d7e5cf
authored
Sep 29, 2018
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AdaptiveProtocolType saves unknown name and supports parameter after colon
parent
88ad7672
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
+34
-5
adaptive_protocol_type.h
src/brpc/adaptive_protocol_type.h
+34
-5
No files found.
src/brpc/adaptive_protocol_type.h
View file @
f0d7e5cf
...
...
@@ -43,18 +43,47 @@ public:
AdaptiveProtocolType
(
ProtocolType
type
)
:
_type
(
type
)
{}
~
AdaptiveProtocolType
()
{}
void
operator
=
(
ProtocolType
type
)
{
_type
=
type
;
}
void
operator
=
(
const
butil
::
StringPiece
&
name
)
{
_type
=
StringToProtocolType
(
name
);
};
void
operator
=
(
ProtocolType
type
)
{
_type
=
type
;
_name
.
clear
();
_param
.
clear
();
}
void
operator
=
(
butil
::
StringPiece
name
)
{
butil
::
StringPiece
param
;
const
size_t
pos
=
name
.
find
(
':'
);
if
(
pos
!=
butil
::
StringPiece
::
npos
)
{
param
=
name
.
substr
(
pos
+
1
);
name
.
remove_suffix
(
name
.
size
()
-
pos
);
}
_type
=
StringToProtocolType
(
name
);
if
(
_type
==
PROTOCOL_UNKNOWN
)
{
_name
.
assign
(
name
.
data
(),
name
.
size
());
}
else
{
_name
.
clear
();
}
if
(
!
param
.
empty
())
{
_param
.
assign
(
param
.
data
(),
param
.
size
());
}
else
{
_param
.
clear
();
}
};
operator
ProtocolType
()
const
{
return
_type
;
}
const
char
*
name
()
const
{
return
ProtocolTypeToString
(
_type
);
}
const
char
*
name
()
const
{
return
_name
.
empty
()
?
ProtocolTypeToString
(
_type
)
:
_name
.
c_str
();
}
bool
has_param
()
const
{
return
!
_param
.
empty
();
}
const
std
::
string
&
param
()
const
{
return
_param
;
}
private
:
ProtocolType
_type
;
std
::
string
_name
;
std
::
string
_param
;
};
}
// namespace brpc
#endif // BRPC_ADAPTIVE_PROTOCOL_TYPE_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment