KDevelop API Documentation

cvsentry.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Mario Scalas                                    *
00003  *   mario.scalas@libero.it                                                *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00012 #include <qfile.h>
00013 #include <qtextstream.h>
00014 
00015 #include "cvsentry.h"
00016 
00018 // Static
00020 
00021 const QString CVSEntry::invalidMarker = "<Invalid entry>";
00022 const QString CVSEntry::directoryMarker = "D";
00023 const QString CVSEntry::fileMarker = "";
00024 const QString CVSEntry::entrySeparator = "/";
00025 
00027 // class CVSEntry
00029 
00030 CVSEntry::CVSEntry()
00031 {
00032     clean();
00033 }
00034 
00036 
00037 CVSEntry::CVSEntry( const QString &aLine )
00038 {
00039     parse( aLine, *this );
00040 }
00041 
00043 
00044 void CVSEntry::clean()
00045 {
00046     m_type = invalidEntry;
00047 }
00048 
00050 
00051 CVSEntry::EntryType CVSEntry::type() const
00052 {
00053     return m_type;
00054 }
00055 
00057 
00058 void CVSEntry::parse( const QString &aLine, CVSEntry &entry )
00059 {
00060     entry.clean();
00061 
00062     entry.m_fields = QStringList::split( "/", aLine );
00063 
00064     if (aLine.startsWith( entrySeparator )) // Is a file?
00065     {
00066         entry.m_type = fileEntry; // Is a file
00067     }
00068     else if (aLine.startsWith( directoryMarker )) // Must be a directory then
00069     {
00070         entry.m_type = directoryEntry; // Is a directory
00071         entry.m_fields.pop_front(); // QStringList::split() fills and empty item in head
00072     }
00073     else // What the hell is this? >:-)
00074     {
00075         entry.m_type = invalidEntry;
00076     }
00077 }
00078 
00080 
00081 QString CVSEntry::fileName() const
00082 {
00083     if (type() != invalidEntry && m_fields.count() >= 1)
00084         return m_fields[0];
00085     else
00086         return QString::null;
00087 }
00088 
00090 
00091 QString CVSEntry::revision() const
00092 {
00093     if (type() != invalidEntry && m_fields.count() >= 2)
00094         return m_fields[1];
00095     else
00096         return QString::null;
00097 }
00098 
00100 
00101 QString CVSEntry::timeStamp() const
00102 {
00103     if (type() != invalidEntry && m_fields.count() >= 3)
00104         return m_fields[2];
00105     else
00106         return QString::null;
00107 }
00108 
00110 
00111 QString CVSEntry::options() const
00112 {
00113     if (type() != invalidEntry && m_fields.count() >= 4)
00114         return m_fields[3];
00115     else
00116         return QString::null;
00117 }
00118 
00120 
00121 QString CVSEntry::tag() const
00122 {
00123     if (type() != invalidEntry && m_fields.count() >= 5)
00124         return m_fields[4];
00125     else
00126         return QString::null;
00127 }
00128 
00130 
00131 VCSFileInfo CVSEntry::toVCSFileInfo() const
00132 {
00133     VCSFileInfo::FileState fileState = VCSFileInfo::Unknown;
00134     if (isDirectory())
00135         fileState = VCSFileInfo::Directory;
00136 
00137     return VCSFileInfo( fileName(), revision(), QString::null, fileState );
00138 }
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:59 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003