RssHelpers.cpp

/****************************************************************************/

/**                                                                        **/

/** Copyright (c) 2005 Diodia Software          (http://www.diodia.com/)   **/

/**                                                                        **/

/** Use in any form with or without modification for commercial and non-   **/

/** commercial purposes is permitted.                                      **/

/**                                                                        **/

/****************************************************************************/

#include "stdafx.h"

 

#include "RssItemC.h"

#include "RssFeedC.h"

#include "RssHelpers.h"

 

static void ReplaceText(std::string &Text, const char *Old, const char *New);

 

/****************************************************************************/

/*

/* DESCRIPTION : Create feed local file name from feed name.

/*

/* RETURN VALUE: Full path

/*

/****************************************************************************/

std::string FeedNameToFileName(const char *Path, const char *FeedName)

{

   std::string  FileName;

   std::string  FullName;

 

   FileName = FeedName;

   for (int Pos = 0; Pos < (int) FileName.size(); Pos++)

   {

      if (!isalnum(FileName[Pos]))

         FileName[Pos] = ' ';

   }

 

   FullName = (std::string) Path + "\\" + FileName + ".xml";

 

   return FullName;

}

 

/****************************************************************************/

/*

/* DESCRIPTION : Create feed local file name from feed name.

/*

/* RETURN VALUE: Full path

/*

/****************************************************************************/

std::string FeedItemToDisplayString(RssItemC *Item)

{

   std::string  Text;

 

   Text = Item->GetDate();

   Text += "   ";

   Text += Item->GetTitle();

   if (Item->GetFeed()->GetTitle())

   {

      Text += "   [";

      Text += Item->GetFeed()->GetTitle();

      Text += " ]";

   }

 

   return Text;

}

 

/****************************************************************************/

/*

/* DESCRIPTION : Remove newlines, map special characters, etc. (make text

/*               string suitable for display in tooltip).

/*

/* RETURN VALUE: Normalized text

/*

/****************************************************************************/

std::string NormalizeText(std::string Text)

{

   ReplaceText(Text, "\n", " ");

   ReplaceText(Text, "&aelig;", "æ");

   ReplaceText(Text, "&oslash;", "ø");

   ReplaceText(Text, "&aring;", "å");

   ReplaceText(Text, "  ", " ");

 

   return Text;

}

 

/****************************************************************************/

/*

/* DESCRIPTION : Replace occurrences of Old with New in text string.

/*

/* RETURN VALUE: None

/*

/****************************************************************************/

static void ReplaceText(std::string &Text, const char *Old, const char *New)

{

   size_t       Pos;

 

   while ((Pos = Text.find(Old)) != std::string::npos)

      Text.replace(Pos, strlen(Old), New);

}

 





Source Files
   Commands.cpp
   Context.cpp
   CreatePath.cpp
   DateParser.cpp
   DlgEditFeedC.cpp
   DlgManageFeedsC.cpp
   Hook.cpp
   Iso8601.cpp
   MsXmlMisc.cpp
   MsXmlSelect.cpp
   RegistryNotify.cpp
   RegistryUtil.cpp
   RSS.cpp
   RSS.def
   RSS.idl
   RssAction.cpp
   RssDownloader.cpp
   RssFeed.cpp
   RssHelpers.cpp
   RssInit.cpp
   RssItem.cpp
   RssMultiFeed.cpp
   RssTimer.cpp
   RssXml.cpp
   StdAfx.cpp

Header Files
   Commands.h
   ContextC.h
   DateParser.h
   DlgEditFeedC.h
   DlgManageFeedsC.h
   Helper.h
   HookC.h
   RegistryNotify.h
   RegistryNotifyC.h
   Resource.h
   RssDownloaderC.h
   RssFeedC.h
   RssHelpers.h
   RssItemC.h
   RssMultiFeedC.h
   StdAfx.h
   ThreadObject.h
   XmlHelpers.h

Resource Files
   about.htm
   DiodiaLogoSmall.gif
   logo.bmp
   manifest.xml
   read.bmp
   RSS.rc
   RSS.rgs
   ToolBandLayout.xml
 

© 2002-2008 Diodia Software