link_parser.cpp File Reference

#include <basis/function.h>
#include <basis/guards.h>
#include <basis/istring.h>
#include <opsystem/application_shell.h>
#include <opsystem/byte_filer.h>
#include <opsystem/command_line.h>
#include <loggers/file_logger.h>
#include <opsystem/filename.h>
#include <data_struct/static_memory_gremlin.h>
#include <textual/parser_bits.h>

Include dependency graph for link_parser.cpp:

Go to the source code of this file.

Defines

#define BASE_LOG(s)   program_wide_logger().log(s)
#define LOG(s)   CLASS_EMERGENCY_LOG(program_wide_logger(), s)
#define INCREM_N_GO   { curr_index++; continue; }
#define ADD_INTERMEDIATE   intermediate_text += full_contents[curr_index]
#define JUMP_TO_CHAR(to_find, save_them)
#define NEXT_STATE_INCREM
#define CLEAN_UP_NAUGHTY(s)
#define MAKE_MORE_ENGLISH(s)   s.replace_all('_', ' ')
#define WRITE_LINK
#define WRITE_SECTION
#define RESET_STRINGS

Functions

bool caseless_equals (char to_find, char comparing_with)
void strain_out_html_codes (istring &to_edit)

Variables

const int MAX_FILE_SIZE = 4 * MEGABYTE


Define Documentation

#define ADD_INTERMEDIATE   intermediate_text += full_contents[curr_index]

Definition at line 54 of file link_parser.cpp.

#define BASE_LOG (  )     program_wide_logger().log(s)

Definition at line 41 of file link_parser.cpp.

#define CLEAN_UP_NAUGHTY (  ) 

Value:

{ \
  while (s.replace("\n", " ")) {} \
  while (s.replace("\r", "")) {} \
  int indy = s.find("--"); \
  while (non_negative(indy)) { \
    s[indy] = ' ';  /* replace the first dash with a space. */ \
    for (int i = indy + 1; i < s.length(); i++) { \
      if (s[i] != '-') break; \
      s.zap(i, i); \
      i--; \
    } \
    indy = s.find("--"); \
  } \
  while (s.replace("  ", " ")) {} \
  s.strip_spaces(); \
}

Definition at line 82 of file link_parser.cpp.

#define INCREM_N_GO   { curr_index++; continue; }

Definition at line 51 of file link_parser.cpp.

#define JUMP_TO_CHAR ( to_find,
save_them   ) 

Value:

{ \
  while ( (curr_index < full_contents.length()) \
      && !caseless_equals(to_find, full_contents[curr_index]) ) { \
    if (save_them) ADD_INTERMEDIATE; \
    curr_index++; \
  } \
}

Definition at line 66 of file link_parser.cpp.

#define LOG (  )     CLASS_EMERGENCY_LOG(program_wide_logger(), s)

Definition at line 43 of file link_parser.cpp.

#define MAKE_MORE_ENGLISH (  )     s.replace_all('_', ' ')

Definition at line 100 of file link_parser.cpp.

#define NEXT_STATE_INCREM

Value:

{ \
  state = parsing_states(state+1);  /* move forward in states. */ \
  curr_index++; \
  continue; \
}

Definition at line 75 of file link_parser.cpp.

#define RESET_STRINGS

Value:

{ \
  url_string = istring::empty_string(); \
  name_string = istring::empty_string(); \
  intermediate_text = istring::empty_string(); \
}

Definition at line 157 of file link_parser.cpp.

#define WRITE_LINK

Value:

{ \
  /* clean naughty characters out of the names. */ \
  CLEAN_UP_NAUGHTY(url_string); \
  CLEAN_UP_NAUGHTY(name_string); \
  while (name_string.replace("\n", " ")) {} \
  while (name_string.replace("\r", "")) {} \
  if (url_string.ends(name_string)) { \
    /* handle the name being boring. replace with the intermediate text. */ \
    MAKE_MORE_ENGLISH(intermediate_text); \
    strain_out_html_codes(intermediate_text); \
    CLEAN_UP_NAUGHTY(intermediate_text); \
    if (intermediate_text.length()) \
      name_string = intermediate_text; \
  } \
  /* output a link in the HOOPLE format. */ \
  istring to_write = "\"L\",\""; \
  to_write += name_string; \
  to_write += "\",\""; \
  to_write += last_title; \
  to_write += "\",\""; \
  to_write += url_string; \
  to_write += "\"\n"; \
  output_file.write(to_write); \
  _link_count++; \
}

Definition at line 116 of file link_parser.cpp.

#define WRITE_SECTION

Value:

{ \
  CLEAN_UP_NAUGHTY(last_title);  /* clean the name. */ \
  /* output a category definition. */ \
  istring to_write = "\"C\",\""; \
  to_write += last_title; \
  to_write += "\",\""; \
  to_write += "NOP"; \
  to_write += "\"\n"; \
  output_file.write(to_write); \
  _category_count++; \
}

Definition at line 144 of file link_parser.cpp.


Function Documentation

bool caseless_equals ( char  to_find,
char  comparing_with 
)

Definition at line 57 of file link_parser.cpp.

void strain_out_html_codes ( istring to_edit  ) 

Definition at line 103 of file link_parser.cpp.

References istring::find(), istring::length(), negative(), and istring::zap().


Variable Documentation

const int MAX_FILE_SIZE = 4 * MEGABYTE

Definition at line 45 of file link_parser.cpp.


Generated on Fri Aug 29 04:29:16 2008 for HOOPLE Libraries by  doxygen 1.5.1