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
218df038
Commit
218df038
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 movable String interface Reflection
parent
6e0a6d1c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
5 deletions
+58
-5
extension_set.h
src/google/protobuf/extension_set.h
+17
-1
generated_message_reflection.cc
src/google/protobuf/generated_message_reflection.cc
+36
-3
message.h
src/google/protobuf/message.h
+5
-1
No files found.
src/google/protobuf/extension_set.h
View file @
218df038
...
...
@@ -269,6 +269,7 @@ class PROTOBUF_EXPORT ExtensionSet {
void
SetBool
(
int
number
,
FieldType
type
,
bool
value
,
desc
);
void
SetEnum
(
int
number
,
FieldType
type
,
int
value
,
desc
);
void
SetString
(
int
number
,
FieldType
type
,
const
std
::
string
&
value
,
desc
);
void
SetString
(
int
number
,
FieldType
type
,
std
::
string
&&
value
,
desc
);
std
::
string
*
MutableString
(
int
number
,
FieldType
type
,
desc
);
MessageLite
*
MutableMessage
(
int
number
,
FieldType
type
,
const
MessageLite
&
prototype
,
desc
);
...
...
@@ -332,6 +333,7 @@ class PROTOBUF_EXPORT ExtensionSet {
void
SetRepeatedBool
(
int
number
,
int
index
,
bool
value
);
void
SetRepeatedEnum
(
int
number
,
int
index
,
int
value
);
void
SetRepeatedString
(
int
number
,
int
index
,
const
std
::
string
&
value
);
void
SetRepeatedString
(
int
number
,
int
index
,
std
::
string
&&
value
);
std
::
string
*
MutableRepeatedString
(
int
number
,
int
index
);
MessageLite
*
MutableRepeatedMessage
(
int
number
,
int
index
);
...
...
@@ -345,6 +347,7 @@ class PROTOBUF_EXPORT ExtensionSet {
void
AddBool
(
int
number
,
FieldType
type
,
bool
packed
,
bool
value
,
desc
);
void
AddEnum
(
int
number
,
FieldType
type
,
bool
packed
,
int
value
,
desc
);
void
AddString
(
int
number
,
FieldType
type
,
const
std
::
string
&
value
,
desc
);
void
AddString
(
int
number
,
FieldType
type
,
std
::
string
&&
value
,
desc
);
std
::
string
*
AddString
(
int
number
,
FieldType
type
,
desc
);
MessageLite
*
AddMessage
(
int
number
,
FieldType
type
,
const
MessageLite
&
prototype
,
desc
);
...
...
@@ -862,16 +865,29 @@ inline void ExtensionSet::SetString(int number, FieldType type,
const
FieldDescriptor
*
descriptor
)
{
MutableString
(
number
,
type
,
descriptor
)
->
assign
(
value
);
}
inline
void
ExtensionSet
::
SetString
(
int
number
,
FieldType
type
,
std
::
string
&&
value
,
const
FieldDescriptor
*
descriptor
)
{
*
MutableString
(
number
,
type
,
descriptor
)
=
std
::
move
(
value
);
}
inline
void
ExtensionSet
::
SetRepeatedString
(
int
number
,
int
index
,
const
std
::
string
&
value
)
{
MutableRepeatedString
(
number
,
index
)
->
assign
(
value
);
}
inline
void
ExtensionSet
::
SetRepeatedString
(
int
number
,
int
index
,
std
::
string
&&
value
)
{
*
MutableRepeatedString
(
number
,
index
)
=
std
::
move
(
value
);
}
inline
void
ExtensionSet
::
AddString
(
int
number
,
FieldType
type
,
const
std
::
string
&
value
,
const
FieldDescriptor
*
descriptor
)
{
AddString
(
number
,
type
,
descriptor
)
->
assign
(
value
);
}
inline
void
ExtensionSet
::
AddString
(
int
number
,
FieldType
type
,
std
::
string
&&
value
,
const
FieldDescriptor
*
descriptor
)
{
*
AddString
(
number
,
type
,
descriptor
)
=
std
::
move
(
value
);
}
// ===================================================================
// Glue for generated extension accessors
...
...
src/google/protobuf/generated_message_reflection.cc
View file @
218df038
...
...
@@ -1224,11 +1224,11 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
void
Reflection
::
SetString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
std
::
string
&&
value
)
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
);
field
->
type
(),
std
::
move
(
value
)
,
field
);
}
else
{
switch
(
field
->
options
().
ctype
())
{
default
:
// TODO(kenton): Support other string reps.
...
...
@@ -1247,7 +1247,7 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
->
UnsafeSetDefault
(
default_ptr
);
}
*
(
MutableField
<
ArenaStringPtr
>
(
message
,
field
)
->
Mutable
(
default_ptr
,
GetArena
(
message
)))
=
value
;
->
Mutable
(
default_ptr
,
GetArena
(
message
)))
=
std
::
move
(
value
)
;
break
;
}
}
...
...
@@ -1304,6 +1304,23 @@ void Reflection::SetRepeatedString(Message* message,
}
void
Reflection
::
SetRepeatedString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
int
index
,
std
::
string
&&
value
)
const
{
USAGE_CHECK_ALL
(
SetRepeatedString
,
REPEATED
,
STRING
);
if
(
field
->
is_extension
())
{
MutableExtensionSet
(
message
)
->
SetRepeatedString
(
field
->
number
(),
index
,
std
::
move
(
value
));
}
else
{
switch
(
field
->
options
().
ctype
())
{
default
:
// TODO(kenton): Support other string reps.
case
FieldOptions
:
:
STRING
:
*
MutableRepeatedField
<
std
::
string
>
(
message
,
field
,
index
)
=
std
::
move
(
value
);
break
;
}
}
}
void
Reflection
::
AddString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
std
::
string
&
value
)
const
{
USAGE_CHECK_ALL
(
AddString
,
REPEATED
,
STRING
);
...
...
@@ -1321,6 +1338,22 @@ void Reflection::AddString(Message* message, const FieldDescriptor* field,
}
void
Reflection
::
AddString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
std
::
string
&&
value
)
const
{
USAGE_CHECK_ALL
(
AddString
,
REPEATED
,
STRING
);
if
(
field
->
is_extension
())
{
MutableExtensionSet
(
message
)
->
AddString
(
field
->
number
(),
field
->
type
(),
std
::
move
(
value
),
field
);
}
else
{
switch
(
field
->
options
().
ctype
())
{
default
:
// TODO(kenton): Support other string reps.
case
FieldOptions
:
:
STRING
:
*
AddField
<
std
::
string
>
(
message
,
field
)
=
std
::
move
(
value
);
break
;
}
}
}
// -------------------------------------------------------------------
const
EnumValueDescriptor
*
Reflection
::
GetEnum
(
...
...
src/google/protobuf/message.h
View file @
218df038
...
...
@@ -541,7 +541,7 @@ class PROTOBUF_EXPORT Reflection final {
void
SetString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
std
::
string
&
value
)
const
;
void
SetString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
std
::
string
&&
value
)
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.
...
...
@@ -642,6 +642,8 @@ class PROTOBUF_EXPORT Reflection final {
int
index
,
bool
value
)
const
;
void
SetRepeatedString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
int
index
,
const
std
::
string
&
value
)
const
;
void
SetRepeatedString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
int
index
,
std
::
string
&&
value
)
const
;
void
SetRepeatedEnum
(
Message
*
message
,
const
FieldDescriptor
*
field
,
int
index
,
const
EnumValueDescriptor
*
value
)
const
;
// Set an enum field's value with an integer rather than EnumValueDescriptor.
...
...
@@ -679,6 +681,8 @@ class PROTOBUF_EXPORT Reflection final {
bool
value
)
const
;
void
AddString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
std
::
string
&
value
)
const
;
void
AddString
(
Message
*
message
,
const
FieldDescriptor
*
field
,
std
::
string
&&
value
)
const
;
void
AddEnum
(
Message
*
message
,
const
FieldDescriptor
*
field
,
const
EnumValueDescriptor
*
value
)
const
;
// Add an integer value to a repeated enum field rather than
...
...
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