KCDDB

lookup.cpp
1 /*
2  SPDX-FileCopyrightText: 2002 Rik Hemsley (rikkus) <[email protected]>
3  SPDX-FileCopyrightText: 2002 Benjamin Meyer <[email protected]>
4  SPDX-FileCopyrightText: 2002 Nadeem Hasan <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "lookup.h"
10 
11 #include <QDebug>
12 
13 namespace KCDDB
14 {
15  Lookup::Lookup()
16  : CDDB()
17  {
18  }
19 
20  Lookup::~Lookup()
21  {
22  // Empty.
23  }
24 
25  Result
26  Lookup::parseQuery( const QString & line )
27  {
28  uint serverStatus = statusCode( line );
29 
30  if ( 200 == serverStatus )
31  {
32 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
33  QStringList tokenList = line.split( QLatin1Char( ' ' ), QString::SkipEmptyParts );
34 #else
35  QStringList tokenList = line.split( QLatin1Char( ' ' ), Qt::SkipEmptyParts );
36 #endif
37  matchList_.append( qMakePair( tokenList[ 1 ], tokenList[ 2 ] ) );
38  return Success;
39  }
40  else if ( ( 211 == serverStatus ) || ( 210 == serverStatus ) )
41  {
42  return MultipleRecordFound;
43  }
44  else if ( 202 == serverStatus )
45  {
46  return NoRecordFound;
47  }
48 
49  return ServerError;
50  }
51 
52  void
53  Lookup::parseExtraMatch( const QString & line )
54  {
55 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
56  QStringList tokenList = line.split( QLatin1Char( ' ' ), QString::SkipEmptyParts );
57 #else
58  QStringList tokenList = line.split( QLatin1Char( ' ' ), Qt::SkipEmptyParts );
59 #endif
60  matchList_.append( qMakePair( tokenList[ 0 ], tokenList[ 1 ] ) );
61  }
62 
63  Result
64  Lookup::parseRead( const QString & line )
65  {
66  uint serverStatus = statusCode( line );
67 
68  if ( 210 != serverStatus )
69  return ServerError;
70 
71  return Success;
72  }
73 
74  CDInfoList
75  Lookup::lookupResponse() const
76  {
77  return cdInfoList_;
78  }
79 
80 }
81 
82 // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1
void append(const T &value)
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
SkipEmptyParts
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:22:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.