The Classes
HTMLBeacon
Derived from: none
Declared in: HTMLFile.h
HTMLBeacon represents particular strings to search in an html file. Use them with HTMLFile.
Constructor and Destructor
|
|
|
HTMLBeacon(const char *stringToFind)
|
HTMLBeacon(const char *string1, const char *string2)
| |
Creates a new HTMLBeacon. The first version creates a one-string beacon. stringToFind will be searched in the html file, and if it is found, the word just after will be stored. The second version creates a two-string beacon. When BeHappy finds string1, it will look for string2 and store the text between the two of them.
A few remarks:
- The strings are case-insensitive, and spaces and tags in the html file are ignored. So if stringToFind="hello", both "hello" and "H e <b>lLo</b>" will be found.
- If you put a space in stringToFind, there must be one in the html file. So if stringToFind="hel lo", "H EL LO" will be found, but "h ello" won't.
- Tags between string1 and string2 won't be recognised. So if there's a link or a label between these two strings, it will be ignored. The contents of the tags won't be stored. (ie if between string1 and string2 there is "He<b>llo</b>", the found string will just be "Hello".
- If the tags are ignored between string1 and string2, you may ask yourself how you can do to find what's in a specific tag... In fact it is simple: just put an '<' at the end of string1, and the caracters just after won't be recognised as a tag, and won't be ignored. As an example, all the html files in the BeHappy Documentation have a <!DK><!type><!DK> string at the beginning, where type is topic for a topic file, and class for a class description. To find the type, I created a beacon with string1="<!DK><!" and string2="><!DK>". The found string will be "no", "topic" or "class".
- If you do a one-string beacon, don't forget that BeHappy will extract the word just after stringToFind. So if you have a link or a label just after stringToFind, it won't be recognised as such. That's why in the sample add-on, to search the <!start> and <!stop> tags, I use one-string beacons with the strings <start and <!stop. In both cases, the FoundString() will be >, and if there is a link just after, it will be recognised.
Member Functions
Return true if the beacon has been found. The beacon must have been added to a file (see HTMLFile::AddBeacon()), and the file must have been searched (see HTMLFile::Search()).
|
|
|
const char *FoundString()
| |
Return the string found, if the beacon has been found. The beacon must have been added to a file (see HTMLFile::AddBeacon()), and the file must have been searched (see HTMLFile::Search()).
If the beacon is a one-string beacon, the found string is just the word after stringToFind, and if it is a two-string beacon, the found string is all the text between string1 and string2 (with the tags removed).