443df7932c
Support the following commands: lshal list lshal list -itrpc lshal help lshal help list lshal list -h lshal list --help Test: run these commands Bug: 37725279 Change-Id: I970fbc8d250d43f57e92f783229e0645d7e8df4e
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
/*
|
|
* Copyright (C) 2017 The Android Open Source Project
|
|
*
|
|
* 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 "utils.h"
|
|
|
|
namespace android {
|
|
namespace lshal {
|
|
|
|
std::string toHexString(uint64_t t) {
|
|
std::ostringstream os;
|
|
os << std::hex << std::setfill('0') << std::setw(16) << t;
|
|
return os.str();
|
|
}
|
|
|
|
std::vector<std::string> split(const std::string &s, char c) {
|
|
std::vector<std::string> components{};
|
|
size_t startPos = 0;
|
|
size_t matchPos;
|
|
while ((matchPos = s.find(c, startPos)) != std::string::npos) {
|
|
components.push_back(s.substr(startPos, matchPos - startPos));
|
|
startPos = matchPos + 1;
|
|
}
|
|
|
|
if (startPos <= s.length()) {
|
|
components.push_back(s.substr(startPos));
|
|
}
|
|
return components;
|
|
}
|
|
|
|
void replaceAll(std::string *s, char from, char to) {
|
|
for (size_t i = 0; i < s->size(); ++i) {
|
|
if (s->at(i) == from) {
|
|
s->at(i) = to;
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace lshal
|
|
} // namespace android
|
|
|