https://github.com/funatsufumiya/ofxabseil
abseil for openFrameworks
https://github.com/funatsufumiya/ofxabseil
openframeworks-addon
Last synced: about 1 year ago
JSON representation
abseil for openFrameworks
- Host: GitHub
- URL: https://github.com/funatsufumiya/ofxabseil
- Owner: funatsufumiya
- License: other
- Created: 2024-11-01T05:37:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-02T02:48:28.000Z (over 1 year ago)
- Last Synced: 2025-03-25T05:06:26.885Z (about 1 year ago)
- Topics: openframeworks-addon
- Language: C++
- Homepage:
- Size: 1.96 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ofxAbseil
[abseil-cpp](https://github.com/abseil/abseil-cpp) for openFrameworks (tested on v0.12.0 Win/Mac/Linux/iOS, abseil version: `lts_2024_07_22`)
## Notes
- Some Windows workaround fixes (e.g. fix min/max problem, disable RawLog, etc) are applied.
- `*_test.cc`, `*_benchmark.cc`, and related files are not included in this addon.
- Already includes `gmock` and `gtest` from [googletest](https://github.com/google/googletest/) as dependencies.
## Usage
See [example](example). (NOTE: Please use `projectGenerator` before run it)
```cpp
#include "absl/strings/str_join.h"
#include "absl/types/optional.h"
#include "absl/hash/hash.h"
#include "absl/container/flat_hash_map.h"
#include "absl/types/any.h"
void ofApp::setup(){
ofLogToConsole();
// test of absl str_join
std::vector v = {"foo", "bar", "baz"};
std::string s = absl::StrJoin(v, "-");
ofLogNotice("ofApp") << "absl::StrJoin(v, \"-\") = " << s;
// test of absl optional
absl::optional o1 = 42;
absl::optional o2 = absl::nullopt;
ofLogNotice("ofApp") << "absl::optional: o1 = " << o1.value_or(0);
ofLogNotice("ofApp") << "absl::optional: o2 = " << o2.value_or(0);
// test of absl hash
absl::Hash hasher;
std::string str = "hello";
size_t hash = hasher(str);
ofLogNotice("ofApp") << "absl::Hash: hash = " << hash;
// test of hash map of any type
absl::flat_hash_map map;
map["int"] = 42;
map["string"] = std::string("hello");
ofLogNotice("ofApp") << "absl::flat_hash_map: map[\"int\"] = " << absl::any_cast(map["int"]);
ofLogNotice("ofApp") << "absl::flat_hash_map: map[\"string\"] = " << absl::any_cast(map["string"]);
}
// Result:
// [notice ] ofApp: absl::StrJoin(v, "-") = foo-bar-baz
// [notice ] ofApp: absl::optional: o1 = 42
// [notice ] ofApp: absl::optional: o2 = 0
// [notice ] ofApp: absl::Hash: hash = 8734633936850012531
// [notice ] ofApp: absl::flat_hash_map: map["int"] = 42
// [notice ] ofApp: absl::flat_hash_map: map["string"] = hello
```
## LICENSE
- abseil: [Apache License 2.0](https://github.com/abseil/abseil-cpp/blob/master/LICENSE)
- googletest: [BSD-3-Clause license](https://github.com/google/googletest/blob/main/LICENSE)
NOTE: No specific copyright is claimed for this repository changes (for oF binding), but the [Apache License 2.0](LICENSE_APACHE) or [MIT License](LICENSE_MIT) can be applied if necessary.
## Side notes
- If you would like to use `std::ranges` alternative (not included in abseil), use [ofxRangeV3](https://github.com/funatsufumiya/ofxRangeV3)