23 #include <QLatin1Char> 24 #include <QLatin1String> 27 #include <KLocalizedString> 41 #define MAX_LINE_LEN 16384 43 //*************************************************************************** 75 if (
m_source.device()) qWarning(
"AsciiDecoder::open(), already open !");
78 if (!src.open(QIODevice::ReadOnly)) {
79 qWarning(
"failed to open source !");
90 qDebug(
"--- AsciiDecoder::open() ---");
93 qDebug(
"AsciiDecoder::open(...)");
105 "\\s*(\\w+[\\s\\w]*\\w)\\s*" 111 if (regex.exactMatch(line)) {
114 QString v = regex.cap(7);
119 bool is_escaped =
false;
120 char quote = v[0].toLatin1();
121 if ((quote !=
'\'') && (quote !=
'"'))
124 for (QString::ConstIterator it = v.begin(); it != v.end(); ++it)
126 const char c = QChar(*it).toLatin1();
128 if ((c ==
'\\') && !is_escaped) {
145 if ((quote == -1) && (c ==
'#'))
154 value = value.trimmed();
162 QRegExp regex_label(
_(
"label\\[(\\d*)\\]"));
163 if (regex_label.exactMatch(name)) {
167 qWarning(
"line %llu: malformed label position: '%s'",
172 labels.append(label);
178 if (info.
name(p).toLower() == name.toLower()) {
180 info.
set(p, QVariant(value));
184 qWarning(
"line %llu: unknown meta data entry: '%s' = '%s'",
187 }
else if (line.startsWith(QLatin1Char(
'#'))) {
209 return (info.
tracks() >= 1);
221 if (!line.length()) {
223 }
else if (line.startsWith(QLatin1Char(
'#'))) {
241 if (!
m_source.device())
return false;
246 const char separators[] = {
',',
'\0' };
249 unsigned int channels = info.
tracks();
250 QVector<sample_t> frame(channels);
253 qDebug(
"AsciiDecoder::decode(...)");
256 char *line = d.data();
257 char *saveptr = Q_NULLPTR;
260 for (
unsigned int channel = 0; channel < channels; channel++) {
263 char *token = strtok_r(line, separators, &saveptr);
267 while (*token && isspace(*token)) ++token;
270 while (isdigit(*p) || (*p ==
'+') || (*p ==
'-')) ++p;
272 if (*token) s = atoi(token);
bool contains(const FileProperty property) const
virtual bool decode(QWidget *widget, Kwave::MultiWriter &dst) Q_DECL_OVERRIDE
QString name(FileProperty key) const
QVariant get(FileProperty key) const
virtual ~AsciiDecoder() Q_DECL_OVERRIDE
void set(FileProperty key, const QVariant &value)
virtual sample_index_t last() const
virtual void close() Q_DECL_OVERRIDE
static QString unescape(const QString &text)
QList< FileProperty > allKnownProperties() const
void setLength(sample_index_t length)
QQueue< QString > m_queue_input
virtual bool open(QWidget *widget, QIODevice &source) Q_DECL_OVERRIDE
virtual Kwave::MetaDataList & metaData()
Kwave::MetaDataList toMetaDataList() const
unsigned int tracks() const
Kwave::MultiWriter * m_dest
#define REGISTER_COMPRESSION_TYPES
virtual Kwave::Decoder * instance() Q_DECL_OVERRIDE