Funktionen | |
static OutDevice * | GetOut (int nr) |
static RouteType | Str2RT (mutChar *type) |
parse a string representation of a route type | |
static DevType | Str2DT (const mutStringRef type) |
static bool | GetLine (const mutStringRef p, size_t &i, mutStringRef s) |
void | LoadRoutes (const mutStringRef) |
load the routes from a text string | |
void | SaveRoutes (mutStringRef) |
write the routes to the given string |
static bool compat30::GetLine | ( | const mutStringRef | p, |
size_t & | i, | ||
mutStringRef | s | ||
) | [static] |
Definiert in Zeile 91 der Datei RouteCompat.cpp.
{ size_t l = p.Length(); start: if ( i >= l ) return false; while ( i < l && wxString(_T(" \t\n\r")).Find(p.GetChar(i)) != -1 ) i++; if ( i >= l ) return false; size_t i1 = i; int i2 = p.find(_T("\n"), i1); if ( i2 == -1 ) { i = l; s = p.Mid(i1); } else { s = p.Mid(i1, i2-i1); i = (size_t) i2; } s = s.Trim(); if ( s.Length() == 0 || s.StartsWith(_T("#")) ) goto start; return true; }
static OutDevice* compat30::GetOut | ( | int | nr | ) | [static] |
Definiert in Zeile 43 der Datei RouteCompat.cpp.
Benutzt OutDevice::GetDevice().
Wird benutzt von LoadRoutes().
{ if ( nr < 0 ) return 0; OutDevice *Out = OutDevice::GetDevice(nr); return Out; }
void compat30::LoadRoutes | ( | const mutStringRef | ) |
load the routes from a text string
config | string to be read from |
Definiert in Zeile 119 der Datei RouteCompat.cpp.
Benutzt InDevice::AddRoute(), InDevice::CreateDevice(), OutDevice::CreateDevice(), DEBUGLOG2, DTGis, DTMidiFile, DTMidiPort, DTUnknown, OutDevice::GetDeviceList(), InDevice::GetDeviceList(), GETLINE, GetOut(), Route::GetRouteList(), OutDevice::InitializeIds(), muT, mutChar, SSCANF, Str2DT(), Str2RT() und UNREACHABLE.
{ bool error = false; DEBUGLOG2(routing,_T("")); InDevice * InDevices = InDevice::GetDeviceList(); OutDevice * OutDevices = OutDevice::GetDeviceList(); // emty lists if ( InDevices) { delete InDevices; InDevices = NULL; } if ( OutDevices ) { delete OutDevices; OutDevices = NULL; } while (Route * routes = Route::GetRouteList()) delete routes; // Zerlegen von config wxString s; size_t i = 0; GETLINE; DEBUGLOG2(routing,_T("+%s"),s.c_str()); while ( !s.StartsWith(_T("OUTPUT")) ) { GETLINE; DEBUGLOG2(other,_T("+%s"),s.c_str()); } GETLINE; DEBUGLOG2(routing,_T("+%s"),s.c_str()); // Output lesen while ( !s.StartsWith(_T("INPUT")) ) { mutChar Type[80], Name[400]; int DevId, BendingRange; DEBUGLOG2(routing,_T("a%s"),s.c_str()); #if (wxUSE_UNICODE || wxUSE_WCHAR_T) int test = SSCANF(s.c_str(), _T("%ls \"%l[^\"]\" %d %d"), Type, Name, &DevId, &BendingRange); if ( test < 2 ) test = SSCANF(s.c_str(), _T("%ls %ls %d %d"), Type, Name, &DevId, &BendingRange); if ( test < 3 ) { error = true; } #else int test = SSCANF(s.c_str(), _T("%s \"%[^\"]\" %d %d"), Type, Name, &DevId, &BendingRange); if ( test < 2 ) test = SSCANF(s.c_str(), _T("%s %s %d %d"), Type, Name, &DevId, &BendingRange); if ( test < 3 ) { error = true; } #endif DEBUGLOG2(routing,_T("%d parameters read: Type = '%s', Name = '%s', devid = %d, bendingrange = %d"),test,Type,Name,DevId,BendingRange); DEBUGLOG2(routing,_T("Name = '%s'"),(wxString(Name).c_str())); OutDevice *Out = OutDevice::CreateDevice(Str2DT(muT(Type)), Name, DevId); switch (Str2DT(muT(Type))) { case DTMidiPort: if (test < 4) error = true; else { OutMidiPort * dev = dynamic_cast<OutMidiPort *>(Out); if (!dev) UNREACHABLE; else dev -> SetBendingRange (BendingRange); } break; case DTMidiFile: if (test < 4) error = true; else { OutMidiFile * dev = dynamic_cast<OutMidiFile *>(Out); if (!dev) UNREACHABLE; else dev -> SetBendingRange (BendingRange); } break; case DTUnknown: case DTGis: default: if (test >= 4) error = true; } GETLINE; DEBUGLOG2(other,_T("+%s"),s.c_str()); } OutDevice::InitializeIds(); GETLINE; DEBUGLOG2(routing,_T("+%s"),s.c_str()); // Input lesen while ( 1 ) { // Device lesen mutChar Type[40], Name[400]; //wxString Type, Name; int DevId = -1; #if (wxUSE_UNICODE || wxUSE_WCHAR_T) int test = SSCANF(s, _T("%ls \"%l[^\"]\" %d"), Type, Name, &DevId); if ( test < 2 ) test = SSCANF(s, _T("%ls %ls %d"), Type, Name, &DevId); if ( test < 3 ) { error = 1; } #else int test = SSCANF(s, _T("%s \"%[^\"]\" %d"), Type, Name, &DevId); if ( test < 2 ) test = SSCANF(s, _T("%s %s %d"), Type, Name, &DevId); if ( test < 3 ) { error = 1; } #endif DEBUGLOG2(routing,_T("%d input parameters read: Type = '%s', Name = '%s', DevId = %d"), test, Type, Name, DevId); InDevice *In = InDevice::CreateDevice(Str2DT(muT(Type)), Name, DevId); GETLINE; DEBUGLOG2(routing,_T("+%s"),s.c_str()); // Routen lesen while ( Str2DT(s) == DTUnknown ) { // Route lesen mutChar Type[40]; int IFrom = 0, ITo = 0, Box = 0, BoxActive = 0, OutDev = -1, OFrom = -1, OTo = -1, ONoDrum = 1; #if (wxUSE_UNICODE || wxUSE_WCHAR_T) test = SSCANF(s.c_str(), _T("%ls %d %d %d %d %d %d %d %d"), Type, &IFrom, &ITo, &Box, &BoxActive, &OutDev, &OFrom, &OTo, &ONoDrum); if ( test < 9 ) { error = true; } #else test = SSCANF(s.c_str(), _T("%s %d %d %d %d %d %d %d %d"), Type, &IFrom, &ITo, &Box, &BoxActive, &OutDev, &OFrom, &OTo, &ONoDrum); if ( test < 9 ) { error = true; } #endif DEBUGLOG2(routing,_T("%d parameters read: Type = '%s', IFrom = %d, ITo = %d"),test, Type, IFrom, ITo); DEBUGLOG2(routing,_T(" Box = %d, BoxActive= %d, OutDev = %d, OFrom = %d, OTo = %d, ONoDrum = %d"), Box, BoxActive, OutDev, OFrom, OTo, ONoDrum); In->AddRoute(new Route(In,GetOut(OutDev), Str2RT(Type), IFrom, ITo, Box, BoxActive, OFrom, OTo, ONoDrum)); GETLINE; DEBUGLOG2(routing,_T("+%s"),s.c_str()); } } }
static DevType compat30::Str2DT | ( | const mutStringRef | type | ) | [static] |
static RouteType compat30::Str2RT | ( | mutChar * | type | ) | [static] |
parse a string representation of a route type
This function returns the numeric route type to a string representation
type | String (array of mutChar ) |
Definiert in Zeile 57 der Datei RouteCompat.cpp.
Benutzt RTName.
Wird benutzt von LoadRoutes().