( !
value.empty() ) {
109 if( stat.
empty() ) {
112 boolphid_present =
false;
117phid_present =
true;
123 if( !phid_present && !phid.empty() ) {
146: m_CgiApplication(application),
179 return(
i->second)->MapTag(
this, name);
232 const string& title,
const string& template_file)
233:
CParent(application, style),
260 if( !create_on_print ) {
310 string* pstr = &
str;
319 if(
i!= cache.
end() ) {
353unique_ptr<CHTMLText> node(
new CHTMLText(*pstr));
357 returnnode.release();
366 "CHTMLPage::x_LoadTemplate(): failed to open template");
376 "CHTMLPage::x_LoadTemplate(): failed to "\
382+
" too big to handle");
391is.read(
buf,
sizeof(
buf));
393&&
str.size() ==
str.capacity()) {
404 "CHTMLPage::x_LoadTemplate(): error reading template");
414 "CHTMLPage::x_PrintTemplate(): failed to open template");
418 "CHTMLPage::x_PrintTemplate(): "\
419 "output stream must be specified");
424unique_ptr<CNCBINode> node(
new CNCBINode);
427is.read(
buf,
sizeof(
buf));
434node->AppendChild(child);
438 if( !
str.empty() ) {
441node->AppendChild(child);
446 "CHTMLPage::x_PrintTemplate(): error reading template");
449 returnnode.release();
475 if( start >= s.size() ) {
478 const char* cstr = s.c_str();
479 const char* p = strstr(cstr + start, target);
480 returnp ? p - cstr :
NPOS;
485 booltemplate_applicable =
true;
487 while(*
buffer!=
'\0') {
491 const char* id_begin =
buffer;
500 stringid(id_begin,
buffer- id_begin);
502 charbracket_stack[
sizeof(long)];
503 char* bracket_stack_pos = bracket_stack +
sizeof(bracket_stack) - 1;
505*bracket_stack_pos =
'\0';
508 charclosing_bracket;
511closing_bracket =
')';
512 else if(*
buffer==
'<')
513closing_bracket =
'>';
514 else if(*
buffer==
'{')
515closing_bracket =
'}';
519 if(bracket_stack_pos == bracket_stack) {
521 "Bracket nesting is too deep");
524*--bracket_stack_pos = closing_bracket;
528 const char* pattern_end;
530 if((pattern_end = strstr(
buffer, bracket_stack_pos)) ==
NULL) {
532 "Unterminated filter expression");
535 if(template_applicable && (filter ==
NULL||
536!filter->TestAttribute(
id,
string(
buffer, pattern_end))))
537template_applicable =
false;
539 buffer= pattern_end + (bracket_stack +
540 sizeof(bracket_stack) - 1 - bracket_stack_pos);
543 returntemplate_applicable;
551 stringtemplate_buf(
"\n");
552 string* pstr = &template_buf;
553 boolcaching =
false;
554 boolneed_read =
true;
561 if(
i!= cache.
end() ) {
576 if( caching )
deletepstr;
580 "CHTMLPage::x_LoadTemplateLib(): failed to "\
581 "open template file '"+
file_name+
"'");
584 "CHTMLPage::x_LoadTemplateLib(): template "\
586 "' is too big to handle");
594pstr->reserve(
size);
599 static const char*
kInclude=
"#include ";
607 while(pos <
len&&
isspace((
unsigned char)s[pos])) {
611 if(pos <
len&& s[pos] ==
'\"') {
614 if(pos_end ==
NPOS) {
617 stringfname = s.substr(pos, pos_end-pos);
625 "CHTMLPage::x_LoadTemplateLib(): "\
626 "incorrect #include syntax, file '"+
633 if(pstr->size() == pstr->capacity() &&
637pstr->reserve(pstr->size() +
641pstr->append(s +
"\n");
648is->read(
buf,
sizeof(
buf));
649 if(pstr->size() == pstr->capacity() &&
653pstr->reserve(pstr->size() +
662 "CHTMLPage::x_LoadTemplateLib(): "\
663 "error reading template");
675 const stringkTagStartBOL(
string(
"\n") +
kTagStart);
676 SIZE_TYPEts_size = kTagStartBOL.length();
681 while( tag_start !=
NPOS) {
685 SIZE_TYPEname_start = tag_start + ts_size;
687 if( name_end ==
NPOS) {
690 "opening tag \""+ name +
"\" not closed, "\
693 if(name_end != name_start) {
695name = pstr->substr(name_start, name_end - name_start);
697 booltemplate_applicable =
true;
698string::size_type space_pos;
699 if((space_pos = name.find_first_of(
" \t")) != string::npos) {
700template_applicable =
702name.erase(space_pos);
708 if( !name.empty() ) {
715 "closing tag \""+ name +
"\" not closed, "\
718 if( name.empty() ) {
719tag_start =
s_Find(*pstr, kTagStartBOL.c_str(),
725 SIZE_TYPEpos = pstr->find_first_not_of(
" ", tag_end);
726 if(pos !=
NPOS&& (*pstr)[pos] ==
'\n') {
729pos = pstr->find_first_not_of(
" ",
last- 1);
730 if(pos !=
NPOS&& (*pstr)[pos] ==
'\n') {
735 stringsubtemplate = pstr->substr(tag_end,
last- tag_end);
738 if(template_applicable)
742tag_start =
s_Find(*pstr, kTagStartBOL.c_str(),
743 last+ te_size + name.size() + tse_size);
const CHTMLBasicPage & m_Page
virtual CNcbiOstream & PrintBegin(CNcbiOstream &out, TMode mode)
CHTMLPageStat(CHTMLBasicPage &page)
container_type::const_iterator const_iterator
container_type::iterator iterator
const_iterator begin() const
const_iterator end() const
const_iterator find(const key_type &key) const
std::ofstream out("events_result.xml")
main entry point for tests
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static const char * str(char *buf, int n)
void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)
Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
@ eTakeOwnership
An object can take ownership of another.
@ eNoOwnership
No ownership is assumed.
static CRequestContext & GetRequestContext(void)
Shortcut to CDiagContextThreadData::GetThreadData().GetRequestContext()
string GetHitID(void) const
Get explicit hit id or the default one (from HTTP_NCBI_PHID etc).
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Int8 GetLength(void) const
Get size of file.
virtual CNCBINode * MapTag(const string &name)
Resolve <@XXX> tag.
virtual CNCBINode * CreateView(void)
bool x_ApplyFilters(TTemplateLibFilter *filter, const char *buffer)
class CHTMLPage::CTemplateLibFilter TTemplateLibFilter
Interface for a filter, which must be passed to one the LoadTemplateLib methods to select relevant pa...
bool HaveChildren(void) const
ECacheTemplateFiles
Template file caching state.
TMode m_PrintMode
Current print mode (used by RepeatHook).
virtual void SetApplication(CCgiApplication *App)
CNCBINode * x_PrintTemplate(CNcbiIstream &is, CNcbiOstream *out, CNCBINode::TMode mode)
Create and print template.
size_t m_TemplateSize
Size of input, if known (0 otherwise)
virtual void AddTagMap(const string &name, BaseTagMapper *mapper)
Tag mappers.
virtual CNCBINode * CreateTitle(void)
Tag substitution callbacks.
CCgiApplication * m_CgiApplication
Pointer to runtime information.
void x_LoadTemplateLib(CNcbiIstream &is, size_t size, ETemplateIncludes includes, const string &file_name, TTemplateLibFilter *filter)
Load template library.
virtual CNcbiOstream & PrintChildren(CNcbiOstream &out, TMode mode)
CHTMLPage(const string &title=kEmptyStr)
Constructors.
void SetTemplateBuffer(const void *template_buffer, size_t size)
virtual CNCBINode * CreateTemplate(CNcbiOstream *out=0, TMode mode=eHTML)
Create the static part of the page (here - read it from <m_TemplateFile>).
void SetTemplateStream(istream &template_stream)
void SetValue(const string &name, const string &value)
Set new value for the name.
void x_LoadTemplate(CNcbiIstream &is, string &str)
Read template into string.
CNCBINode * AppendChild(CNCBINode *child)
const TData & GetData(void) const
Return the whole internal string map (read-only).
const void * m_TemplateBuffer
Some buffer.
TTagMap m_TagMap
Tag resolvers (as registered by AddTagMap).
void LoadTemplateLibFile(const string &template_file, TTemplateLibFilter *filter=NULL)
Load template library.
void GeneratePageInternalName(const string &template_src)
Generate page internal name on the base of template source.
const string & GetValue(const string &name) const
Get value by name. Return empty string if the name is unknown.
const CPageStat & GetPageStat(void) const
Get CPageStat used to create meta-tags (design ID, hit ID etc.)
virtual CNCBINode * MapTag(const string &tagname)
virtual void CreateSubNodes(void)
Create the individual sub pages.
static void CacheTemplateFiles(ECacheTemplateFiles caching)
Enable/disable template caching.
virtual CNcbiOstream & Print(CNcbiOstream &out, TMode mode=eHTML)
void SetTemplateFile(const string &template_file)
Set source which contains the template.
string m_Title
Page title.
virtual void AddTagMap(const string &name, BaseTagMapper *mapper)
Add tag resolver.
CNcbiOstream & PrintChildren(CNcbiOstream &out, TMode mode)
istream * m_TemplateStream
Stream.
virtual ~CHTMLBasicPage(void)
Dectructor.
virtual CNcbiOstream & PrintBegin(CNcbiOstream &, TMode mode)
CHTMLBasicPage(void)
Default constructor.
static ECacheTemplateFiles sm_CacheTemplateFiles
string m_TemplateFile
Template sources.
@ eCTF_Enable
Enable caching.
@ eCTF_Disable
Disable caching.
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
CNcbiIstream & NcbiGetline(CNcbiIstream &is, string &str, char delim, string::size_type *count=NULL)
Read from "is" to "str" up to the delimiter symbol "delim" (or EOF)
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
NCBI_NS_STD::string::size_type SIZE_TYPE
const char * g_GetNcbiString(ENcbiStrings what)
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
BaseTagMapper * CreateTagMapper(CNCBINode *node)
@ eHTML
HTML tag or, for example, HTML entity.
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
static size_t x_size(const char *dst, size_t len, const char *ptr)
Static variables safety - create on demand, destroy on application termination.
String constants used in NCBI C/C++ toolkit.
Useful/utility classes and methods.
const SIZE_TYPE kBufferSize
const char * kTagStartEnd
const char * kTagStart
Tag delimiters.
static CSafeStatic< TTemplateCache > s_TemplateCache
const char * kTagEnd
Tag end.
static SIZE_TYPE s_Find(const string &s, const char *target, SIZE_TYPE start=0)
map< string, string * > TTemplateCache
Defines CRequestContext class for NCBI C++ diagnostic API.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4