Kyoto Tycoon
Classes | Typedefs | Functions | Variables
kyototycoon Namespace Reference

All symbols of Kyoto Tycoon. More...

Classes

class  MapReduce
 MapReduce framework. More...
class  URL
 URL accessor. More...
class  HTTPClient
 HTTP client. More...
class  HTTPServer
 HTTP server. More...
class  PluggableDB
 Interface of pluggable database abstraction. More...
class  PluggableServer
 Interface of pluggable server abstraction. More...
class  RemoteDB
 Remote database. More...
class  ReplicationClient
 Replication client. More...
class  RPCClient
 RPC client. More...
class  RPCServer
 RPC server. More...
class  SharedLibrary
 Shared library. More...
class  Pollable
 Interface of poolable I/O event. More...
class  Socket
 Network stream abstraction based on TCP/IP. More...
class  ServerSocket
 Network server abstraction based on TCP/IP. More...
class  Poller
 I/O event notification. More...
class  ThreadedServer
 Threaded TCP Server. More...
class  TimedDB
 Timed database. More...
class  UpdateLogger
 Update logger. More...

Typedefs

typedef PluggableDB *(* KTDBINIT )()
 Initializer of a database implementation.
typedef PluggableServer *(* KTSERVINIT )()
 Initializer of a server implementation.

Functions

bool setkillsignalhandler (void(*handler)(int))
 Set the signal handler for termination signals.
bool maskthreadsignal ()
 Set the signal mask of the current to ignore all.
bool daemonize ()
 Switch the process into the background.
int32_t executecommand (const std::vector< std::string > &args)
 Execute a shell command.
const char * strmapget (const std::map< std::string, std::string > &map, const char *key, size_t *sp=NULL)
 Get the C-style string value of a record in a string map.
void printstrvec (const std::vector< std::string > &vec, std::ostream &strm=std::cout)
 Print all records in a string vector.
void printstrmap (const std::map< std::string, std::string > &map, std::ostream &strm=std::cout)
 Print all records in a string map.
void urlbreak (const char *url, std::map< std::string, std::string > *elems)
 Break up a URL into elements.
char * xmlescape (const char *str)
 Escape meta characters in a string with the entity references of XML.
char * xmlunescape (const char *str)
 Unescape meta characters in a string with the entity references of XML.
void wwwformtomap (const std::string &str, std::map< std::string, std::string > *map)
 Parse a www-form-urlencoded string and store each records into a map.
void maptowwwform (const std::map< std::string, std::string > &map, std::string *str)
 Serialize a string map into a www-form-urlencoded string.
void tsvtomap (const std::string &str, std::map< std::string, std::string > *map)
 Parse a TSV string and store each records into a map.
void maptotsv (const std::map< std::string, std::string > &map, std::string *str)
 Serialize a string map into a TSV string.
void tsvmapencode (std::map< std::string, std::string > *map, int32_t mode)
 Encode each record of a string map.
void tsvmapdecode (std::map< std::string, std::string > *map, int32_t mode)
 Decode each record of a string map.
int32_t checkmapenc (const std::map< std::string, std::string > &map)
 Check the best suited encoding of a string map.
char * strcapitalize (char *str)
 Capitalize letters of a string.
bool strisalnum (const char *str)
 Check a string is composed of alphabets or numbers only.
void strtokenize (const char *str, std::vector< std::string > *tokens)
 Tokenize a string separating by space characters.
void getcalendar (int64_t t, int32_t jl, int32_t *yearp=NULL, int32_t *monp=NULL, int32_t *dayp=NULL, int32_t *hourp=NULL, int32_t *minp=NULL, int32_t *secp=NULL)
 Get the Gregorian calendar of a time.
void datestrwww (int64_t t, int32_t jl, char *buf)
 Format a date as a string in W3CDTF.
void datestrwww (double t, int32_t jl, int32_t acr, char *buf)
 Format a date as a string in W3CDTF with the fraction part.
void datestrhttp (int64_t t, int32_t jl, char *buf)
 Format a date as a string in RFC 1123 format.
int64_t strmktime (const char *str)
 Get the time value of a date string.
int32_t jetlag ()
 Get the jet lag of the local time.
int32_t dayofweek (int32_t year, int32_t mon, int32_t day)
 Get the day of week of a date.
bool getlocaltime (time_t time, struct std::tm *result)
 Get the local time of a time.
bool getgmtime (time_t time, struct std::tm *result)
 Get the GMT local time of a time.
time_t mkgmtime (struct std::tm *tm)
 Make the GMT from a time structure.

Variables

const char *const KTDBINITNAME = "ktdbinit"
 The name of the initializer function.
const char *const KTSERVINITNAME = "ktservinit"
 The name of the initializer function.
const char *const VERSION
 The package version.
const int32_t LIBVER
 The library version.
const int32_t LIBREV
 The library revision.
const char *const FEATURES
 The extra feature list.
const int32_t DEFPORT = 1978
 The default port number.

Detailed Description

All symbols of Kyoto Tycoon.

Common namespace of Kyoto Tycoon.


