Files
miscservices_time/services/dfx/src/time_cmd_parse.cpp
T
GlaryCastle cf90cbe315 Signed-off-by: GlaryCastle <yangpeng190@huawei.com>
Changes to be committed:
	modified:   services/BUILD.gn
	modified:   services/dfx/include/time_cmd_dispatcher.h
	modified:   services/dfx/include/time_cmd_parse.h
	modified:   services/dfx/include/time_sysevent.h
	deleted:    services/dfx/include/time_trace.h
	modified:   services/dfx/src/time_cmd_dispatcher.cpp
	modified:   services/dfx/src/time_cmd_parse.cpp
	modified:   services/dfx/src/time_sysevent.cpp
	deleted:    services/dfx/src/time_trace.cpp
	modified:   services/time_manager/test/unittest/src/time_service_test.cpp
2022-07-08 18:17:38 +08:00

51 lines
1.4 KiB
C++

/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "time_cmd_parse.h"
TimeCmdParse::TimeCmdParse(
const std::vector<std::string> &argsFormat, const std::string &strHelp, const TimeCmdParse::Action &action)
: format(argsFormat), help(strHelp), action(action)
{
}
std::string TimeCmdParse::ShowHelp()
{
return help;
}
void TimeCmdParse::DoAction(int fd, const std::vector<std::string> &input)
{
action(fd, input);
}
std::string TimeCmdParse::GetOption()
{
std::string formatTitle;
for (unsigned long i = 0; i < format.size() - 1; i++) {
formatTitle += format.at(i);
formatTitle += " ";
}
return formatTitle.substr(0, formatTitle.length() - 1);
}
std::string TimeCmdParse::GetFormat()
{
std::string formatStr;
for (auto &seg : format) {
formatStr += seg;
formatStr += " ";
}
return formatStr;
}