165 lines
2.9 KiB
C++
165 lines
2.9 KiB
C++
#ifndef _NNTP_LISTITEM_HPP_
|
|
#define _NNTP_LISTITEM_HPP_
|
|
#ifndef _COMMON_WINDOWS_HPP_
|
|
#include <common/windows.hpp>
|
|
#endif
|
|
#ifndef _COMMON_STRING_HPP_
|
|
#include <common/string.hpp>
|
|
#endif
|
|
|
|
class ListItem
|
|
{
|
|
public:
|
|
ListItem(void);
|
|
ListItem(const ListItem &someListItem);
|
|
ListItem(const String &listItemString);
|
|
ListItem(const String &groupName,DWORD first,DWORD last,BYTE posting);
|
|
virtual ~ListItem();
|
|
ListItem &operator=(const ListItem &someListItem);
|
|
WORD operator==(const ListItem &someListItem)const;
|
|
ListItem &operator<<(String lineString);
|
|
const String &groupName(void)const;
|
|
void groupName(const String &groupName);
|
|
DWORD first(void)const;
|
|
void first(DWORD first);
|
|
DWORD last(void)const;
|
|
void last(DWORD last);
|
|
BYTE posting(void)const;
|
|
void posting(BYTE posting);
|
|
String toString(void)const;
|
|
private:
|
|
String mGroupName;
|
|
DWORD mFirst;
|
|
DWORD mLast;
|
|
BYTE mPosting;
|
|
};
|
|
|
|
inline
|
|
ListItem::ListItem(void)
|
|
: mFirst(0), mLast(0), mPosting('n')
|
|
{
|
|
}
|
|
|
|
inline
|
|
ListItem::ListItem(const ListItem &someListItem)
|
|
{
|
|
*this=someListItem;
|
|
}
|
|
|
|
inline
|
|
ListItem::ListItem(const String &listItemString)
|
|
{
|
|
*this<<listItemString;
|
|
}
|
|
|
|
inline
|
|
ListItem::ListItem(const String &groupName,DWORD first,DWORD last,BYTE posting)
|
|
: mGroupName(groupName), mFirst(first), mLast(last), mPosting(posting)
|
|
{
|
|
}
|
|
|
|
inline
|
|
ListItem::~ListItem()
|
|
{
|
|
}
|
|
|
|
inline
|
|
ListItem &ListItem::operator=(const ListItem &someListItem)
|
|
{
|
|
groupName(someListItem.groupName());
|
|
first(someListItem.first());
|
|
last(someListItem.last());
|
|
posting(someListItem.posting());
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
WORD ListItem::operator==(const ListItem &someListItem)const
|
|
{
|
|
return (groupName()==someListItem.groupName()&&
|
|
first()==someListItem.first()&&
|
|
last()==someListItem.last()&&
|
|
posting()==someListItem.posting());
|
|
}
|
|
|
|
inline
|
|
ListItem &ListItem::operator<<(String lineString)
|
|
{
|
|
char *strPtr=(LPSTR)lineString;
|
|
|
|
strPtr=::strtok(strPtr," ");
|
|
if(!strPtr)return *this;
|
|
groupName(strPtr);
|
|
strPtr=::strtok(0," ");
|
|
if(!strPtr)return *this;
|
|
first(::atoi(strPtr));
|
|
strPtr=::strtok(0," ");
|
|
if(!strPtr)return *this;
|
|
last(::atoi(strPtr));
|
|
strPtr=::strtok(0,"\0");
|
|
if(!strPtr)return *this;
|
|
posting(*strPtr);
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
const String &ListItem::groupName(void)const
|
|
{
|
|
return mGroupName;
|
|
}
|
|
|
|
inline
|
|
void ListItem::groupName(const String &groupName)
|
|
{
|
|
mGroupName=groupName;
|
|
}
|
|
|
|
inline
|
|
DWORD ListItem::first(void)const
|
|
{
|
|
return mFirst;
|
|
}
|
|
|
|
inline
|
|
void ListItem::first(DWORD first)
|
|
{
|
|
mFirst=first;
|
|
}
|
|
|
|
inline
|
|
DWORD ListItem::last(void)const
|
|
{
|
|
return mLast;
|
|
}
|
|
|
|
inline
|
|
void ListItem::last(DWORD last)
|
|
{
|
|
mLast=last;
|
|
}
|
|
|
|
inline
|
|
BYTE ListItem::posting(void)const
|
|
{
|
|
return mPosting;
|
|
}
|
|
|
|
inline
|
|
void ListItem::posting(BYTE posting)
|
|
{
|
|
mPosting=posting;
|
|
}
|
|
|
|
inline
|
|
String ListItem::toString(void)const
|
|
{
|
|
String strItem;
|
|
String space(" ");
|
|
|
|
strItem=mGroupName+space;
|
|
strItem+=String().fromInt(mLast)+space;
|
|
strItem+=String().fromInt(mFirst)+space;
|
|
strItem+=mPosting?"y":"n";
|
|
return strItem;
|
|
}
|
|
#endif |