Typedef Documentation

Initializer of a database implementation.

Note:
Each shared library of a pluggable database module must implement a function whose name is "ktdbinit" and return a new instance of a derived class of the PluggableDB class. The instance will be deleted implicitly by the caller.

Initializer of a server implementation.

Note:
Each shared library of a pluggable server module must implement a function whose name is "ktservinit" and return a new instance of a derived class of the PluggableServer class. The instance will be deleted implicitly by the caller.

Function Documentation

bool kyototycoon::setkillsignalhandler ( void(*)(int)  handler)

Set the signal handler for termination signals.

Parameters:
handlerthe function pointer of the signal handler.
Returns:
true on success, or false on failure.

Set the signal mask of the current to ignore all.

Returns:
true on success, or false on failure.

Switch the process into the background.

Returns:
true on success, or false on failure.
int32_t kyototycoon::executecommand ( const std::vector< std::string > &  args)

Execute a shell command.

Parameters:
argsan array of the command name and its arguments.
Returns:
the exit code of the command or `INT32_MIN' on failure.
Note:
The command name and the arguments are quoted and meta characters are escaped.
const char * kyototycoon::strmapget ( const std::map< std::string, std::string > &  map,
const char *  key,
size_t *  sp = NULL 
)

Get the C-style string value of a record in a string map.

Parameters:
mapthe target string map.
keythe key.
spthe pointer to the variable into which the size of the region of the return value is assigned. If it is NULL, it is ignored.
Returns:
the C-style string value of the corresponding record, or NULL if there is no corresponding record.
void kyototycoon::printstrvec ( const std::vector< std::string > &  vec,
std::ostream &  strm = std::cout 
)

Print all records in a string vector.

Parameters:
vecthe target string vector.
strmthe output stream.
void kyototycoon::printstrmap ( const std::map< std::string, std::string > &  map,
std::ostream &  strm = std::cout 
)

Print all records in a string map.

Parameters:
mapthe target string map.
strmthe output stream.
void kyototycoon::urlbreak ( const char *  url,
std::map< std::string, std::string > *  elems 
)

Break up a URL into elements.

Parameters:
urlthe URL string.
elemsthe map object to contain the result elements. The key "self" indicates the URL itself. "scheme" indicates the scheme. "host" indicates the host of the server. "port" indicates the port number of the server. "authority" indicates the authority information. "path" indicates the path of the resource. "file" indicates the file name without the directory section. "query" indicates the query string. "fragment" indicates the fragment string.
Note:
Supported schema are HTTP, HTTPS, FTP, and FILE. Both of absolute URL and relative URL are supported.
char * kyototycoon::xmlescape ( const char *  str)

Escape meta characters in a string with the entity references of XML.

Parameters:
strthe string.
Returns:
the escaped string.
Note:
Because the region of the return value is allocated with the the new[] operator, it should be released with the delete[] operator when it is no longer in use.
char * kyototycoon::xmlunescape ( const char *  str)

Unescape meta characters in a string with the entity references of XML.

Parameters:
strthe string.
Returns:
the unescaped string.
Note:
Because the region of the return value is allocated with the the new[] operator, it should be released with the delete[] operator when it is no longer in use.
void kyototycoon::wwwformtomap ( const std::string &  str,
std::map< std::string, std::string > *  map 
)

Parse a www-form-urlencoded string and store each records into a map.

Parameters:
strthe source string.
mapthe destination string map.
void kyototycoon::maptowwwform ( const std::map< std::string, std::string > &  map,
std::string *  str 
)

Serialize a string map into a www-form-urlencoded string.

Parameters:
mapthe source string map.
strthe destination string.
void kyototycoon::tsvtomap ( const std::string &  str,
std::map< std::string, std::string > *  map 
)

Parse a TSV string and store each records into a map.

Parameters:
strthe source string.
mapthe destination string map.
void kyototycoon::maptotsv ( const std::map< std::string, std::string > &  map,
std::string *  str 
)

Serialize a string map into a TSV string.

Parameters:
mapthe source string map.
strthe destination string.
void kyototycoon::tsvmapencode ( std::map< std::string, std::string > *  map,
int32_t  mode 
)

Encode each record of a string map.

Parameters:
mapthe string map.
modethe encoding mode. 'B' for Base64 encoding, 'Q' for Quoted-printable encoding, 'U' for URL encoding.
void kyototycoon::tsvmapdecode ( std::map< std::string, std::string > *  map,
int32_t  mode 
)

Decode each record of a string map.

Parameters:
mapthe string map.
modethe encoding mode. 'B' for Base64 encoding, 'Q' for Quoted-printable encoding, 'U' for URL encoding.
int32_t kyototycoon::checkmapenc ( const std::map< std::string, std::string > &  map)

Check the best suited encoding of a string map.

Parameters:
mapthe string map.
Returns:
the the best suited encoding. 0 for the raw format, 'B' for Base64 encoding, 'Q' for Quoted-printable encoding,
char * kyototycoon::strcapitalize ( char *  str)

Capitalize letters of a string.

Parameters:
strthe string to convert.
Returns:
the string itself.
bool kyototycoon::strisalnum ( const char *  str)

Check a string is composed of alphabets or numbers only.

Returns:
true if it is composed of alphabets or numbers only, or false if not.
void kyototycoon::strtokenize ( const char *  str,
std::vector< std::string > *  tokens 
)

Tokenize a string separating by space characters.

Parameters:
strthe source string.
tokensa string vector to contain the result tokens.
void kyototycoon::getcalendar ( int64_t  t,
int32_t  jl,
int32_t *  yearp = NULL,
int32_t *  monp = NULL,
int32_t *  dayp = NULL,
int32_t *  hourp = NULL,
int32_t *  minp = NULL,
int32_t *  secp = NULL 
)

Get the Gregorian calendar of a time.

Parameters:
tthe source time in seconds from the epoch. If it is kyotocabinet::INT64MAX, the current time is specified.
jlthe jet lag of a location in seconds. If it is kyotocabinet::INT32MAX, the local jet lag is specified.
yearpthe pointer to a variable to which the year is assigned. If it is NULL, it is not used.
monpthe pointer to a variable to which the month is assigned. If it is NULL, it is not used. 1 means January and 12 means December.
daypthe pointer to a variable to which the day of the month is assigned. If it is NULL, it is not used.
hourpthe pointer to a variable to which the hours is assigned. If it is NULL, it is not used.
minpthe pointer to a variable to which the minutes is assigned. If it is NULL, it is not used.
secpthe pointer to a variable to which the seconds is assigned. If it is NULL, it is not used.
void kyototycoon::datestrwww ( int64_t  t,
int32_t  jl,
char *  buf 
)

Format a date as a string in W3CDTF.

Parameters:
tthe source time in seconds from the epoch. If it is kyotocabinet::INT64MAX, the current time is specified.
jlthe jet lag of a location in seconds. If it is kyotocabinet::INT32MAX, the local jet lag is specified.
bufthe pointer to the region into which the result string is written. The size of the buffer should be equal to or more than 48 bytes.
void kyototycoon::datestrwww ( double  t,
int32_t  jl,
int32_t  acr,
char *  buf 
)

Format a date as a string in W3CDTF with the fraction part.

Parameters:
tthe source time in seconds from the epoch. If it is Not-a-Number, the current time is specified.
jlthe jet lag of a location in seconds. If it is kyotocabinet::INT32MAX, the local jet lag is specified.
acrthe accuracy of time by the number of columns of the fraction part.
bufthe pointer to the region into which the result string is written. The size of the buffer should be equal to or more than 48 bytes.
void kyototycoon::datestrhttp ( int64_t  t,
int32_t  jl,
char *  buf 
)

Format a date as a string in RFC 1123 format.

Parameters:
tthe source time in seconds from the epoch. If it is kyotocabinet::INT64MAX, the current time is specified.
jlthe jet lag of a location in seconds. If it is kyotocabinet::INT32MAX, the local jet lag is specified.
bufthe pointer to the region into which the result string is written. The size of the buffer should be equal to or more than 48 bytes.
int64_t kyototycoon::strmktime ( const char *  str)

Get the time value of a date string.

Parameters:
strthe date string in decimal, hexadecimal, W3CDTF, or RFC 822 (1123). Decimal can be trailed by "s" for in seconds, "m" for in minutes, "h" for in hours, and "d" for in days.
Returns:
the time value of the date or INT64_MIN if the format is invalid.
int32_t kyototycoon::jetlag ( )

Get the jet lag of the local time.

Returns:
the jet lag of the local time in seconds.
int32_t kyototycoon::dayofweek ( int32_t  year,
int32_t  mon,
int32_t  day 
)

Get the day of week of a date.

Parameters:
yearthe year of a date.
monthe month of the date.
daythe day of the date.
Returns:
the day of week of the date. 0 means Sunday and 6 means Saturday.
bool kyototycoon::getlocaltime ( time_t  time,
struct std::tm *  result 
)

Get the local time of a time.

Parameters:
timethe time.
resultthe resulb buffer.
Returns:
true on success, or false on failure.
bool kyototycoon::getgmtime ( time_t  time,
struct std::tm *  result 
)

Get the GMT local time of a time.

Parameters:
timethe time.
resultthe resulb buffer.
Returns:
true on success, or false on failure.
time_t kyototycoon::mkgmtime ( struct std::tm *  tm)

Make the GMT from a time structure.

Parameters:
tmthe pointer to the time structure.
Returns:
the GMT.

Variable Documentation

const char* const kyototycoon::KTDBINITNAME = "ktdbinit"

The name of the initializer function.

const char* const kyototycoon::KTSERVINITNAME = "ktservinit"

The name of the initializer function.

const char* const kyototycoon::VERSION

The package version.

const int32_t kyototycoon::LIBVER

The library version.

const int32_t kyototycoon::LIBREV

The library revision.

const char* const kyototycoon::FEATURES

The extra feature list.

const int32_t kyototycoon::DEFPORT = 1978

The default port number.