// CvsRoot.cs
// Copyright (C) 2001 Mike Krueger
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a special exception, if you link this library with other files to
// produce an executable, this library does not by itself cause the
// resulting executable to be covered by the GNU General Public License.
// This exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
using System;
namespace CVS.Misc{
public class CvsRoot
{
string protocol = "";
string user = "";
string host = "";
string cvsrepository = "";
public string Protocol {
get {
return protocol;
}
set {
protocol = value;
}
}
public string User {
get {
return user;
}
set {
user = value;
}
}
public string Host {
get {
return host;
}
set {
host = value;
}
}
public string CvsRepository {
get {
return cvsrepository;
}
set {
cvsrepository = value;
}
}
public CvsRoot(string cvsroot)
{
int s1 = cvsroot.IndexOf(':', 1) + 1;
if (s1 == -1 || cvsroot[0] != ':')
throw new ArgumentException("cvsroot doesn't start with :");
int s2 = cvsroot.IndexOf('@', s1) + 1;
if (s2 == -1)
throw new ArgumentException("no username given");
int s3 = cvsroot.IndexOf(':', s2) + 1;
if (s3 == -1)
throw new ArgumentException("no host given");
protocol = cvsroot.Substring(1, s1 - 2);
user = cvsroot.Substring(s1, s2 - s1 - 1);
host = cvsroot.Substring(s2, s3 - s2 - 1);
cvsrepository = cvsroot.Substring(s3);
if (protocol.Length == 0 || user.Length == 0 || host.Length == 0 || cvsrepository.Length == 0)
throw new ArgumentException("invalid cvsroot given");
}
public override string ToString()
{
return ':' + protocol + ':' + user + '@' + host + ':' + cvsrepository;
}
}
}
|