Remove boost::program_options dependency #13482

pull ken2812221 wants to merge 2 commits into bitcoin:master from ken2812221:program_options changing 7 files +42 −123
  1. ken2812221 commented at 4:25 AM on June 16, 2018: contributor

    Concept from #12744, but without parsing negated options.

  2. fanquake added the label Refactoring on Jun 16, 2018
  3. ken2812221 force-pushed on Jun 16, 2018
  4. in src/util.h:290 in 9b0d45aa74 outdated
     281 | @@ -282,6 +282,17 @@ class ArgsManager
     282 |       * Check whether we know of this arg
     283 |       */
     284 |      bool IsArgKnown(const std::string& key, std::string& error);
     285 | +
     286 | +private:
     287 | +    /**
     288 | +     * Trim string by the pattern
     289 | +     */
     290 | +    std::string trimString(std::string str, const std::string& pattern);
    


    qmma70 commented at 6:16 PM on June 16, 2018:

    Is there a reason for this method to start with a lower case letter while all other start with upper case letters?


    ken2812221 commented at 8:50 PM on June 16, 2018:

    No reason. So make it uppercase.

  5. in src/util.cpp:822 in 9b0d45aa74 outdated
     821 | -    {
     822 | -        std::string strKey = std::string("-") + it->string_key;
     823 | -        std::string strValue = it->value[0];
     824 | +    auto options = GetConfigOptions(stream);
     825 | +
     826 | +    for (auto it = options.begin(), end = options.end(); it != end; ++it) {
    


    qmma70 commented at 6:19 PM on June 16, 2018:

    Use cbegin() and cend() please.


    ken2812221 commented at 8:52 PM on June 16, 2018:

    I made it range-based

  6. in src/util.cpp:954 in 9b0d45aa74 outdated
     949 | +            if (*str.begin() == '[' && *str.rbegin() == ']')
     950 | +                prefix = str.substr(1, str.size() - 2) + '.';
     951 | +            else if ((pos = str.find('=')) != std::string::npos) {
     952 | +                std::string name = prefix + trimString(str.substr(0, pos), " \t\r\n");
     953 | +                std::string value = trimString(str.substr(pos + 1), " \t\r\n");
     954 | +                options.push_back(std::pair<std::string, std::string>(name, value));
    


    qmma70 commented at 6:21 PM on June 16, 2018:

    Minor: can use std::make_pair(name, value) for simplicity.


    ken2812221 commented at 8:54 PM on June 16, 2018:

    emplace_back is more simple.

  7. ken2812221 force-pushed on Jun 16, 2018
  8. ken2812221 force-pushed on Jun 16, 2018
  9. qmma70 commented at 9:07 PM on June 16, 2018: contributor

    I'm utAck on this. Nicely done.

    This could have also been implemented with regex, but the pattern is simple enough that the logic is easily understandable.

  10. Empact commented at 9:12 PM on June 17, 2018: member

    Concept ACK - maybe include the tests from #12744?

  11. ken2812221 commented at 1:19 AM on June 18, 2018: contributor

    @Empact Those tests have been added by #12713

  12. ken2812221 commented at 6:05 PM on June 18, 2018: contributor

    Current on master, if there are some options in the config file without =, they would cause an exception. In this PR, I simply ignore them, or should I also throw an exception?

  13. DrahtBot commented at 10:40 PM on June 19, 2018: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->Note to reviewers: This pull request conflicts with the following ones:

    • #13562 (travis: Switch back to trusty for now by MarcoFalke)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  14. DrahtBot cross-referenced this on Jun 19, 2018 from issue gui: Drop qt4 support by laanwj
  15. fanquake added this to the "In progress" column in a project

  16. jezzalladmins changes_requested
  17. jezzalladmins commented at 8:04 AM on June 22, 2018: none

    Run

  18. DrahtBot added the label Needs rebase on Jun 24, 2018
  19. DrahtBot commented at 2:18 PM on June 24, 2018: contributor

    <!--cf906140f33d8803c4a75a2196329ecb-->Needs rebase

  20. MarcoFalke commented at 2:21 PM on June 24, 2018: member

    Update doc/build-unix.md as well?

  21. ken2812221 force-pushed on Jun 25, 2018
  22. ken2812221 force-pushed on Jun 25, 2018
  23. ken2812221 commented at 2:52 AM on June 25, 2018: contributor
  24. DrahtBot removed the label Needs rebase on Jun 25, 2018
  25. in src/util.cpp:940 in 092864dfc7 outdated
     935 | +{
     936 | +    std::vector<std::pair<std::string, std::string>> options;
     937 | +    std::string str, prefix;
     938 | +    std::string::size_type pos;
     939 | +    while (std::getline(stream, str)) {
     940 | +        if ((pos = str.find('#')) != std::string::npos)
    


    sipa commented at 12:25 AM on June 27, 2018:

    Coding style nit: use braces whenever indenting.


    ken2812221 commented at 2:07 AM on June 29, 2018:

    Fixed

  26. in src/util.cpp:949 in 092864dfc7 outdated
     941 | +            str = str.substr(0, pos);
     942 | +        str = TrimString(str, " \t\r\n");
     943 | +        if (!str.empty()) {
     944 | +            if (*str.begin() == '[' && *str.rbegin() == ']')
     945 | +                prefix = str.substr(1, str.size() - 2) + '.';
     946 | +            else if ((pos = str.find('=')) != std::string::npos) {
    


    sipa commented at 12:25 AM on June 27, 2018:

    Same here.


    ken2812221 commented at 2:07 AM on June 29, 2018:

    Fixed

  27. in src/util.cpp:942 in 092864dfc7 outdated
     937 | +    std::string str, prefix;
     938 | +    std::string::size_type pos;
     939 | +    while (std::getline(stream, str)) {
     940 | +        if ((pos = str.find('#')) != std::string::npos)
     941 | +            str = str.substr(0, pos);
     942 | +        str = TrimString(str, " \t\r\n");
    


    sipa commented at 12:27 AM on June 27, 2018:

    Maybe introduce a static constant for this set of trimmable characters?


    ken2812221 commented at 2:07 AM on June 29, 2018:

    I'm not sure this is what you want.

  28. ken2812221 force-pushed on Jun 27, 2018
  29. ken2812221 force-pushed on Jun 27, 2018
  30. ken2812221 force-pushed on Jun 29, 2018
  31. ken2812221 force-pushed on Jun 29, 2018
  32. DrahtBot cross-referenced this on Jun 30, 2018 from issue travis: Switch back to trusty for now by MarcoFalke
  33. in src/util.cpp:925 in 5d7d1a2db8 outdated
     921 | @@ -927,6 +922,40 @@ std::string ArgsManager::GetChainName() const
     922 |      return CBaseChainParams::MAIN;
     923 |  }
     924 |  
     925 | +std::string ArgsManager::TrimString(const std::string& str, const std::string& pattern)
    


    sipa commented at 2:02 AM on July 18, 2018:

    This can just be a static function; it doesn't need to be a method of ArgsManager.

  34. ken2812221 force-pushed on Jul 18, 2018
  35. ken2812221 closed this on Jul 18, 2018

  36. Replace boost program_options 11588c639e
  37. Remove program options from build system f447a0a707
  38. sipa commented at 2:50 AM on July 18, 2018: member

    Why close?

  39. ken2812221 commented at 2:51 AM on July 18, 2018: contributor

    Sorry, misclicked

  40. ken2812221 reopened this on Jul 18, 2018

  41. ken2812221 force-pushed on Jul 18, 2018
  42. fanquake added this to the milestone 0.17.0 on Jul 18, 2018
  43. sipa commented at 9:50 PM on July 19, 2018: member

    utACK f447a0a7079619f0d650084df192781cca9fd826

  44. in build-aux/m4/ax_boost_program_options.m4:1 in f447a0a707
       0 | @@ -1,108 +0,0 @@
       1 | -# ============================================================================
    


    laanwj commented at 2:30 PM on July 20, 2018:

    I like this file-bloodbath.

  45. laanwj commented at 2:40 PM on July 20, 2018: member

    +42 −123 even though this is removing an external dependency, if that isn't a clear indication that this should be done I don't know what is. utACK f447a0a7079619f0d650084df192781cca9fd826

  46. laanwj merged this on Jul 20, 2018
  47. laanwj closed this on Jul 20, 2018

  48. laanwj referenced this in commit 2dc5ab6378 on Jul 20, 2018
  49. ken2812221 deleted the branch on Jul 20, 2018
  50. fanquake moved this from the "In progress" to the "Done" column in a project

  51. Bushstar cross-referenced this on Jul 24, 2018 from issue commits from bitcoin/master by Bushstar
  52. meshcollider cross-referenced this on Oct 16, 2018 from issue Error if # is used in rpcpassword in conf by meshcollider
  53. laanwj referenced this in commit 90c0b6aca2 on Nov 12, 2018
  54. Fuzzbawls cross-referenced this on Apr 27, 2021 from issue [Util] Remove boost program_options dependency by Fuzzbawls
  55. furszy referenced this in commit 4bf92204e4 on Apr 30, 2021
  56. UdjinM6 referenced this in commit 0c5896078f on Jun 29, 2021
  57. UdjinM6 referenced this in commit db8ed9f495 on Jun 29, 2021
  58. UdjinM6 referenced this in commit 63443e26fd on Jul 1, 2021
  59. UdjinM6 referenced this in commit bec6b5e19f on Jul 2, 2021
  60. UdjinM6 referenced this in commit a9fb8a57ab on Jul 2, 2021
  61. knst referenced this in commit e74373879b on Aug 10, 2021
  62. knst referenced this in commit a4062f57d9 on Aug 10, 2021
  63. barton2526 cross-referenced this on Aug 13, 2021 from issue depends: Remove boost::program_options dependency by barton2526
  64. knst referenced this in commit 705d36cd39 on Aug 16, 2021
  65. PastaPastaPasta referenced this in commit 42d1b0ba71 on Aug 23, 2021
  66. christiancfifi referenced this in commit b33ca8474a on Aug 27, 2021
  67. christiancfifi referenced this in commit 74858f06b4 on Aug 27, 2021
  68. christiancfifi referenced this in commit 33876d2450 on Aug 28, 2021
  69. christiancfifi referenced this in commit 1feb306462 on Aug 29, 2021
  70. christiancfifi referenced this in commit bfd9852f90 on Aug 29, 2021
  71. christiancfifi referenced this in commit b9d2e81286 on Aug 29, 2021
  72. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:54 UTC