2014-10-20 18:37:19 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
|
|
|
* Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "cli/repositoryutility.hpp"
|
|
|
|
#include "cli/clicommand.hpp"
|
|
|
|
#include "base/logger.hpp"
|
|
|
|
#include "base/application.hpp"
|
|
|
|
#include "base/convert.hpp"
|
2014-10-26 19:59:49 +01:00
|
|
|
#include "base/json.hpp"
|
2014-10-20 18:37:19 +02:00
|
|
|
#include "base/netstring.hpp"
|
|
|
|
#include "base/stdiostream.hpp"
|
|
|
|
#include "base/debug.hpp"
|
|
|
|
#include "base/objectlock.hpp"
|
|
|
|
#include "base/console.hpp"
|
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
#include <boost/algorithm/string/join.hpp>
|
2014-10-23 19:07:14 +02:00
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
2014-10-24 12:42:57 +02:00
|
|
|
#include <boost/algorithm/string/split.hpp>
|
|
|
|
#include <boost/algorithm/string/classification.hpp>
|
2014-10-20 18:37:19 +02:00
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2014-10-24 12:42:57 +02:00
|
|
|
Dictionary::Ptr RepositoryUtility::GetArgumentAttributes(const std::vector<std::string>& arguments)
|
|
|
|
{
|
|
|
|
Dictionary::Ptr attr = make_shared<Dictionary>();
|
|
|
|
|
|
|
|
BOOST_FOREACH(const String& kv, arguments) {
|
|
|
|
std::vector<String> tokens;
|
|
|
|
boost::algorithm::split(tokens, kv, boost::is_any_of("="));
|
|
|
|
|
|
|
|
if (tokens.size() == 2) {
|
|
|
|
attr->Set(tokens[0], tokens[1]);
|
|
|
|
} else
|
|
|
|
Log(LogWarning, "cli")
|
|
|
|
<< "Cannot parse passed attributes: " << boost::algorithm::join(tokens, "=");
|
|
|
|
}
|
|
|
|
|
|
|
|
return attr;
|
|
|
|
}
|
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
String RepositoryUtility::GetRepositoryConfigPath(void)
|
2014-10-20 18:37:19 +02:00
|
|
|
{
|
|
|
|
return Application::GetSysconfDir() + "/icinga2/repository.d";
|
|
|
|
}
|
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
String RepositoryUtility::GetRepositoryObjectConfigPath(const String& type, const Dictionary::Ptr& object)
|
2014-10-20 18:37:19 +02:00
|
|
|
{
|
2014-10-24 15:27:20 +02:00
|
|
|
String path = GetRepositoryConfigPath() + "/";
|
|
|
|
|
|
|
|
if (type == "Host") {
|
|
|
|
path += "hosts";
|
|
|
|
}
|
2014-10-20 18:37:19 +02:00
|
|
|
else if (type == "Service")
|
2014-10-24 15:27:20 +02:00
|
|
|
path += "hosts/" + object->Get("host_name");
|
2014-10-20 18:37:19 +02:00
|
|
|
else if (type == "Zone")
|
2014-10-24 15:27:20 +02:00
|
|
|
path += "zones";
|
2014-10-20 18:37:19 +02:00
|
|
|
else if (type == "Endpoints")
|
2014-10-24 15:27:20 +02:00
|
|
|
path += "endpoints";
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
String RepositoryUtility::GetRepositoryObjectConfigFilePath(const String& type, const Dictionary::Ptr& object)
|
|
|
|
{
|
|
|
|
String path = GetRepositoryObjectConfigPath(type, object);
|
|
|
|
|
|
|
|
path += "/" + object->Get("name") + ".conf";
|
|
|
|
|
|
|
|
return path;
|
2014-10-20 18:37:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
String RepositoryUtility::GetRepositoryChangeLogPath(void)
|
|
|
|
{
|
2014-10-24 15:27:20 +02:00
|
|
|
return Application::GetLocalStateDir() + "/lib/icinga2/repository/changes";
|
2014-10-20 18:37:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RepositoryUtility::PrintObjects(std::ostream& fp, const String& type)
|
|
|
|
{
|
2014-10-24 15:27:20 +02:00
|
|
|
std::vector<String> objects = GetObjects(); //full path
|
2014-10-20 18:37:19 +02:00
|
|
|
|
|
|
|
BOOST_FOREACH(const String& object, objects) {
|
2014-10-24 15:27:20 +02:00
|
|
|
Dictionary::Ptr obj = GetObjectFromRepository(object);
|
2014-10-20 18:37:19 +02:00
|
|
|
|
|
|
|
if (obj) {
|
|
|
|
fp << "Object Name: " << object << "\n";
|
2014-10-26 19:59:49 +01:00
|
|
|
fp << JsonEncode(obj);
|
2014-10-20 18:37:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* public interface, only logs changes */
|
|
|
|
bool RepositoryUtility::AddObject(const String& name, const String& type, const Dictionary::Ptr& attr)
|
|
|
|
{
|
|
|
|
/* add a new changelog entry by timestamp */
|
|
|
|
String path = GetRepositoryChangeLogPath() + "/" + Convert::ToString(static_cast<long>(Utility::GetTime())) + ".change";
|
|
|
|
|
|
|
|
Dictionary::Ptr change = make_shared<Dictionary>();
|
|
|
|
|
|
|
|
change->Set("timestamp", Utility::GetTime());
|
|
|
|
change->Set("name", name);
|
|
|
|
change->Set("type", type);
|
|
|
|
change->Set("command", "add");
|
|
|
|
change->Set("attr", attr);
|
|
|
|
|
|
|
|
return WriteObjectToRepositoryChangeLog(path, change);
|
|
|
|
}
|
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
bool RepositoryUtility::RemoveObject(const String& name, const String& type, const Dictionary::Ptr& attr)
|
2014-10-20 18:37:19 +02:00
|
|
|
{
|
|
|
|
/* add a new changelog entry by timestamp */
|
|
|
|
String path = GetRepositoryChangeLogPath() + "/" + Convert::ToString(static_cast<long>(Utility::GetTime())) + ".change";
|
|
|
|
|
|
|
|
Dictionary::Ptr change = make_shared<Dictionary>();
|
|
|
|
|
|
|
|
change->Set("timestamp", Utility::GetTime());
|
|
|
|
change->Set("name", name);
|
|
|
|
change->Set("type", type);
|
|
|
|
change->Set("command", "remove");
|
2014-10-24 15:27:20 +02:00
|
|
|
change->Set("attr", attr); //required for service->host_name
|
2014-10-20 18:37:19 +02:00
|
|
|
|
|
|
|
return WriteObjectToRepositoryChangeLog(path, change);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RepositoryUtility::CommitChangeLog(void)
|
|
|
|
{
|
|
|
|
GetChangeLog(boost::bind(RepositoryUtility::CommitChange, _1));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RepositoryUtility::PrintChangeLog(std::ostream& fp)
|
|
|
|
{
|
|
|
|
Array::Ptr changelog = make_shared<Array>();
|
|
|
|
|
|
|
|
GetChangeLog(boost::bind(RepositoryUtility::CollectChange, _1, boost::ref(changelog)));
|
|
|
|
|
|
|
|
ObjectLock olock(changelog);
|
|
|
|
|
|
|
|
std::cout << "Changes to be committed:\n";
|
|
|
|
|
|
|
|
BOOST_FOREACH(const Value& entry, changelog) {
|
2014-10-26 19:59:49 +01:00
|
|
|
std::cout << JsonEncode(entry) << "\n"; //TODO better formatting
|
2014-10-20 18:37:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RepositoryUtility::SetObjectAttribute(const String& name, const String& type, const String& attr, const Value& val)
|
|
|
|
{
|
|
|
|
//TODO: Implement modification commands
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* internal implementation when changes are committed */
|
|
|
|
bool RepositoryUtility::AddObjectInternal(const String& name, const String& type, const Dictionary::Ptr& attr)
|
|
|
|
{
|
2014-10-24 15:27:20 +02:00
|
|
|
String path = GetRepositoryObjectConfigPath(type, attr) + "/" + name + ".conf";
|
2014-10-20 18:37:19 +02:00
|
|
|
|
|
|
|
return WriteObjectToRepository(path, name, type, attr);
|
|
|
|
}
|
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
bool RepositoryUtility::RemoveObjectInternal(const String& name, const String& type, const Dictionary::Ptr& attr)
|
2014-10-20 18:37:19 +02:00
|
|
|
{
|
2014-10-24 15:27:20 +02:00
|
|
|
String path = GetRepositoryObjectConfigPath(type, attr) + "/" + name + ".conf";
|
2014-10-20 18:37:19 +02:00
|
|
|
|
|
|
|
return RemoveObjectFileInternal(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RepositoryUtility::RemoveObjectFileInternal(const String& path)
|
|
|
|
{
|
|
|
|
if (!Utility::PathExists(path) ) {
|
|
|
|
Log(LogCritical, "cli", "Cannot remove '" + path + "'. Does not exist.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlink(path.CStr()) < 0) {
|
|
|
|
Log(LogCritical, "cli", "Cannot remove file '" + path +
|
|
|
|
"'. Failed with error code " + Convert::ToString(errno) + ", \"" + Utility::FormatErrorNumber(errno) + "\".");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
bool RepositoryUtility::SetObjectAttributeInternal(const String& name, const String& type, const String& key, const Value& val, const Dictionary::Ptr& attr)
|
2014-10-20 18:37:19 +02:00
|
|
|
{
|
|
|
|
//Fixme
|
2014-10-24 15:27:20 +02:00
|
|
|
String path = GetRepositoryObjectConfigPath(type, attr) + "/" + name + ".conf";
|
2014-10-20 18:37:19 +02:00
|
|
|
|
|
|
|
Dictionary::Ptr obj = GetObjectFromRepository(path);
|
|
|
|
|
|
|
|
if (!obj) {
|
|
|
|
Log(LogCritical, "cli")
|
|
|
|
<< "Can't get object " << name << " from repository.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
obj->Set(key, val);
|
2014-10-20 18:37:19 +02:00
|
|
|
|
|
|
|
std::cout << "Writing object '" << name << "' to path '" << path << "'.\n";
|
|
|
|
|
|
|
|
//TODO: Create a patch file
|
|
|
|
if(!WriteObjectToRepository(path, name, type, obj)) {
|
|
|
|
Log(LogCritical, "cli")
|
|
|
|
<< "Can't write object " << name << " to repository.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RepositoryUtility::WriteObjectToRepository(const String& path, const String& name, const String& type, const Dictionary::Ptr& item)
|
|
|
|
{
|
|
|
|
Log(LogInformation, "cli", "Dumping config items to file '" + path + "'");
|
|
|
|
|
|
|
|
Utility::MkDirP(Utility::DirName(path), 0755);
|
|
|
|
|
|
|
|
String tempPath = path + ".tmp";
|
|
|
|
|
|
|
|
std::ofstream fp(tempPath.CStr(), std::ofstream::out | std::ostream::trunc);
|
|
|
|
SerializeObject(fp, name, type, item);
|
|
|
|
fp << std::endl;
|
|
|
|
fp.close();
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2014-10-23 19:07:14 +02:00
|
|
|
_unlink(path.CStr());
|
2014-10-20 18:37:19 +02:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
|
|
|
if (rename(tempPath.CStr(), path.CStr()) < 0) {
|
|
|
|
BOOST_THROW_EXCEPTION(posix_error()
|
|
|
|
<< boost::errinfo_api_function("rename")
|
|
|
|
<< boost::errinfo_errno(errno)
|
|
|
|
<< boost::errinfo_file_name(tempPath));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr RepositoryUtility::GetObjectFromRepository(const String& filename)
|
|
|
|
{
|
|
|
|
//TODO: Parse existing configuration objects
|
|
|
|
return Dictionary::Ptr();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RepositoryUtility::WriteObjectToRepositoryChangeLog(const String& path, const Dictionary::Ptr& item)
|
|
|
|
{
|
|
|
|
Log(LogInformation, "cli", "Dumping changelog items to file '" + path + "'");
|
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
Utility::MkDirP(Utility::DirName(path), 0750);
|
2014-10-20 18:37:19 +02:00
|
|
|
|
|
|
|
String tempPath = path + ".tmp";
|
|
|
|
|
|
|
|
std::ofstream fp(tempPath.CStr(), std::ofstream::out | std::ostream::trunc);
|
2014-10-26 19:59:49 +01:00
|
|
|
fp << JsonEncode(item);
|
2014-10-20 18:37:19 +02:00
|
|
|
fp.close();
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2014-10-23 19:07:14 +02:00
|
|
|
_unlink(path.CStr());
|
2014-10-20 18:37:19 +02:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
|
|
|
if (rename(tempPath.CStr(), path.CStr()) < 0) {
|
|
|
|
BOOST_THROW_EXCEPTION(posix_error()
|
|
|
|
<< boost::errinfo_api_function("rename")
|
|
|
|
<< boost::errinfo_errno(errno)
|
|
|
|
<< boost::errinfo_file_name(tempPath));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr RepositoryUtility::GetObjectFromRepositoryChangeLog(const String& filename)
|
|
|
|
{
|
|
|
|
std::fstream fp;
|
|
|
|
fp.open(filename.CStr(), std::ifstream::in);
|
|
|
|
|
|
|
|
if (!fp)
|
|
|
|
return Dictionary::Ptr();
|
|
|
|
|
|
|
|
String content((std::istreambuf_iterator<char>(fp)), std::istreambuf_iterator<char>());
|
|
|
|
|
|
|
|
fp.close();
|
|
|
|
|
2014-10-26 19:59:49 +01:00
|
|
|
return JsonDecode(content);
|
2014-10-20 18:37:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* collect functions
|
|
|
|
*/
|
2014-10-24 15:27:20 +02:00
|
|
|
std::vector<String> RepositoryUtility::GetObjects(void)
|
2014-10-20 18:37:19 +02:00
|
|
|
{
|
2014-10-24 15:27:20 +02:00
|
|
|
std::vector<String> objects;
|
|
|
|
String path = GetRepositoryConfigPath() + "/";
|
2014-10-20 18:37:19 +02:00
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
Utility::Glob(path + "/*.conf",
|
|
|
|
boost::bind(&RepositoryUtility::CollectObjects, _1, boost::ref(objects)), GlobFile);
|
2014-10-20 18:37:19 +02:00
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
return objects;
|
2014-10-20 18:37:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RepositoryUtility::CollectObjects(const String& object_file, std::vector<String>& objects)
|
|
|
|
{
|
2014-10-24 15:27:20 +02:00
|
|
|
Log(LogDebug, "cli")
|
|
|
|
<< "Adding object: '" << object_file << "'.";
|
2014-10-20 18:37:19 +02:00
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
objects.push_back(object_file);
|
2014-10-20 18:37:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool RepositoryUtility::GetChangeLog(const boost::function<void (const Dictionary::Ptr&)>& callback)
|
|
|
|
{
|
|
|
|
std::vector<String> changelog;
|
|
|
|
String path = GetRepositoryChangeLogPath() + "/";
|
|
|
|
|
2014-10-24 15:27:20 +02:00
|
|
|
Utility::Glob(path + "/*.change",
|
|
|
|
boost::bind(&RepositoryUtility::CollectChangeLog, _1, boost::ref(changelog)), GlobFile);
|
2014-10-20 18:37:19 +02:00
|
|
|
|
|
|
|
/* sort by timestamp ascending */
|
|
|
|
std::sort(changelog.begin(), changelog.end());
|
|
|
|
|
|
|
|
BOOST_FOREACH(const String& entry, changelog) {
|
|
|
|
Dictionary::Ptr change = GetObjectFromRepositoryChangeLog(path + entry + ".change");
|
|
|
|
|
|
|
|
Log(LogInformation, "cli")
|
|
|
|
<< "Collecting entry " << entry << "\n";
|
|
|
|
|
|
|
|
if (change)
|
|
|
|
callback(change);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RepositoryUtility::CollectChangeLog(const String& change_file, std::vector<String>& changelog)
|
|
|
|
{
|
|
|
|
String file = Utility::BaseName(change_file);
|
|
|
|
boost::algorithm::replace_all(file, ".change", "");
|
|
|
|
|
|
|
|
Log(LogDebug, "cli", "Adding change file: " + file);
|
|
|
|
changelog.push_back(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RepositoryUtility::CommitChange(const Dictionary::Ptr& change)
|
|
|
|
{
|
|
|
|
Log(LogInformation, "cli")
|
|
|
|
<< "Got change " << change->Get("name");
|
|
|
|
|
|
|
|
String name = change->Get("name");
|
|
|
|
String type = change->Get("type");
|
|
|
|
String command = change->Get("command");
|
|
|
|
Dictionary::Ptr attr;
|
|
|
|
|
|
|
|
if (change->Contains("attr")) {
|
|
|
|
attr = change->Get("attr");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command == "add") {
|
|
|
|
AddObjectInternal(name, type, attr);
|
|
|
|
}
|
|
|
|
else if (command == "remove") {
|
2014-10-24 15:27:20 +02:00
|
|
|
RemoveObjectInternal(name, type, attr);
|
2014-10-20 18:37:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RepositoryUtility::CollectChange(const Dictionary::Ptr& change, Array::Ptr& changes)
|
|
|
|
{
|
|
|
|
changes->Add(change);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* print helpers for configuration
|
|
|
|
* TODO: Move into a separate class
|
|
|
|
*/
|
|
|
|
void RepositoryUtility::SerializeObject(std::ostream& fp, const String& name, const String& type, const Dictionary::Ptr& object)
|
|
|
|
{
|
|
|
|
fp << "object " << type << " \"" << name << "\" {\n";
|
2014-10-23 19:06:02 +02:00
|
|
|
|
2014-10-23 20:42:56 +02:00
|
|
|
if (!object) {
|
|
|
|
fp << "}\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-24 12:42:57 +02:00
|
|
|
if (object->Contains("import")) {
|
|
|
|
Array::Ptr imports = object->Get("import");
|
2014-10-23 20:42:56 +02:00
|
|
|
|
2014-10-24 12:42:57 +02:00
|
|
|
ObjectLock olock(imports);
|
|
|
|
BOOST_FOREACH(const String& import, imports) {
|
|
|
|
fp << "\t" << "import \"" << import << "\"\n";
|
2014-10-23 20:42:56 +02:00
|
|
|
}
|
|
|
|
}
|
2014-10-23 19:06:02 +02:00
|
|
|
|
2014-10-20 18:37:19 +02:00
|
|
|
BOOST_FOREACH(const Dictionary::Pair& kv, object) {
|
2014-10-24 15:27:20 +02:00
|
|
|
if (kv.first == "import" || kv.first == "name") {
|
2014-10-23 19:06:02 +02:00
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
fp << "\t" << kv.first << " = ";
|
|
|
|
FormatValue(fp, kv.second);
|
|
|
|
}
|
2014-10-20 18:37:19 +02:00
|
|
|
fp << "\n";
|
|
|
|
}
|
|
|
|
fp << "}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void RepositoryUtility::FormatValue(std::ostream& fp, const Value& val)
|
|
|
|
{
|
|
|
|
if (val.IsObjectType<Array>()) {
|
|
|
|
FormatArray(fp, val);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val.IsString()) {
|
|
|
|
fp << "\"" << Convert::ToString(val) << "\"";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fp << Convert::ToString(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RepositoryUtility::FormatArray(std::ostream& fp, const Array::Ptr& arr)
|
|
|
|
{
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
fp << "[ ";
|
|
|
|
|
|
|
|
if (arr) {
|
|
|
|
ObjectLock olock(arr);
|
|
|
|
BOOST_FOREACH(const Value& value, arr) {
|
|
|
|
if (first)
|
|
|
|
first = false;
|
|
|
|
else
|
|
|
|
fp << ", ";
|
|
|
|
|
|
|
|
FormatValue(fp, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!first)
|
|
|
|
fp << " ";
|
|
|
|
|
|
|
|
fp << "]";
|
|
|
|
}
|