mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-25 06:36:37 +01:00
fix: remove executable flag and change back to 100644 (was 100755) Signed-off-by: Roger Meier <r.meier@siemens.com>
60 lines
930 B
C++
60 lines
930 B
C++
//
|
|
// ObjectId.cpp
|
|
//
|
|
// $Id$
|
|
//
|
|
// Library: MongoDB
|
|
// Package: MongoDB
|
|
// Module: ObjectId
|
|
//
|
|
// Implementation of the ObjectId class.
|
|
//
|
|
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "Poco/MongoDB/ObjectId.h"
|
|
#include "Poco/Format.h"
|
|
|
|
|
|
namespace Poco {
|
|
namespace MongoDB {
|
|
|
|
|
|
ObjectId::ObjectId(const std::string& id)
|
|
{
|
|
if (id.size() == 12)
|
|
{
|
|
std::string::const_iterator it = id.begin();
|
|
std::string::const_iterator end = id.end();
|
|
for (int i = 0; i < 12; ++it, ++i) _id[i] = *it;
|
|
}
|
|
else if (id.size())
|
|
{
|
|
throw Poco::InvalidArgumentException("ID must be 12 characters long.");
|
|
}
|
|
}
|
|
|
|
|
|
ObjectId::~ObjectId()
|
|
{
|
|
}
|
|
|
|
|
|
std::string ObjectId::toString(const std::string& fmt) const
|
|
{
|
|
std::string s;
|
|
|
|
for(int i = 0; i < 12; ++i)
|
|
{
|
|
s += format(fmt, (unsigned int) _id[i]);
|
|
}
|
|
return s;
|
|
}
|
|
|
|
|
|
} } // namespace Poco::MongoDB
|