MCPcopy Create free account
hub / github.com/ChiyukiGana/Quickinput / interpretAll

Method interpretAll

source/src/scriptinterpreter.h:868–929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

866 }
867 }
868 void interpretAll(const std::string& code, QiVarMap* local = nullptr)
869 {
870 if (code.empty()) return;
871
872 std::vector<std::string> rawLines;
873 std::istringstream codeStream(code);
874 std::string rawLine;
875 while (std::getline(codeStream, rawLine)) rawLines.push_back(rawLine);
876
877 std::vector<std::string> lines;
878 for (const auto& rawLine : rawLines) {
879 std::string line = rawLine;
880 bool in_string = false;
881 bool escape_next = false;
882
883 for (size_t i = 0; i < line.length(); i++) {
884 char c = line[i];
885 if (in_string) {
886 if (escape_next) {
887 escape_next = false;
888 }
889 else {
890 if (c == '\\') {
891 escape_next = true;
892 }
893 else if (c == '\'') {
894 in_string = false;
895 }
896 }
897 }
898 else {
899 if (c == '\'') {
900 in_string = true;
901 }
902 else if (c == '#') {
903 line = line.substr(0, i);
904 break;
905 }
906 }
907 }
908
909 if (!line.empty()) {
910 std::vector<std::string> statements;
911 size_t start = 0;
912 size_t end = line.find(';');
913 while (end != std::string::npos) {
914 std::string stmt = trim(line.substr(start, end - start));
915 if (!stmt.empty()) {
916 statements.push_back(stmt);
917 }
918 start = end + 1;
919 end = line.find(';', start);
920 }
921 std::string lastStmt = trim(line.substr(start));
922 if (!lastStmt.empty()) statements.push_back(lastStmt);
923
924 for (const auto& stmt : statements) lines.push_back(stmt);
925 }

Callers 3

ActionInterpreterMethod · 0.80
runMethod · 0.80
Event_Action_WidgetMethod · 0.80

Calls 2

trimFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected