return ret;
}
-Board Board::fromXml( const QString& xml )
+Board* Board::fromXml( const QString& xml )
{
- Board board;
+ Board* board;
BoardXmlParser parser;
QXmlSimpleReader reader;
if( parser.isValid() ) {
board = parser.getBoard();
} else {
+ board = new Board();
kdError() << "inValid" << endl;
}
return board;
{
if( localName == "board" ) {
m_inBoard = false;
- m_board = Kita::Board( m_urlStr, m_nameStr );
+ m_board = new Kita::Board( m_urlStr, m_nameStr );
m_isValid = true;
// create board;
} else if( localName == "url" ) {
const QPtrList<Thread> getThreadList() const;
const QString toXmlFragment() const;
- static Board fromXml( const QString& xml );
+ static Board* fromXml( const QString& xml );
// Factory method
static Board* getByURL( const QString& boardURL );
QString m_urlStr;
QString m_characters;
- Board m_board;
+ Board* m_board;
bool m_inBoard;
bool m_isValid;
public:
bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName );
bool characters( const QString& ch );
bool isValid() const { return m_isValid; }
- Board getBoard() const { return m_board; }
+ Board* getBoard() const { return m_board; }
};
};
CPPUNIT_ASSERT_EQUAL( QString( "unix" ), m_share2->id() );
CPPUNIT_ASSERT_EQUAL( QString( "unix" ), m_share3->id() );
CPPUNIT_ASSERT_EQUAL( QString::null, m_null->id() );
- CPPUNIT_ASSERT_EQUAL( QString( "linux" ), m_fromxml.id() );
- CPPUNIT_ASSERT_EQUAL( QString( "linux" ), m_fromxml2.id() );
+ CPPUNIT_ASSERT_EQUAL( QString( "linux" ), m_fromxml->id() );
+ CPPUNIT_ASSERT_EQUAL( QString( "linux" ), m_fromxml2->id() );
}
void BoardTest::testName()
CPPUNIT_ASSERT_EQUAL( QString( "U**x" ), m_share2->name() );
CPPUNIT_ASSERT_EQUAL( QString( "Unix" ), m_share3->name() );
CPPUNIT_ASSERT_EQUAL( QString::null, m_null->name() );
- CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), m_fromxml.name() );
- CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), m_fromxml2.name() );
+ CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), m_fromxml->name() );
+ CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), m_fromxml2->name() );
}
void BoardTest::testSubjectTxtURL()
m_share3->subjectTxtURL().url() );
CPPUNIT_ASSERT_EQUAL( QString::null, m_null->subjectTxtURL().url() );
CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/linux/subject.txt" ),
- m_fromxml.subjectTxtURL().url() );
+ m_fromxml->subjectTxtURL().url() );
CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/linux/subject.txt" ),
- m_fromxml2.subjectTxtURL().url() );
+ m_fromxml2->subjectTxtURL().url() );
}
void BoardTest::testURL()
m_share3->url() );
CPPUNIT_ASSERT_EQUAL( QString::null, m_null->url() );
CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/linux/"),
- m_fromxml.url() );
+ m_fromxml->url() );
CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/linux/"),
- m_fromxml2.url() );
+ m_fromxml2->url() );
}
if( localName == "board" ) {
m_inBoard = false;
m_boardParser->endElement( namespaceURI, localName, qName );
- Board board = m_boardParser->getBoard();
- m_board = new Board( board.url(), board.name() );
+ Board* board = m_boardParser->getBoard();
+ m_board = new Board( board->url(), board->name() );
delete m_boardParser;
m_boardParser = 0;