Commit 4c906ee3 authored by Yoann Peronneau's avatar Yoann Peronneau

* add a function to parse the mrl line

parent 885113ae
/***************************************************************************** /*****************************************************************************
* open.cpp : Advanced open dialog * open.cpp : Advanced open dialog
**************************************************************************** *****************************************************************************
* Copyright (C) 2006 the VideoLAN team * Copyright (C) 2006 the VideoLAN team
* $Id: streaminfo.cpp 16816 2006-09-23 20:56:52Z jb $ * $Id: streaminfo.cpp 16816 2006-09-23 20:56:52Z jb $
* *
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QTabWidget> #include <QTabWidget>
#include <QGridLayout> #include <QGridLayout>
...@@ -205,3 +206,51 @@ void OpenDialog::newMethod(QString method) ...@@ -205,3 +206,51 @@ void OpenDialog::newMethod(QString method)
ui.cacheSpinBox->setValue(i_value); ui.cacheSpinBox->setValue(i_value);
} }
} }
QStringList SeparateEntries( QString entries )
{
bool b_quotes_mode = false;
QStringList entries_array;
QString entry;
int index = 0;
while( index < entries.size() )
{
int delim_pos = entries.indexOf( QRegExp( "\\s+" ), index );
if( delim_pos < 0 ) delim_pos = entries.size() - 1;
entry += entries.mid( index, delim_pos );
index = delim_pos + 1;
if( entry.isEmpty() ) continue;
if( !b_quotes_mode && entry.endsWith( "\"" ) )
{
/* Enters quotes mode */
entry.truncate( entry.size() - 1 );
b_quotes_mode = true;
}
else if( b_quotes_mode && entry.endsWith( "\"" ) )
{
/* Finished the quotes mode */
entry.truncate( entry.size() - 1 );
b_quotes_mode = false;
}
else if( !b_quotes_mode && !entry.endsWith( "\"" ) )
{
/* we found a non-quoted standalone string */
if( index < entries.size() ||
entry.endsWith( " " ) || entry.endsWith( "\t" ) ||
entry.endsWith( "\r" ) || entry.endsWith( "\n" ) )
entry.truncate( entry.size() - 1 );
if( !entry.isEmpty() ) entries_array.append( entry );
entry = "";
}
else
{;}
}
if( !entry.isEmpty() ) entries_array.append( entry );
return entries_array;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment