diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp | 258 |
1 files changed, 129 insertions, 129 deletions
diff --git a/contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp b/contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp index 020f5f0620..dcbae13a0a 100644 --- a/contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp +++ b/contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp @@ -1,129 +1,129 @@ -// -// NestedDiagnosticContext.cpp -// -// Library: Foundation -// Package: Core -// Module: NestedDiagnosticContext -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/NestedDiagnosticContext.h" -#include "Poco/SingletonHolder.h" -#include "Poco/ThreadLocal.h" - - -namespace Poco { - - -NestedDiagnosticContext::NestedDiagnosticContext() -{ -} - - -NestedDiagnosticContext::NestedDiagnosticContext(const NestedDiagnosticContext& ctx) -{ - _stack = ctx._stack; -} - - -NestedDiagnosticContext::~NestedDiagnosticContext() -{ -} - - -NestedDiagnosticContext& NestedDiagnosticContext::operator = (const NestedDiagnosticContext& ctx) -{ - if (&ctx != this) - _stack = ctx._stack; - return *this; -} - - -void NestedDiagnosticContext::push(const std::string& info) -{ - Context ctx; - ctx.info = info; - ctx.line = -1; - ctx.file = 0; - _stack.push_back(ctx); -} - - -void NestedDiagnosticContext::push(const std::string& info, int line, const char* filename) -{ - Context ctx; - ctx.info = info; - ctx.line = line; - ctx.file = filename; - _stack.push_back(ctx); -} - - -void NestedDiagnosticContext::pop() -{ - if (!_stack.empty()) - _stack.pop_back(); -} - - -int NestedDiagnosticContext::depth() const -{ - return int(_stack.size()); -} - - -std::string NestedDiagnosticContext::toString() const -{ - std::string result; - for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it) - { - if (!result.empty()) - result.append(":"); - result.append(it->info); - } - return result; -} - - -void NestedDiagnosticContext::dump(std::ostream& ostr) const -{ - dump(ostr, "\n"); -} - - -void NestedDiagnosticContext::dump(std::ostream& ostr, const std::string& delimiter) const -{ - for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it) - { - ostr << it->info; - if (it->file) - ostr << " (in \"" << it->file << "\", line " << it->line << ")"; - ostr << delimiter; - } -} - - -void NestedDiagnosticContext::clear() -{ - _stack.clear(); -} - - -namespace -{ - static ThreadLocal<NestedDiagnosticContext> ndc; -} - - -NestedDiagnosticContext& NestedDiagnosticContext::current() -{ - return ndc.get(); -} - - -} // namespace Poco +// +// NestedDiagnosticContext.cpp +// +// Library: Foundation +// Package: Core +// Module: NestedDiagnosticContext +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/NestedDiagnosticContext.h" +#include "Poco/SingletonHolder.h" +#include "Poco/ThreadLocal.h" + + +namespace Poco { + + +NestedDiagnosticContext::NestedDiagnosticContext() +{ +} + + +NestedDiagnosticContext::NestedDiagnosticContext(const NestedDiagnosticContext& ctx) +{ + _stack = ctx._stack; +} + + +NestedDiagnosticContext::~NestedDiagnosticContext() +{ +} + + +NestedDiagnosticContext& NestedDiagnosticContext::operator = (const NestedDiagnosticContext& ctx) +{ + if (&ctx != this) + _stack = ctx._stack; + return *this; +} + + +void NestedDiagnosticContext::push(const std::string& info) +{ + Context ctx; + ctx.info = info; + ctx.line = -1; + ctx.file = 0; + _stack.push_back(ctx); +} + + +void NestedDiagnosticContext::push(const std::string& info, int line, const char* filename) +{ + Context ctx; + ctx.info = info; + ctx.line = line; + ctx.file = filename; + _stack.push_back(ctx); +} + + +void NestedDiagnosticContext::pop() +{ + if (!_stack.empty()) + _stack.pop_back(); +} + + +int NestedDiagnosticContext::depth() const +{ + return int(_stack.size()); +} + + +std::string NestedDiagnosticContext::toString() const +{ + std::string result; + for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it) + { + if (!result.empty()) + result.append(":"); + result.append(it->info); + } + return result; +} + + +void NestedDiagnosticContext::dump(std::ostream& ostr) const +{ + dump(ostr, "\n"); +} + + +void NestedDiagnosticContext::dump(std::ostream& ostr, const std::string& delimiter) const +{ + for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it) + { + ostr << it->info; + if (it->file) + ostr << " (in \"" << it->file << "\", line " << it->line << ")"; + ostr << delimiter; + } +} + + +void NestedDiagnosticContext::clear() +{ + _stack.clear(); +} + + +namespace +{ + static ThreadLocal<NestedDiagnosticContext> ndc; +} + + +NestedDiagnosticContext& NestedDiagnosticContext::current() +{ + return ndc.get(); +} + + +} // namespace Poco |