/*******************************************************************************
***  This file is part of Pecunia.                                           ***
***                                                                          ***
***  Copyright (C) 2017, 2018, 2019, 2020, 2021, 2023                        ***
***  John Schneiderman <Licencing _AT_ Schneiderman _DOT_ me>                ***
***                                                                          ***
***  This program is free software: you can redistribute it and/or modify it ***
***  under the terms of the GNU Lesser General Public License as published   ***
***  by the Free Software Foundation, either version 3 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 Lesser General Public License for more details.             ***
***                                                                          ***
***  You should have received a copy of the GNU Lesser General Public License***
***  along with this program. If not, see <http://www.gnu.org/licenses/>.    ***
*******************************************************************************/
#include "MoneyManip.h"
using std::ios_base;


int pecunia::currency::countryLeadingIndex()
{
	static int index{ios_base::xalloc()};
	return index;
}

int pecunia::currency::useSymbolIndex()
{
	static int index{ios_base::xalloc()};
	return index;
}

int pecunia::currency::spacedIndex()
{
	static int index{ios_base::xalloc()};
	return index;
}

ios_base& pecunia::currency::lead(ios_base& stream) // cppcheck-suppress unusedFunction
{
	stream.iword(pecunia::currency::countryLeadingIndex()) = 1;
	return stream;
}

ios_base& pecunia::currency::trail(ios_base& stream) // cppcheck-suppress unusedFunction
{
	stream.iword(pecunia::currency::countryLeadingIndex()) = 0;
	return stream;
}

ios_base& pecunia::currency::symbol(ios_base& stream) // cppcheck-suppress unusedFunction
{
	stream.iword(pecunia::currency::useSymbolIndex()) = 1;
	return stream;
}

ios_base& pecunia::currency::isocode(ios_base& stream) // cppcheck-suppress unusedFunction
{
	stream.iword(pecunia::currency::useSymbolIndex()) = 0;
	return stream;
}

ios_base& pecunia::currency::spaced(ios_base& stream) // cppcheck-suppress unusedFunction
{
	stream.iword(pecunia::currency::spacedIndex()) = 1;
	return stream;
}

ios_base& pecunia::currency::nonspaced(ios_base& stream) // cppcheck-suppress unusedFunction
{
	stream.iword(pecunia::currency::spacedIndex()) = 0;
	return stream;
}
