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

Method QiFuncMap

source/src/scriptinterpreter.cpp:2040–2199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2038 else if (val.type() == QiVar::Type::t_int) output << static_cast<osc::int32>(val.toInteger());
2039 else if (val.type() == QiVar::Type::t_num) output << static_cast<float>(val.toNumber());
2040 else { const std::string str = val.toString(); if (!str.empty()) output << str.c_str(); }
2041 }
2042 output << osc::EndMessage;
2043 socket.Send(output.Data(), output.Size());
2044 return true;
2045 }
2046 catch (...) {}
2047 return false;
2048 }
2049};
2050/*
2051str host
2052int port
2053
2054bool return
2055*/
2056struct OscListen
2057{
2058 static constexpr const char* property_name = "osc_listen";
2059 using Ptr = std::shared_ptr<OscListen>;
2060 class Listener : public osc::OscPacketListener
2061 {
2062 OscListen& listen;
2063 protected:
2064 void ProcessMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) override
2065 {
2066 std::unique_lock<std::mutex> lock(listen.mutex);
2067 auto i = m.ArgumentsBegin();
2068 if (i != m.ArgumentsEnd())
2069 {
2070 QiVar value;
2071 switch (i->TypeTag())
2072 {
2073 case osc::TRUE_TYPE_TAG: value = true; break;
2074 case osc::FALSE_TYPE_TAG: value = false; break;
2075 case osc::INT32_TYPE_TAG: value = i->AsInt32(); break;
2076 case osc::FLOAT_TYPE_TAG: value = i->AsFloat(); break;
2077 case osc::CHAR_TYPE_TAG: value = i->AsChar(); break;
2078 case osc::RGBA_COLOR_TYPE_TAG: i->AsRgbaColor(); break;
2079 case osc::INT64_TYPE_TAG: value = i->AsInt64(); break;
2080 case osc::TIME_TAG_TYPE_TAG: value = i->AsTimeTag(); break;
2081 case osc::DOUBLE_TYPE_TAG: value = i->AsDouble(); break;
2082 case osc::STRING_TYPE_TAG: value = i->AsString(); break;
2083 case osc::SYMBOL_TYPE_TAG: value = i->AsSymbol(); break;
2084 default: return;
2085 }
2086 const std::string key = m.AddressPattern();
2087 auto iter = listen.data.find(key);
2088 if (iter != listen.data.end()) iter->second = value;
2089 else listen.data.insert(std::make_pair(key, value));
2090 }
2091 }
2092 public:
2093 Listener(OscListen& listen) : listen(listen) {}
2094 };
2095
2096 std::unordered_map<std::string, QiVar> data;
2097 std::unique_ptr<Listener> listener;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected