NCBI C++ ToolKit
Classes | Typedefs | Enumerations | Enumerator | Functions | Variables
HTML Helper and Utility Functions
+ Collaboration diagram for HTML Helper and Utility Functions:

Classes

class  CHTMLHelper
 
class  CIDs
 CIDs class to hold sorted list of IDs. More...
 

Typedefs

typedef int CHTMLHelper::THTMLEncodeFlags
 
typedef int CHTMLHelper::THTMLDecodeFlags
 

Enumerations

enum  CHTMLHelper::EHTMLEncodeFlags {
  CHTMLHelper::fEncodeAll = 0 , CHTMLHelper::fSkipLiteralEntities = 1 << 1 , CHTMLHelper::fSkipNumericEntities = 1 << 2 , CHTMLHelper::fSkipEntities = fSkipLiteralEntities | fSkipNumericEntities ,
  CHTMLHelper::fCheckPreencoded = 1 << 3
}
 Flags for HTMLEncode. More...
 
enum  CHTMLHelper::EHTMLDecodeFlags { CHTMLHelper::fCharRef_Entity = 1 , CHTMLHelper::fCharRef_Numeric = 1 << 1 , CHTMLHelper::fEncoding = 1 << 2 }
 

Functions

static string CHTMLHelper::HTMLEncode (const string &str, THTMLEncodeFlags flags=fEncodeAll)
 HTML encodes a string. E.g. <. More...
 
static CStringUTF8 CHTMLHelper::HTMLDecode (const string &str, EEncoding encoding=eEncoding_Unknown, THTMLDecodeFlags *result_flags=NULL)
 Decode HTML entities and character references. More...
 
static string CHTMLHelper::HTMLJavaScriptEncode (const string &str, THTMLEncodeFlags flags=fEncodeAll)
 Encode a string for JavaScript. More...
 
static string CHTMLHelper::HTMLAttributeEncode (const string &str, THTMLEncodeFlags flags=fSkipEntities)
 HTML encodes a tag attribute ('&' and '"' symbols). More...
 
static string CHTMLHelper::StripHTML (const string &str)
 Strip all HTML code from a string. More...
 
static string CHTMLHelper::StripTags (const string &str)
 Strip all HTML tags from a string. More...
 
static string CHTMLHelper::StripSpecialChars (const string &str)
 Strip all named and numeric character entities from a string. More...
 
static void CHTMLHelper::SetNL (const string &nl)
 
static string CHTMLHelper::GetNL (void)
 
 CIDs::CIDs (void)
 
 CIDs::~CIDs (void)
 
bool CIDs::ExtractID (int id)
 
void CIDs::AddID (int id)
 
size_t CIDs::CountIDs (void) const
 
void CIDs::Decode (const string &str)
 
string CIDs::Encode (void) const
 
int CIDs::GetNumber (const string &str)
 
int CIDs::AddID (char cmd, int id, int number)
 

Variables

static const char * CHTMLHelper::sm_newline = kDefaultNL
 

Detailed Description

Typedef Documentation

◆ THTMLDecodeFlags

Definition at line 83 of file htmlhelper.hpp.

◆ THTMLEncodeFlags

Definition at line 72 of file htmlhelper.hpp.

Enumeration Type Documentation

◆ EHTMLDecodeFlags

Enumerator
fCharRef_Entity 

Character entity reference(s) was found.

fCharRef_Numeric 

Numeric character reference(s) was found.

fEncoding 

Character encoding changed.

Definition at line 78 of file htmlhelper.hpp.

◆ EHTMLEncodeFlags

Flags for HTMLEncode.

Enumerator
fEncodeAll 

Encode all symbols.

fSkipLiteralEntities 

Skip "&entity;".

fSkipNumericEntities 

Skip "&#NNNN;".

fSkipEntities 
fCheckPreencoded 

Print warning if some preencoded entity found in the string.

Definition at line 64 of file htmlhelper.hpp.

Function Documentation

◆ AddID() [1/2]

int CIDs::AddID ( char  cmd,
int  id,
int  number 
)
inlineprivate

Definition at line 226 of file htmlhelper.hpp.

References CIDs::AddID(), cmd, and number.

◆ AddID() [2/2]

void CIDs::AddID ( int  id)
inline

Definition at line 142 of file htmlhelper.hpp.

Referenced by CIDs::AddID(), CSelection::CSelection(), and CIDs::Decode().

◆ CIDs()

CIDs::CIDs ( void  )
inline

Definition at line 134 of file htmlhelper.hpp.

◆ CountIDs()

size_t CIDs::CountIDs ( void  ) const
inline

Definition at line 145 of file htmlhelper.hpp.

References ncbi::grid::netcache::search::fields::size.

◆ Decode()

void CIDs::Decode ( const string str)
inline

Definition at line 197 of file htmlhelper.hpp.

References CIDs::AddID(), cmd, CIDs::GetNumber(), NPOS, and str().

Referenced by CSelection::CSelection().

◆ Encode()

string CIDs::Encode ( void  ) const
inline

Definition at line 245 of file htmlhelper.hpp.

References i, NStr::IntToString(), and out().

Referenced by CSelection::CreateSubNodes().

◆ ExtractID()

bool CIDs::ExtractID ( int  id)
inline

Definition at line 179 of file htmlhelper.hpp.

References i.

◆ GetNL()

static string CHTMLHelper::GetNL ( void  )
inlinestatic

◆ GetNumber()

int CIDs::GetNumber ( const string str)
inlineprivate

Definition at line 190 of file htmlhelper.hpp.

References str(), and NStr::StringToInt().

Referenced by CIDs::Decode().

◆ HTMLAttributeEncode()

string CHTMLHelper::HTMLAttributeEncode ( const string str,
THTMLEncodeFlags  flags = fSkipEntities 
)
static

HTML encodes a tag attribute ('&' and '"' symbols).

Definition at line 153 of file htmlhelper.cpp.

References flags, s_HTMLEncode(), and str().

Referenced by CHTMLOpenElement::x_PrintBegin().

◆ HTMLDecode()

CStringUTF8 CHTMLHelper::HTMLDecode ( const string str,
EEncoding  encoding = eEncoding_Unknown,
THTMLDecodeFlags result_flags = NULL 
)
static

◆ HTMLEncode()

string CHTMLHelper::HTMLEncode ( const string str,
THTMLEncodeFlags  flags = fEncodeAll 
)
static

◆ HTMLJavaScriptEncode()

string CHTMLHelper::HTMLJavaScriptEncode ( const string str,
THTMLEncodeFlags  flags = fEncodeAll 
)
inlinestatic

Encode a string for JavaScript.

Call HTMLEncode and also encode all non-printable characters. The non-printable characters will be represented as "\S" where S is the symbol code or as "\xDD" where DD is the character's code in hexadecimal.

See also
NStr::JavaScriptEncode, HTMLEncode

Definition at line 166 of file htmlhelper.hpp.

References flags, CHTMLHelper::HTMLEncode(), NStr::JavaScriptEncode(), and str().

◆ SetNL()

void CHTMLHelper::SetNL ( const string nl)
static

Definition at line 49 of file htmlhelper.cpp.

References free(), kDefaultNL, NcbiSysChar_strdup, and CHTMLHelper::sm_newline.

◆ StripHTML()

string CHTMLHelper::StripHTML ( const string str)
inlinestatic

Strip all HTML code from a string.

Definition at line 173 of file htmlhelper.hpp.

References str(), CHTMLHelper::StripSpecialChars(), and CHTMLHelper::StripTags().

Referenced by CDoiLookup::GetPubFromCrossRef(), CJobResultsDlg::OnExportClick(), and CHTMLText::PrintString().

◆ StripSpecialChars()

string CHTMLHelper::StripSpecialChars ( const string str)
static

Strip all named and numeric character entities from a string.

Definition at line 200 of file htmlhelper.cpp.

References check, i, int, isalpha(), isdigit(), NPOS, and str().

Referenced by CHTMLHelper::StripHTML().

◆ StripTags()

string CHTMLHelper::StripTags ( const string str)
static

Strip all HTML tags from a string.

Definition at line 159 of file htmlhelper.cpp.

References isalpha(), NPOS, and str().

Referenced by CHTMLHelper::StripHTML().

◆ ~CIDs()

CIDs::~CIDs ( void  )
inline

Definition at line 135 of file htmlhelper.hpp.

Variable Documentation

◆ sm_newline

const char * CHTMLHelper::sm_newline = kDefaultNL
staticprotected

Definition at line 122 of file htmlhelper.hpp.

Referenced by CHTMLHelper::GetNL(), and CHTMLHelper::SetNL().

Modified on Wed Feb 21 09:54:07 2024 by modify_doxy.py rev. 669887