Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
c692005b
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c692005b
编写于
11月 18, 2019
作者:
X
Xiangquan Xiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Common: Retire unused DecodeBase64.
上级
6081f69f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
0 addition
and
45 deletion
+0
-45
modules/common/util/string_util.cc
modules/common/util/string_util.cc
+0
-33
modules/common/util/string_util.h
modules/common/util/string_util.h
+0
-2
modules/common/util/string_util_test.cc
modules/common/util/string_util_test.cc
+0
-10
未找到文件。
modules/common/util/string_util.cc
浏览文件 @
c692005b
...
...
@@ -27,16 +27,6 @@ namespace {
static
const
char
kBase64Array
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
// A table which maps a char to its value in Base64 mode.
std
::
vector
<
int
>
Base64CodeTable
()
{
std
::
vector
<
int
>
table
(
256
,
-
1
);
const
size_t
base64_array_length
=
strlen
(
kBase64Array
);
for
(
size_t
i
=
0
;
i
<
base64_array_length
;
++
i
)
{
table
[
kBase64Array
[
i
]]
=
static_cast
<
int
>
(
i
);
}
return
table
;
}
const
char
*
tripletBase64
(
const
int
triplet
)
{
static
char
result
[
4
];
result
[
0
]
=
kBase64Array
[(
triplet
>>
18
)
&
0x3f
];
...
...
@@ -48,29 +38,6 @@ const char* tripletBase64(const int triplet) {
}
// namespace
std
::
string
DecodeBase64
(
const
std
::
string
&
base64_str
)
{
static
const
std
::
vector
<
int
>
kBase64CodeTable
=
Base64CodeTable
();
std
::
string
bytes
;
// Binary string is generally 3/4 the length of base64 string
bytes
.
reserve
(
base64_str
.
length
()
*
3
/
4
+
3
);
unsigned
int
sum
=
0
,
sum_bits
=
0
;
for
(
const
char
c
:
base64_str
)
{
if
(
kBase64CodeTable
[
c
]
==
-
1
)
{
break
;
}
// Convert 6-bits Base64 chars to 8-bits general bytes.
sum
=
(
sum
<<
6
)
+
kBase64CodeTable
[
c
];
sum_bits
+=
6
;
if
(
sum_bits
>=
8
)
{
bytes
.
push_back
(
static_cast
<
char
>
((
sum
>>
(
sum_bits
-
8
))
&
0xFF
));
sum_bits
-=
8
;
}
}
return
bytes
;
}
std
::
string
EncodeBase64
(
const
std
::
string
&
in
)
{
std
::
string
out
;
if
(
in
.
empty
())
{
...
...
modules/common/util/string_util.h
浏览文件 @
c692005b
...
...
@@ -43,8 +43,6 @@ struct DebugStringFormatter {
}
};
std
::
string
DecodeBase64
(
const
std
::
string
&
base64_str
);
std
::
string
EncodeBase64
(
const
std
::
string
&
in
);
}
// namespace util
...
...
modules/common/util/string_util_test.cc
浏览文件 @
c692005b
...
...
@@ -24,16 +24,6 @@ namespace apollo {
namespace
common
{
namespace
util
{
TEST
(
StringUtilTest
,
DecodeBase64
)
{
EXPECT_EQ
(
""
,
DecodeBase64
(
""
));
EXPECT_EQ
(
"f"
,
DecodeBase64
(
"Zg=="
));
EXPECT_EQ
(
"fo"
,
DecodeBase64
(
"Zm8="
));
EXPECT_EQ
(
"foo"
,
DecodeBase64
(
"Zm9v"
));
EXPECT_EQ
(
"foob"
,
DecodeBase64
(
"Zm9vYg=="
));
EXPECT_EQ
(
"fooba"
,
DecodeBase64
(
"Zm9vYmE="
));
EXPECT_EQ
(
"foobar"
,
DecodeBase64
(
"Zm9vYmFy"
));
}
TEST
(
StringUtilTest
,
EncodeBase64
)
{
EXPECT_EQ
(
""
,
EncodeBase64
(
""
));
EXPECT_EQ
(
"Zg=="
,
EncodeBase64
(
"f"
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录