Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
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
protobuf
Commits
6e0a6d1c
Commit
6e0a6d1c
authored
Aug 05, 2019
by
reed-lau
Committed by
Adam Cozzette
Aug 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add move constructor for Reflection's SetString
parent
43156775
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
generated_message_reflection.cc
src/google/protobuf/generated_message_reflection.cc
+32
-0
message.h
src/google/protobuf/message.h
+2
-0
No files found.
src/google/protobuf/generated_message_reflection.cc
View file @
6e0a6d1c
...
...
@@ -1223,6 +1223,38 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
}
void
Reflection
::
SetString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
std
::
string
&&
value
)
const
{
USAGE_CHECK_ALL
(
SetString
,
SINGULAR
,
STRING
);
if
(
field
->
is_extension
())
{
return
MutableExtensionSet
(
message
)
->
SetString
(
field
->
number
(),
field
->
type
(),
value
,
field
);
}
else
{
switch
(
field
->
options
().
ctype
())
{
default
:
// TODO(kenton): Support other string reps.
case
FieldOptions
:
:
STRING
:
{
if
(
IsInlined
(
field
))
{
MutableField
<
InlinedStringField
>
(
message
,
field
)
->
SetNoArena
(
nullptr
,
value
);
break
;
}
const
std
::
string
*
default_ptr
=
&
DefaultRaw
<
ArenaStringPtr
>
(
field
).
Get
();
if
(
field
->
containing_oneof
()
&&
!
HasOneofField
(
*
message
,
field
))
{
ClearOneof
(
message
,
field
->
containing_oneof
());
MutableField
<
ArenaStringPtr
>
(
message
,
field
)
->
UnsafeSetDefault
(
default_ptr
);
}
*
(
MutableField
<
ArenaStringPtr
>
(
message
,
field
)
->
Mutable
(
default_ptr
,
GetArena
(
message
)))
=
value
;
break
;
}
}
}
}
std
::
string
Reflection
::
GetRepeatedString
(
const
Message
&
message
,
const
FieldDescriptor
*
field
,
int
index
)
const
{
...
...
src/google/protobuf/message.h
View file @
6e0a6d1c
...
...
@@ -540,6 +540,8 @@ class PROTOBUF_EXPORT Reflection final {
bool
value
)
const
;
void
SetString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
std
::
string
&
value
)
const
;
void
SetString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
std
::
string
&&
value
)
const
;
void
SetEnum
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
EnumValueDescriptor
*
value
)
const
;
// Set an enum field's value with an integer rather than EnumValueDescriptor.
...
...
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