NVDA Helper
In-process and lite high-speed utilities for NVDA
utils.h File Reference
#include <string>
#include <wchar.h>
#include <map>
#include "storage.h"

Go to the source code of this file.

Typedefs

typedef std::multimap< std::wstring, std::wstring > multiValueAttribsMap
 

Functions

std::wstring getNameForURL (const std::wstring &url)
 Obtain a user friendly name for a URL if possible.
 
bool isWhitespace (const wchar_t *str)
 Determine whether a string of text is whitespace.
 
void multiValueAttribsStringToMap (const std::wstring &attribsString, multiValueAttribsMap &attribsMap)
 Convert a multi-value attributes string to a multimap of attribute keys and values.
 
bool nodeHasUsefulContent (VBufStorage_fieldNode_t *node)
 Determine whether a buffer node has useful content.
 
bool nodeContentMatchesString (VBufStorage_fieldNode_t *node, const std::wstring &testStr)
 Determine whether a buffer node's description is the same as it's content.
 
bool isPrivateCharacter (wchar_t ch)
 

Typedef Documentation

◆ multiValueAttribsMap

typedef std::multimap<std::wstring, std::wstring> multiValueAttribsMap

Function Documentation

◆ getNameForURL()

std::wstring getNameForURL ( const std::wstring & url)

Obtain a user friendly name for a URL if possible.

This is done as follows: For a URL which is not path-based (e.g. javascript), return the URL with the protocol (the portion before the colon) stripped. For a path-based URL (e.g. http) or a URL with no protocol (which is assumed to be a path), modify the URL as follows:

  • Start with the last path component which is not empty.
  • If this is not the hostname and there is no trailing slash, which means we're probably dealing with a filename, strip the extension; i.e. everything after the last "." character.
  • Append the query string and the anchor target, if any, with the "#" and "?" characters replaced with spaces.
    Parameters
    urlThe URL.
    Returns
    : The user friendly name for the URL.

Referenced by MshtmlVBufBackend_t::fillVBuf().

◆ isWhitespace()

bool isWhitespace ( const wchar_t * str)

Determine whether a string of text is whitespace.

Parameters
strThe string in question. @precondition: str is not NULL.
Returns
: true if str is whitespace, false otherwise.

◆ multiValueAttribsStringToMap()

void multiValueAttribsStringToMap ( const std::wstring & attribsString,
multiValueAttribsMap & attribsMap )

Convert a multi-value attributes string to a multimap of attribute keys and values.

A multi-value attributes string is of the form "name:value;name:value1,value2;...;" Colons, commas and semi-colons must be escaped with a backslash character. An invalid attributes string does not cause an error, but strange results may be returned.

Parameters
attribsStringThe attributes string to convert.
attribsMapThe multiValueAttribsMap into which the attributes should be placed, with keys and values as strings.

◆ nodeHasUsefulContent()

bool nodeHasUsefulContent ( VBufStorage_fieldNode_t * node)

Determine whether a buffer node has useful content.

Useful content means the text isn't empty and isn't just a small amount of whitespace.

References VBufStorage_fieldNode_t::getLength(), VBufStorage_fieldNode_t::getTextInRange(), and isPrivateCharacter().

Referenced by MshtmlVBufBackend_t::fillVBuf().

◆ nodeContentMatchesString()

bool nodeContentMatchesString ( VBufStorage_fieldNode_t * node,
const std::wstring & testStr )

Determine whether a buffer node's description is the same as it's content.

This can happen with links that have a title attribute matching the content.

References VBufStorage_fieldNode_t::getLength(), and VBufStorage_fieldNode_t::getTextInRange().

◆ isPrivateCharacter()

bool isPrivateCharacter ( wchar_t ch)
inline