mirror of
https://github.com/openharmony/miscservices_time.git
synced 2026-07-19 12:02:04 -04:00
cf90cbe315
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
51 lines
1.4 KiB
C++
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;
|
|
} |