Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgPropTextList Class Reference

#include <SgProp.h>

Inheritance diagram for SgPropTextList:

Inheritance graph
[legend]
List of all members.

Detailed Description

Keeps a string for each point in a set of points.

Definition at line 891 of file SgProp.h.

Public Member Functions

 SgPropTextList (SgPropID id)
 SgPropTextList (SgPropID id, const SgVector< SgPoint > &points, SgVectorOf< std::string > strings)
virtual ~SgPropTextList ()
SgPropDuplicate () const
 Override this function for each property class to return an exact duplicate of this property.
const SgVector< SgPoint > & GetPointsWithText () const
 Return a list with all the points that have text associated with them.
bool GetStringAtPoint (SgPoint p, std::string *s) const
 If point 'p' has a string, copy that string into '*string' and return true.
void AddStringAtPoint (SgPoint p, const std::string &s)
 Set the string for point 'p' to 'string'.
void AppendToStringAtPoint (SgPoint p, const std::string &s)
 Append 'string' to the string for point 'p'.
void ClearStringAtPoint (SgPoint p)
 Remove any existing string for point 'p'.
bool ToString (std::vector< std::string > &values, int boardSize, SgPropPointFmt fmt, int fileFormat) const
 Convert the property into string representation.
bool FromString (const std::vector< std::string > &values, int boardSize, SgPropPointFmt fmt)
 Override this method to convert the string read from disk to the value of this property, and set the value of this property.
virtual bool ContainsText (const std::string &findText)
 Return true if this property matches the given text.
SgPropID ID () const
 Return the property type of this property.
virtual SgPropFlags Flags () const
 Get the flags for this property type.
virtual std::string Label () const
 Get the the label for this property type.
bool Flag (SgPropFlags flags) const
 Return whether any of the given flags are set for this property.
SgBlackWhite Player () const
 If this property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return that property.
bool IsPlayer (SgBlackWhite player) const
virtual void ChangeToOpponent ()
 Override this method to do something special when changing the color of a property (e.g.
bool MatchesID (SgPropID id) const
 Return true if the given 'id' matches this property.

Static Public Member Functions

static SgPropID Register (SgProp *prop, const char *label, SgPropFlags flags=0)
 Call this function with a property of the right type to register that property type.
static SgPropCreateProperty (SgPropID id)
 Create a property with the given property ID.
static SgPropID GetIDOfLabel (const std::string &label)
 Return the ID for a given label.
static SgPropID ConvertFindTextToPropID (const std::string &findText)
 Convert the text specified in the Find dialog to special propIDs to search for.
static void Init ()
 Initialize properties.
static void Fini ()
 Finalize properties.
static SgPropID OpponentProp (SgPropID id)
 If the given property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return the property of the opposite color, otherwise return 'id'.
static SgPropID PlayerProp (SgPropID id, SgBlackWhite player)
 If the given property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return the property of player's color, otherwise return 'id'.

Static Protected Member Functions

static bool Initialized ()

Protected Attributes

SgPropID m_id

Private Attributes

SgVector< SgPointm_points
SgVectorOf< std::string > m_strings


Constructor & Destructor Documentation

SgPropTextList::SgPropTextList ( SgPropID  id  )  [explicit]

Definition at line 942 of file SgProp.h.

Referenced by Duplicate().

SgPropTextList::SgPropTextList ( SgPropID  id,
const SgVector< SgPoint > &  points,
SgVectorOf< std::string >  strings 
)

Definition at line 1087 of file SgProp.cpp.

References m_strings, and SgVectorOf< T >::PushBack().

SgPropTextList::~SgPropTextList (  )  [virtual]

Definition at line 1099 of file SgProp.cpp.

References m_strings.


Member Function Documentation

void SgPropTextList::AddStringAtPoint ( SgPoint  p,
const std::string &  s 
)

Set the string for point 'p' to 'string'.

If that point already has a string, replace it with the new string.

Definition at line 1123 of file SgProp.cpp.

References ClearStringAtPoint(), m_points, m_strings, and SgVectorOf< T >::PushBack().

Referenced by AppendToStringAtPoint(), and FromString().

void SgPropTextList::AppendToStringAtPoint ( SgPoint  p,
const std::string &  s 
)

Append 'string' to the string for point 'p'.

If that point has no string, create a new one.

Definition at line 1130 of file SgProp.cpp.

References AddStringAtPoint(), and GetStringAtPoint().

void SgProp::ChangeToOpponent (  )  [virtual, inherited]

Override this method to do something special when changing the color of a property (e.g.

a value might need to be negated).

Reimplemented in SgPropValue, and SgPropPlayer.

Definition at line 391 of file SgProp.cpp.

References SgProp::m_id, and SgProp::OpponentProp().

void SgPropTextList::ClearStringAtPoint ( SgPoint  p  ) 

Remove any existing string for point 'p'.

Definition at line 1138 of file SgProp.cpp.

References SgVector< T >::DeleteAt(), m_points, and m_strings.

Referenced by AddStringAtPoint().

bool SgPropTextList::ContainsText ( const std::string &  findText  )  [virtual]

Return true if this property matches the given text.

Override for specific properties.

Reimplemented from SgProp.

Definition at line 1192 of file SgProp.cpp.

References m_strings.

SgPropID SgProp::ConvertFindTextToPropID ( const std::string &  findText  )  [static, inherited]

Convert the text specified in the Find dialog to special propIDs to search for.

Return SG_PROP_NONE if the literal text should be searched for.

Definition at line 526 of file SgProp.cpp.

References SG_PROP_ANNOTATE, SG_PROP_BAD_MOVE, SG_PROP_BRANCH, SG_PROP_CHECK, SG_PROP_COMMENT, SG_PROP_GOOD_MOVE, SG_PROP_HOTSPOT, SG_PROP_INFO, SG_PROP_MARKS, SG_PROP_MOVE_BLACK, SG_PROP_MOVE_WHITE, SG_PROP_NAME, SG_PROP_NONE, SG_PROP_SIGMA, SG_PROP_TERMINAL, and SG_PROP_TRIANGLE.

Referenced by SgNode::ContainsText().

SgProp * SgProp::CreateProperty ( SgPropID  id  )  [static, inherited]

Create a property with the given property ID.

Definition at line 440 of file SgProp.cpp.

References SgProp::Duplicate(), SgProp::m_id, SgProp::s_numPropClasses, SgProp::s_prop, and SG_ASSERT.

Referenced by SgGameReader::HandleProperties(), SgNode::SetIntProp(), SgNode::SetListProp(), SgNode::SetRealProp(), and SgNode::SetStringProp().

SgProp * SgPropTextList::Duplicate (  )  const [virtual]

Override this function for each property class to return an exact duplicate of this property.

Implements SgProp.

Definition at line 1107 of file SgProp.cpp.

References SgProp::m_id, m_points, m_strings, and SgPropTextList().

void SgProp::Fini (  )  [static, inherited]

Finalize properties.

Definition at line 806 of file SgProp.cpp.

References SgProp::s_initialized.

Referenced by SgFini().

bool SgProp::Flag ( SgPropFlags  flags  )  const [inherited]

Return whether any of the given flags are set for this property.

Definition at line 411 of file SgProp.h.

References SgProp::Flags().

Referenced by SgPropList::Add(), SgNode::Add(), SgProp::Player(), and SgGameWriter::ShouldWriteProperty().

SgPropFlags SgProp::Flags (  )  const [virtual, inherited]

Get the flags for this property type.

Not normally overridden.

Definition at line 402 of file SgProp.cpp.

References SgProp::m_id, and SgProp::s_flags.

Referenced by SgProp::Flag(), SgProp::MatchesID(), and SgProp::Player().

bool SgPropTextList::FromString ( const std::vector< std::string > &  values,
int  boardSize,
SgPropPointFmt  fmt 
) [virtual]

Override this method to convert the string read from disk to the value of this property, and set the value of this property.

Returns:
true, if the string could be converted to a valid property.

Implements SgProp.

Definition at line 1170 of file SgProp.cpp.

References AddStringAtPoint(), SgPointUtil::InBoardRange(), and SgPropUtil::SgfStringToPoint().

SgPropID SgProp::GetIDOfLabel ( const std::string &  label  )  [static, inherited]

Return the ID for a given label.

Return SG_PROP_NONE if there is no property with that label.

Definition at line 452 of file SgProp.cpp.

References SgProp::s_label, SgProp::s_numPropClasses, and SG_PROP_NONE.

Referenced by SgGameReader::HandleProperties().

const SgVector< SgPoint > & SgPropTextList::GetPointsWithText (  )  const

Return a list with all the points that have text associated with them.

Definition at line 949 of file SgProp.h.

References m_points.

bool SgPropTextList::GetStringAtPoint ( SgPoint  p,
std::string *  s 
) const

If point 'p' has a string, copy that string into '*string' and return true.

Otherwise return false and don't change '*string'.

Definition at line 1112 of file SgProp.cpp.

References m_points, and m_strings.

Referenced by AppendToStringAtPoint().

SgPropID SgProp::ID (  )  const [inherited]

Return the property type of this property.

Definition at line 406 of file SgProp.h.

References SgProp::m_id.

Referenced by SgPropList::Add(), SgPropList::AppendMoveAnnotation(), SgPropPointList::Duplicate(), SgProp::MatchesID(), and SgGameWriter::ShouldWriteProperty().

void SgProp::Init (  )  [static, inherited]

Initialize properties.

Registers most properties. Does not register SG_PROP_MOVE_BLACK ("B") and SG_PROP_MOVE_WHITE ("W"), because they are game dependent.

Definition at line 557 of file SgProp.cpp.

References SgProp::Register(), SgProp::s_flags, SgProp::s_initialized, SgProp::s_label, SgProp::s_prop, SG_PROP_ADD_BLACK, SG_PROP_ADD_EMPTY, SG_PROP_ADD_WHITE, SG_PROP_ANALYSIS, SG_PROP_ANNOTATE, SG_PROP_APPLIC, SG_PROP_BAD_MOVE, SG_PROP_BRANCH, SG_PROP_CHECK, SG_PROP_CHINESE, SG_PROP_CIRCLE, SG_PROP_COMMENT, SG_PROP_COPYRIGHT, SG_PROP_COUNT, SG_PROP_DATE, SG_PROP_DEPTH, SG_PROP_DIAMOND, SG_PROP_DIMMED, SG_PROP_DOUBTFUL, SG_PROP_EVAL, SG_PROP_EVEN_POS, SG_PROP_EVENT, SG_PROP_EXPECTED, SG_PROP_FIGURE, SG_PROP_FIND_MOVE, SG_PROP_FIND_TEXT, SG_PROP_FORMAT, SG_PROP_GAME, SG_PROP_GAME_COMMENT, SG_PROP_GAME_NAME, SG_PROP_GOOD_BLACK, SG_PROP_GOOD_MOVE, SG_PROP_GOOD_WHITE, SG_PROP_HANDICAP, SG_PROP_HOTSPOT, SG_PROP_INFO, SG_PROP_INTERESTING, SG_PROP_KOMI, SG_PROP_LABEL, SG_PROP_LOSE_TIME, SG_PROP_MARKED, SG_PROP_MARKS, SG_PROP_MAX_DEPTH, SG_PROP_MOTIVE, SG_PROP_MOVE, SG_PROP_MOVE_ANNO, SG_PROP_NAME, SG_PROP_NONE, SG_PROP_NOT_BLACK, SG_PROP_NOT_EMPTY, SG_PROP_NOT_WHITE, SG_PROP_NUM_LEAFS, SG_PROP_NUM_NODES, SG_PROP_OPENING, SG_PROP_OT_BLACK, SG_PROP_OT_NU_MOVES, SG_PROP_OT_PERIOD, SG_PROP_OT_WHITE, SG_PROP_OVERHEAD, SG_PROP_PART_DEPTH, SG_PROP_PLACE, SG_PROP_PLAYER, SG_PROP_PLAYER_BLACK, SG_PROP_PLAYER_WHITE, SG_PROP_POS_ANNO, SG_PROP_RANK_BLACK, SG_PROP_RANK_WHITE, SG_PROP_RESULT, SG_PROP_ROUND, SG_PROP_RULES, SG_PROP_SELECT, SG_PROP_SEQUENCE, SG_PROP_SIGMA, SG_PROP_SIZE, SG_PROP_SOURCE, SG_PROP_SPEC_BLACK, SG_PROP_SPEC_WHITE, SG_PROP_SQUARE, SG_PROP_TEAM_BLACK, SG_PROP_TEAM_WHITE, SG_PROP_TERMINAL, SG_PROP_TERR_BLACK, SG_PROP_TERR_WHITE, SG_PROP_TIME, SG_PROP_TIME_BLACK, SG_PROP_TIME_USED, SG_PROP_TIME_WHITE, SG_PROP_TIMES, SG_PROP_TRIANGLE, SG_PROP_UNCLEAR, SG_PROP_UNKNOWN, SG_PROP_USER, SG_PROP_VALUE, SG_PROPCLASS_ABSTRACT, SG_PROPCLASS_ANNO, SG_PROPCLASS_ANNO_MOVE, SG_PROPCLASS_ANNO_POS, SG_PROPCLASS_BLACK, SG_PROPCLASS_CUSTOM, SG_PROPCLASS_INFO, SG_PROPCLASS_MARK, SG_PROPCLASS_MOVE, SG_PROPCLASS_NEWLINE, SG_PROPCLASS_NOT_FF3, SG_PROPCLASS_NOTCLEAN, SG_PROPCLASS_ROOT, SG_PROPCLASS_STAT, SG_PROPCLASS_TIME, and SG_PROPCLASS_WHITE.

Referenced by SgInitImpl().

bool SgProp::Initialized (  )  [static, protected, inherited]

Definition at line 407 of file SgProp.cpp.

References SgProp::s_initialized.

Referenced by SgPropInt::Value().

bool SgProp::IsPlayer ( SgBlackWhite  player  )  const [inherited]

Definition at line 503 of file SgProp.cpp.

References SgProp::Player(), and SG_ASSERT_BW.

string SgProp::Label (  )  const [virtual, inherited]

Get the the label for this property type.

Overridden only by SgPropUnknown.

Reimplemented in SgPropUnknown.

Definition at line 412 of file SgProp.cpp.

References SgProp::m_id, and SgProp::s_label.

Referenced by SgGameWriter::ShouldWriteProperty().

bool SgProp::MatchesID ( SgPropID  id  )  const [inherited]

Return true if the given 'id' matches this property.

The special properties SG_PROP_INFO, SG_PROP_ANNOTATE, SG_PROP_POS_ANNO, SG_PROP_MOVE_ANNO, and SG_PROP_COUNT match any property that has the corresponding flag set.

Definition at line 509 of file SgProp.cpp.

References SgProp::Flags(), SgProp::ID(), SgProp::s_flags, and SG_PROPCLASS_ABSTRACT.

Referenced by SgPropList::Remove().

SgPropID SgProp::OpponentProp ( SgPropID  id  )  [static, inherited]

If the given property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return the property of the opposite color, otherwise return 'id'.

Definition at line 460 of file SgProp.cpp.

References SgProp::s_flags, SG_ASSERT, SG_PROPCLASS_BLACK, and SG_PROPCLASS_WHITE.

Referenced by SgProp::ChangeToOpponent(), and SgProp::PlayerProp().

SgBlackWhite SgProp::Player (  )  const [inherited]

If this property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return that property.

Otherwise the return value is undefined (checked with assertion).

Definition at line 492 of file SgProp.cpp.

References SgProp::Flag(), SgProp::Flags(), SG_ASSERT, SG_BLACK, SG_PROPCLASS_BLACK, SG_PROPCLASS_WHITE, and SG_WHITE.

Referenced by SgProp::IsPlayer().

SgPropID SgProp::PlayerProp ( SgPropID  id,
SgBlackWhite  player 
) [static, inherited]

If the given property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return the property of player's color, otherwise return 'id'.

Definition at line 480 of file SgProp.cpp.

References SgProp::OpponentProp(), SgProp::s_flags, SG_ASSERT, SG_PROPCLASS_BLACK, SG_PROPCLASS_WHITE, and SG_WHITE.

Referenced by SgTimeRecord::PlayedMove(), and SgTimeRecord::SetClock().

SgPropID SgProp::Register ( SgProp prop,
const char *  label,
SgPropFlags  flags = 0 
) [static, inherited]

Call this function with a property of the right type to register that property type.

Ownership of 'prop' is passed to the Property class; it will dispose the property upon exit. Register returns the property identifier to be used to refer to this property. Abstract properties can be registered with 'prop' set to 0. No property object of that type can be instantiated. (?? useful for searching?) This method asserts and returns 0 if the registry is full.

Definition at line 417 of file SgProp.cpp.

References SgProp::m_id, SgProp::s_flags, SgProp::s_label, SgProp::s_numPropClasses, SgProp::s_prop, SG_ASSERT, SG_MAX_PROPCLASS, SG_PROPCLASS_BLACK, and SG_PROPCLASS_WHITE.

Referenced by SgProp::Init().

bool SgPropTextList::ToString ( std::vector< std::string > &  values,
int  boardSize,
SgPropPointFmt  fmt,
int  fileFormat 
) const [virtual]

Convert the property into string representation.

Escapes special characters if needed (this depends on the property, e.g. the colon needs to be escaped only by some properties) Use the default file format if 'fileFormat' is zero; use the proper version of the sgf file format if 'fileFormat' is 3 or greater.

Returns:
true if the property should be written to file

Implements SgProp.

Definition at line 1149 of file SgProp.cpp.

References SgPropUtil::EscapeSpecialCharacters(), m_points, m_strings, and SgPropUtil::PointToSgfString().


Member Data Documentation

SgPropID SgProp::m_id [protected, inherited]

Definition at line 378 of file SgProp.h.

Referenced by SgProp::ChangeToOpponent(), SgProp::CreateProperty(), SgPropMove::Duplicate(), SgPropAddStone::Duplicate(), SgPropPlayer::Duplicate(), Duplicate(), SgPropText::Duplicate(), SgPropMSec::Duplicate(), SgPropTime::Duplicate(), SgPropValue::Duplicate(), SgPropReal::Duplicate(), SgPropInt::Duplicate(), SgPropMultiple::Duplicate(), SgPropSimple::Duplicate(), SgPropUnknown::Duplicate(), SgProp::Flags(), SgProp::ID(), SgProp::Label(), and SgProp::Register().

SgVector<SgPoint> SgPropTextList::m_points [private]

Definition at line 937 of file SgProp.h.

Referenced by AddStringAtPoint(), ClearStringAtPoint(), Duplicate(), GetPointsWithText(), GetStringAtPoint(), and ToString().

SgVectorOf<std::string> SgPropTextList::m_strings [private]

Definition at line 939 of file SgProp.h.

Referenced by AddStringAtPoint(), ClearStringAtPoint(), ContainsText(), Duplicate(), GetStringAtPoint(), SgPropTextList(), ToString(), and ~SgPropTextList().


The documentation for this class was generated from the following files:


17 Jun 2010 Doxygen 1.4.7