From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mpeglib/example/yaf/yafcore/commandTable.cpp | 256 +++++++++++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 mpeglib/example/yaf/yafcore/commandTable.cpp (limited to 'mpeglib/example/yaf/yafcore/commandTable.cpp') diff --git a/mpeglib/example/yaf/yafcore/commandTable.cpp b/mpeglib/example/yaf/yafcore/commandTable.cpp new file mode 100644 index 00000000..10e36dc3 --- /dev/null +++ b/mpeglib/example/yaf/yafcore/commandTable.cpp @@ -0,0 +1,256 @@ +/* + valid Commands for Input/Output + Copyright (C) 1998 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + + +#include "commandTable.h" +#include + +using namespace std; + + +CommandTable::CommandTable(){ + nCommandDesc=0; +} + +CommandTable::~CommandTable(){ +} + + +const char* CommandTable::getCommand(int nr) { + int i; + const char* back=""; + for(i=0;i nlen) && (name[nlen]==' ')) { + return commandDesc[i].longName; + } + } + + if (strlen(commandDesc[i].shortName) > 0) { + nlen=strlen(commandDesc[i].shortName); + comp=strncmp(commandDesc[i].shortName,name,nlen); + + if (comp == 0) { + if (strlen(name) == nlen) { + return commandDesc[i].shortName; + } else if ((strlen(name) > nlen) && (name[nlen]==' ')) { + return commandDesc[i].shortName; + } + } + } + } + return back; +} + + +int CommandTable::getNr(const char* command) { + int i; + int comp; + int back=-1; + unsigned int nlen; + for(i=0;i nlen) && (command[nlen]==' ')) { + return commandDesc[i].number; + } + } + + if (strlen(commandDesc[i].shortName) > 0) { + nlen=strlen(commandDesc[i].shortName); + comp=strncmp(commandDesc[i].shortName,command,nlen); + + if (comp == 0) { + if (strlen(command) == nlen) { + return commandDesc[i].number; + } else if((strlen(command) > nlen) && (command[nlen]==' ')){ + return commandDesc[i].number; + } + } + } + } + return back; +} + + +const char* CommandTable::getArgs(const char* command,const char* wholeLine) { + unsigned int i; + unsigned int n; + const char* back; + back=wholeLine; + n=strlen(command); + if (n==0) return back; + for(i=0;i n) { + back++; + } + return back; +} + + + +void CommandTable::print() { + int i; + cout << "internal Help System V. 0.2\n"; + cout << "known commands are :\n\n"; + for(i=0;igetCommandCounter(); + CommandDescription* cmdDesc; + + for (i=0;igetCommandDescription(i); + insert(cmdDesc); + + } + +} + + + + + + + +void CommandTable::insert(CommandDescription* cmdDesc) { + const char* lNameTest; + const char* sNameTest; + int pos=getPos(cmdDesc->number); + + if (pos != -1) { + cout << "number "<< cmdDesc->number + << " for command "<< cmdDesc->longName << " already defined!" << endl; + } + + lNameTest=getCommand(cmdDesc->longName); + if (strlen(lNameTest) > 0) { + cout << "longName "<< cmdDesc->longName << " already defined." + << "Previous definition has number : " + << getNr(cmdDesc->longName) << endl; + } + + sNameTest=getCommand(cmdDesc->shortName); + if (strlen(sNameTest) > 0) { + cout << "shortName "<< cmdDesc->shortName << " already defined." + << "Previous definition has number : " + << getNr(cmdDesc->shortName) << endl; + + } + + + commandDesc[nCommandDesc].lexternalUse=cmdDesc->lexternalUse; + commandDesc[nCommandDesc].lReturn=cmdDesc->lReturn; + commandDesc[nCommandDesc].longName=cmdDesc->longName; + commandDesc[nCommandDesc].shortName=cmdDesc->shortName; + commandDesc[nCommandDesc].number=cmdDesc->number; + commandDesc[nCommandDesc].help=cmdDesc->help; + nCommandDesc++; +} + + +int CommandTable::getReturnFlag(int cmdNr) { + int i=getPos(cmdNr); + CommandDescription* cmdDesc; + if (i == -1) { + return -1; + } + cmdDesc=getCommandDescription(i); + return cmdDesc->lReturn; +} + + + + + + + + + + -- cgit v1.2.1