/******************************************************************************
 JUNIXEnvironmentEntry.cc

	Copyright © 1997 by Glenn Bach. All rights reserved.

 ******************************************************************************/

#include "JUNIXEnvironmentEntry.h"

#include <JOrderedSet.h>

#include <iostream.h>
#include <jAssert.h>

/******************************************************************************
 Constructor

 ******************************************************************************/

JUNIXEnvironmentEntry::JUNIXEnvironmentEntry
	(
	const JCharacter* 	variable, 
	const JCharacter* 	value 
	)
	:
	itsVariable(variable),
	itsVariableWidth(0),
	itsValue(value),
	itsValueWidth(0)
{
}

/******************************************************************************
 Destructor

 ******************************************************************************/

JUNIXEnvironmentEntry::~JUNIXEnvironmentEntry()
{
}

/******************************************************************************
 CompareSuffixes (static private)

 ******************************************************************************/

JOrderedSetT::CompareResult
JUNIXEnvironmentEntry::CompareVariables
	(
	JUNIXEnvironmentEntry* const & n1,
	JUNIXEnvironmentEntry* const & n2
	)
{
	const int r = JStringCompare(n1->GetVariable(), n2->GetVariable(), kFalse);

	if (r > 0)
		{
		return JOrderedSetT::kFirstGreaterSecond;
		}
	else if (r < 0)
		{
		return JOrderedSetT::kFirstLessSecond;
		}
	else
		{
		return JOrderedSetT::kFirstEqualSecond;
		}
}

/******************************************************************************
 Stream operators

	The string data is delimited by double quotes:  "this is a string".

	To include double quotes in a string, use \"
	To include a backslash in a string, use \\

	An exception is made if the streams are cin or cout.
	For input, characters are simply read until 'return' is pressed.
	For output, Print() is used.

 ******************************************************************************/

ostream&
operator<<
	(
	ostream&						output,
	const JUNIXEnvironmentEntry&	entry
	)
{
	output << entry.GetVariable();
	output << entry.GetValue();
	output << endl;
	return output;
}
