mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-25 10:09:36 +02:00
minor improvements to documentation and style
This commit is contained in:
@@ -22,10 +22,10 @@ namespace Poco {
|
||||
namespace JSON {
|
||||
|
||||
|
||||
TemplateCache* TemplateCache::_instance = NULL;
|
||||
TemplateCache* TemplateCache::_pInstance = 0;
|
||||
|
||||
|
||||
TemplateCache::TemplateCache() : _logger(NULL)
|
||||
TemplateCache::TemplateCache(): _pLogger(0)
|
||||
{
|
||||
setup();
|
||||
}
|
||||
@@ -33,40 +33,44 @@ TemplateCache::TemplateCache() : _logger(NULL)
|
||||
|
||||
TemplateCache::~TemplateCache()
|
||||
{
|
||||
_instance = NULL;
|
||||
_pInstance = 0;
|
||||
}
|
||||
|
||||
|
||||
void TemplateCache::setup()
|
||||
{
|
||||
poco_assert (_instance == NULL);
|
||||
_instance = this;
|
||||
poco_assert (_pInstance == 0);
|
||||
_pInstance = this;
|
||||
}
|
||||
|
||||
|
||||
Template::Ptr TemplateCache::getTemplate(const Path& path)
|
||||
{
|
||||
if ( _logger )
|
||||
if (_pLogger)
|
||||
{
|
||||
poco_trace_f1(*_logger, "Trying to load %s", path.toString());
|
||||
poco_trace_f1(*_pLogger, "Trying to load %s", path.toString());
|
||||
}
|
||||
|
||||
Path templatePath = resolvePath(path);
|
||||
std::string templatePathname = templatePath.toString();
|
||||
if ( _logger )
|
||||
|
||||
if (_pLogger)
|
||||
{
|
||||
poco_trace_f1(*_logger, "Path resolved to %s", templatePathname);
|
||||
poco_trace_f1(*_pLogger, "Path resolved to %s", templatePathname);
|
||||
}
|
||||
|
||||
File templateFile(templatePathname);
|
||||
|
||||
Template::Ptr tpl;
|
||||
|
||||
std::map<std::string, Template::Ptr>::iterator it = _cache.find(templatePathname);
|
||||
if ( it == _cache.end() )
|
||||
if (it == _cache.end())
|
||||
{
|
||||
if ( templateFile.exists() )
|
||||
if (templateFile.exists())
|
||||
{
|
||||
if ( _logger )
|
||||
if (_pLogger)
|
||||
{
|
||||
poco_information_f1(*_logger, "Loading template %s", templatePath.toString());
|
||||
poco_information_f1(*_pLogger, "Loading template %s", templatePath.toString());
|
||||
}
|
||||
|
||||
tpl = new Template(templatePath);
|
||||
@@ -76,19 +80,19 @@ Template::Ptr TemplateCache::getTemplate(const Path& path)
|
||||
tpl->parse();
|
||||
_cache[templatePathname] = tpl;
|
||||
}
|
||||
catch(JSONTemplateException& jte)
|
||||
catch (JSONTemplateException& jte)
|
||||
{
|
||||
if ( _logger )
|
||||
if (_pLogger)
|
||||
{
|
||||
poco_error_f2(*_logger, "Template %s contains an error: %s", templatePath.toString(), jte.message());
|
||||
poco_error_f2(*_pLogger, "Template %s contains an error: %s", templatePath.toString(), jte.message());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( _logger )
|
||||
if (_pLogger)
|
||||
{
|
||||
poco_error_f1(*_logger, "Template file %s doesn't exist", templatePath.toString());
|
||||
poco_error_f1(*_pLogger, "Template file %s doesn't exist", templatePath.toString());
|
||||
}
|
||||
throw FileNotFoundException(templatePathname);
|
||||
}
|
||||
@@ -96,11 +100,11 @@ Template::Ptr TemplateCache::getTemplate(const Path& path)
|
||||
else
|
||||
{
|
||||
tpl = it->second;
|
||||
if ( tpl->parseTime() < templateFile.getLastModified() )
|
||||
if (tpl->parseTime() < templateFile.getLastModified())
|
||||
{
|
||||
if ( _logger )
|
||||
if (_pLogger)
|
||||
{
|
||||
poco_information_f1(*_logger, "Reloading template %s", templatePath.toString());
|
||||
poco_information_f1(*_pLogger, "Reloading template %s", templatePath.toString());
|
||||
}
|
||||
|
||||
tpl = new Template(templatePath);
|
||||
@@ -110,11 +114,11 @@ Template::Ptr TemplateCache::getTemplate(const Path& path)
|
||||
tpl->parse();
|
||||
_cache[templatePathname] = tpl;
|
||||
}
|
||||
catch(JSONTemplateException& jte)
|
||||
catch (JSONTemplateException& jte)
|
||||
{
|
||||
if ( _logger )
|
||||
if (_pLogger)
|
||||
{
|
||||
poco_error_f2(*_logger, "Template %s contains an error: %s", templatePath.toString(), jte.message());
|
||||
poco_error_f2(*_pLogger, "Template %s contains an error: %s", templatePath.toString(), jte.message());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,25 +130,25 @@ Template::Ptr TemplateCache::getTemplate(const Path& path)
|
||||
|
||||
Path TemplateCache::resolvePath(const Path& path) const
|
||||
{
|
||||
if ( path.isAbsolute() )
|
||||
if (path.isAbsolute())
|
||||
return path;
|
||||
|
||||
for(std::vector<Path>::const_iterator it = _includePaths.begin(); it != _includePaths.end(); ++it)
|
||||
for (std::vector<Path>::const_iterator it = _includePaths.begin(); it != _includePaths.end(); ++it)
|
||||
{
|
||||
Path templatePath(*it, path);
|
||||
|
||||
File templateFile(templatePath);
|
||||
if ( templateFile.exists() )
|
||||
if (templateFile.exists())
|
||||
{
|
||||
if ( _logger )
|
||||
if (_pLogger)
|
||||
{
|
||||
poco_trace_f2(*_logger, "%s template file resolved to %s", path.toString(), templatePath.toString());
|
||||
poco_trace_f2(*_pLogger, "%s template file resolved to %s", path.toString(), templatePath.toString());
|
||||
}
|
||||
return templatePath;
|
||||
}
|
||||
if ( _logger )
|
||||
if (_pLogger)
|
||||
{
|
||||
poco_trace_f1(*_logger, "%s doesn't exist", templatePath.toString());
|
||||
poco_trace_f1(*_pLogger, "%s doesn't exist", templatePath.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user