- Three source trees: core/ (shared C++ engine, moved from ios/core), app/ (Android UI), ios/app/ (iOS UI) - Android plays through core/ via JNI (EngineHost, jni_engine.cpp): the Oboe callback renders natively; the Kotlin model is mirrored as project text and applied as a diff, so playback continues through edits - The Kotlin engine moves to the unit tests as ReferenceEngine (golden reference) - Shared MasterRecorder in core/src/host, used by both apps; host_test - versions.properties: one versionName/versionCode for both platforms, continuing Android's numbering (iOS 0.6.0/11 -> 0.37.0/71) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.3 KiB
C++
56 lines
2.3 KiB
C++
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
#pragma once
|
|
|
|
// Kotlin/JVM string semantics the file formats rely on, for UTF-8 text: lines
|
|
// (lineSequence), trim (Char.isWhitespace), split (keeps empty parts), lengths and
|
|
// indices in UTF-16 units (String.length, forEachIndexed), toIntOrNull (Unicode
|
|
// decimal digits, as Character.digit) and toFloatOrNull (Java's Float.parseFloat
|
|
// grammar). Malformed UTF-8 bytes are kept as they are and count as one unit each.
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace sizzle::io::kt {
|
|
|
|
/** One code point at s[i], advancing i; malformed bytes come back one at a time. */
|
|
unsigned decodeUtf8(const std::string &s, size_t &i);
|
|
/** Kotlin's Char.isWhitespace (Character.isWhitespace || isSpaceChar), BMP. */
|
|
bool isWhitespace(unsigned cp);
|
|
/** Character.isDigit's decimal value of [cp] (0..9), or -1. */
|
|
int decimalDigit(unsigned cp);
|
|
|
|
/** text.lineSequence(): split on CRLF, LF and CR. */
|
|
std::vector<std::string> lines(const std::string &text);
|
|
/** String.trim(). */
|
|
std::string trim(const std::string &s);
|
|
/** String.split(c): every part, empty ones included. */
|
|
std::vector<std::string> split(const std::string &s, char c);
|
|
/** String.length (UTF-16 units). */
|
|
size_t utf16Length(const std::string &s);
|
|
/** The code points of [s] with their UTF-16 index (as forEachIndexed sees them). */
|
|
template <typename F> void forEachIndexed(const std::string &s, F f) {
|
|
size_t i = 0, idx = 0;
|
|
while (i < s.size()) {
|
|
unsigned cp = decodeUtf8(s, i);
|
|
f(idx, cp);
|
|
idx += cp >= 0x10000 ? 2 : 1;
|
|
}
|
|
}
|
|
|
|
bool startsWith(const std::string &s, const char *prefix);
|
|
/** String.toIntOrNull(radix). */
|
|
bool toIntOrNull(const std::string &s, int &out, int radix = 10);
|
|
/** String.toFloatOrNull(). */
|
|
bool toFloatOrNull(const std::string &s, float &out);
|
|
/** Float.toInt(): NaN -> 0, saturating. */
|
|
int floatToInt(float v);
|
|
/** Integer.toString(v, 16), upper-cased. */
|
|
std::string hexUpper(int v);
|
|
/** padStart(n, '0'). */
|
|
std::string padStart(const std::string &s, size_t n, char c = '0');
|
|
/** replace(from, to) on every non-overlapping occurrence, left to right. */
|
|
std::string replaceAll(const std::string &s, const std::string &from, const std::string &to);
|
|
|
|
} // namespace sizzle::io::kt
|