tars_filter.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Tencent is pleased to support the open source community by making Tars available.
  3. *
  4. * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
  5. *
  6. * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  7. * in compliance with the License. You may obtain a copy of the License at
  8. *
  9. * https://opensource.org/licenses/BSD-3-Clause
  10. *
  11. * Unless required by applicable law or agreed to in writing, software distributed
  12. * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  13. * CONDITIONS OF ANY KIND, either express or implied. See the License for the
  14. * specific language governing permissions and limitations under the License.
  15. */
  16. #include "tars_filter.h"
  17. TarsFilter::TarsFilter() {
  18. addSid("TRom::E_ROM_DEVICE_TYPE");
  19. addSid("TRom::EAPNTYPE");
  20. addSid("TRom::EIPType");
  21. addSid("TRom::ELOGINRET");
  22. addSid("TRom::ENETTYPE");
  23. addSid("TRom::IPListReq");
  24. addSid("TRom::IPListRsp");
  25. addSid("TRom::JoinIPInfo");
  26. addSid("TRom::LoginReq");
  27. addSid("TRom::LoginRsp");
  28. addSid("TRom::RomBaseInfo");
  29. addSid("TRom::SECPROXY_RETCODE");
  30. addSid("TRom::SecureReq");
  31. addSid("TRom::SecureRsp");
  32. }
  33. void TarsFilter::addSid(const std::string& sid) {
  34. mFilterTarsSidMap.insert(std::pair<std::string, bool>(sid, true));
  35. }
  36. void TarsFilter::filterStructs(
  37. const std::map<std::string, StructPtr>& orignalMap
  38. , std::map<std::string, StructPtr>& resultMap) const {
  39. for (std::map<std::string, StructPtr>::const_iterator it = orignalMap.begin()
  40. ; it != orignalMap.end(); ++it) {
  41. if (mFilterTarsSidMap.find(it->first) != mFilterTarsSidMap.end()) {
  42. continue;
  43. }
  44. resultMap.insert(std::pair<std::string, StructPtr>(it->first, it->second));
  45. }
  46. }
  47. void TarsFilter::filterEnums(
  48. const std::map<std::string, EnumPtr>& orignalMap
  49. , std::map<std::string, EnumPtr>& resultMap) const {
  50. for (std::map<std::string, EnumPtr>::const_iterator it = orignalMap.begin()
  51. ; it != orignalMap.end(); ++it) {
  52. if (mFilterTarsSidMap.find(it->first) != mFilterTarsSidMap.end()) {
  53. continue;
  54. }
  55. resultMap.insert(std::pair<std::string, EnumPtr>(it->first, it->second));
  56. }
  57. }