/// <summary> /// Returns the argument type at index. /// </summary> public bool TryGetArgType(int index, out OscArgType type) { if (index < 0 || index >= _argInfo.Count) { type = OscArgType.Unsupported; return(false); } type = OscConverter.ToArgType(_argInfo[index].tagByte); return(true); }
bool ValidateTryGet(int index, OscArgType requestedType) { // Arg bounds. if (index < 0 || index >= _argInfo.Count) { StringBuilder sb = StartBuildingInvalidTryGetString(OscDebug.BuildText(this)); sb.Append("Requested argument index "); sb.Append(index); sb.Append(" is out of bounds. Message has "); sb.Append(_argInfo.Count); sb.Append(" arguments.\n"); Debug.LogWarning(sb.ToString()); return(false); } // Arg type. OscArgInfo info = _argInfo[index]; OscArgType type = OscConverter.ToArgType(info.tagByte); if (requestedType != type) { StringBuilder sb = StartBuildingInvalidTryGetString(OscDebug.BuildText(this)); sb.Append("Argument at index "); sb.Append(index); sb.Append(" is not type "); sb.Append(requestedType); sb.Append(" ('"); sb.Append((char)OscConverter.ToTagByte(requestedType)); sb.Append("')"); sb.Append(", it is "); sb.Append(type); sb.Append(" ('"); sb.Append((char)info.tagByte); sb.Append("').\n"); Debug.LogWarning(sb.ToString()); return(false); } // Data capacity. if (index + info.size > _argData.Count) { StringBuilder sb = StartBuildingInvalidTryGetString(OscDebug.BuildText(this)); sb.Append("Argument at index "); sb.Append(index); sb.Append(" has incomplete data\n"); Debug.LogWarning(sb.ToString()); return(false); } return(true); }