nasa / fprime

F´ - A flight software and embedded systems framework
https://fprime.jpl.nasa.gov
Apache License 2.0
9.95k stars 1.28k forks source link

Add Fw::ExternalString and revise string implementations #2679

Closed bocchino closed 2 months ago

bocchino commented 2 months ago

This PR does the following:

  1. Add a new class Fw::ExternalString. This class is derived from Fw::StringBase. It uses an externally supplied character buffer to implement a string. I added tests for Fw::ExternalString to the Fw/Types unit tests.
  2. Refactor the string implementations in the framework to reduce code duplication.

Rationale:

  1. Fw::ExternalString is needed to improve the C++ code generation strategy for strings. See fprime-community/fpp#406.
  2. The refactored implementation eliminates a significant amount of copy-paste code when creating a new concrete string type. The new version should be functionally identical to the old version.

Notes:

  1. Review and merge #2677 first. A lot of changes in this PR are formatting changes that will go away once #2677 is merged.
  2. Static analysis is telling us that single-argument constructors should be marked explicit. When I tried this, I saw compilation errors in the generated C++. I think this issue will have to be addressed separately.
bocchino commented 2 months ago

Converting this PR to draft because I need to do some refactoring.