Skip to content

Comments

feat(bindings/cpp): adopt Google C++ Style Guide for API naming#6448

Merged
Xuanwo merged 2 commits intoapache:mainfrom
JackDrogon:feature/cpp_to_google_style
Jul 30, 2025
Merged

feat(bindings/cpp): adopt Google C++ Style Guide for API naming#6448
Xuanwo merged 2 commits intoapache:mainfrom
JackDrogon:feature/cpp_to_google_style

Conversation

@JackDrogon
Copy link
Contributor

Adopt Google C++ Style Guide for API naming

  • Rename public methods from snake_case to PascalCase
    • available() -> Available()
    • read() -> Read()
    • write() -> Write()
    • exists() -> Exists()
    • create_dir() -> CreateDir()
    • reader() -> GetReader()
    • lister() -> GetLister()
    • And all corresponding method implementations
  • Update documentation and comments to reference new API names
  • Add Google C++ Style Guide compliance notes to README and CONTRIBUTING
  • Update all test files and examples to use new API conventions
  • Preserve standard library virtual function names (underflow, uflow)
  • remove Get prefix from simple accessor methods
    • GetContentLength() -> ContentLength()
    • GetCacheControl() -> CacheControl()
    • GetContentDisposition() -> ContentDisposition()
    • GetContentMd5() -> ContentMd5()
    • GetContentType() -> ContentType()
    • GetContentEncoding() -> ContentEncoding()
    • GetEtag() -> Etag()
    • GetLastModified() -> LastModified()
    • GetVersion() -> Version()
    • GetIsCurrent() -> IsCurrent()
    • GetIsDeleted() -> IsDeleted()

This change improves code consistency and follows industry standard
C++ naming conventions while maintaining full backward compatibility
for existing functionality.

- Rename public methods from snake_case to PascalCase
  - available() -> Available()
  - read() -> Read()
  - write() -> Write()
  - exists() -> Exists()
  - create_dir() -> CreateDir()
  - reader() -> GetReader()
  - lister() -> GetLister()
  - And all corresponding method implementations

- Update documentation and comments to reference new API names
- Add Google C++ Style Guide compliance notes to README and CONTRIBUTING
- Update all test files and examples to use new API conventions
- Preserve standard library virtual function names (underflow, uflow)

This change improves code consistency and follows industry standard
C++ naming conventions while maintaining full backward compatibility
for existing functionality.

Signed-off-by: Jack Drogon <[email protected]>
Follow Google C++ Style Guide by removing Get prefix from simple
getter functions that directly return member variables:

- GetContentLength() -> ContentLength()
- GetCacheControl() -> CacheControl()
- GetContentDisposition() -> ContentDisposition()
- GetContentMd5() -> ContentMd5()
- GetContentType() -> ContentType()
- GetContentEncoding() -> ContentEncoding()
- GetEtag() -> Etag()
- GetLastModified() -> LastModified()
- GetVersion() -> Version()
- GetIsCurrent() -> IsCurrent()
- GetIsDeleted() -> IsDeleted()

Update all test files and documentation to use the new naming
conventions. This change aligns with Google's recommendation that
simple accessors should not have Get prefixes.

Signed-off-by: Jack Drogon <[email protected]>
@JackDrogon JackDrogon requested a review from Xuanwo as a code owner July 29, 2025 13:13
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jul 29, 2025
@JackDrogon
Copy link
Contributor Author

@Xuanwo @deadlinefen need a code review

@dosubot dosubot bot added the releases-note/feat The PR implements a new feature or has a title that begins with "feat" label Jul 29, 2025
@Xuanwo
Copy link
Member

Xuanwo commented Jul 29, 2025

Is there a way to enforce a coding style? I don't want to worry about this during future reviews.

@JackDrogon
Copy link
Contributor Author

JackDrogon commented Jul 30, 2025

Is there a way to enforce a coding style? I don't want to worry about this during future reviews.

Use clang-format to format code and use clang-tidy to check code. Something else, we also need reviewer to guarantee.

@Xuanwo
Copy link
Member

Xuanwo commented Jul 30, 2025

Use clang-format to format code and use clang-tidy to check code.

Would you like to add them in CI in the following PRs? Other looks good to me.

@Xuanwo Xuanwo merged commit 8d1ec03 into apache:main Jul 30, 2025
32 checks passed
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants