Okay, so I finished the first of a few files on the converting, and I am getting some errors, and yes I have googled them and tried to fix to no avail, I am a noob on programming and am being told to work on a high level project, which even though I am getting help from the community I am definitely learning in the process

So here is the header file that I am having 1 bug with:

1>c:\users\public\documents\aoc source\c++\aoe2wide\aoe2wide\AoE2Wide.h(35): error C2059: syntax error : '<'
1>c:\users\public\documents\aoc source\c++\aoe2wide\aoe2wide\AoE2Wide.h(35): error C2238: unexpected token(s) preceding ';'

#include <iostream>
#include <string>
#include <vector>
#using <mscorlib.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Diagnostics;
using namespace System::IO;
using namespace System::Text;

namespace AoE2Wide
{
    private ref class Item
	{
	public:
		int Pos;
		int ReferenceValue;
		String ^Type;
		int Parameter;
		String ^Comments;
		String ^Asm;
		int OriginalPos;
	};

	private ref class Patch
	{
	public:
		String ^PatchFilepath;
		int FileSize;
		String ^Md5;
		String ^Version;
		int InterfaceDrsPosition;
		int InterfaceX1DrsPosition;
		IEnumerable<Item^> ^Items;
	};

	private ref class FatalError : Exception
	{
		public:
			FatalError(String ^msg) : Exception(msg)
			{
			}
	};
};

Then after that I am definitely having some more issues, most of them are repeats, but I need 1 solution to fix xD If i understand properly some of these arrays are not being created right...do I need to use a different notation instead? Only provided one example of each 100% unique error Once again I appreciate the help and the explanations :)

1>SlpStreamer.cpp(16): error C2664: 'System::IO::MemoryStream::MemoryStream(cli::array<Type> ^,bool)' : cannot convert parameter 1 from 'std::vector<_Ty>' to 'cli::array<Type> ^'

1>SlpStreamer.cpp(84): error C2653: 'Trace' : is not a class or namespace name
1>SlpStreamer.cpp(84): error C3861: 'Assert': identifier not found
1>SlpStreamer.cpp(95): error C2819: type 'std::vector<_Ty>' does not have an overloaded member 'operator ->'

1>SlpStreamer.cpp(191): error C2440: 'type cast' : cannot convert from 'cli::array<Type> ^' to 'auto'
1>SlpStreamer.cpp(194): error C2227: left of '->Length' must point to class/struct/union/generic type
1> type is 'int'

1>SlpStreamer.cpp(209): error C2440: 'initializing' : cannot convert from 'cli::array<Type> ^' to 'cli::array<Type> ^'

1>SlpStreamer.cpp(215): error C2664: 'std::vector<_Ty>::vector(const std::vector<_Ty> &)' : cannot convert parameter 1 from 'cli::array<Type> ^' to 'const std::vector<_Ty> &'

#include "stdafx.h"
#include "AoE2Wide.h"

using namespace System;
using namespace System::Collections::Generic;
using namespace System::Diagnostics;
using namespace System::IO;

namespace AoE2Wide
{
	private ref class SlpStrecher
	{
		public:
			static std::vector<char> Enlarge(UInt32 id, std::vector<char> data, int oldWidth, int oldHeight, int newWidth, int newHeight)
			{
				BinaryReader ^reader = gcnew BinaryReader(gcnew MemoryStream(data, false));
				// testing patch version
				auto version = reader->ReadUInt32();
				if (version != 0x4e302e32)
					return data;

				auto framecount = reader->ReadUInt32();
				if (framecount != 1)
					return data;

				auto comment = reader->ReadBytes(24);
				/*auto linesOffset = */reader->ReadUInt32();
				auto maskOffset = reader->ReadUInt32();
				auto paletteOffset = reader->ReadUInt32();
				auto properties = reader->ReadUInt32();

				auto width = reader->ReadInt32();
				if (width != oldWidth)
					return data;

				auto height = reader->ReadInt32();
				auto centerX = reader->ReadInt32();
				auto centerY = reader->ReadInt32();

				// if height - centerY doesnt equal oldHeight return data due to error
				if (height - centerY != oldHeight)
					return data;

				if (centerY != 0)
				{
					int higher = newHeight - oldHeight;
					centerY -= higher;
					newHeight = oldHeight = height;
				}

				auto newMaskSize = (UInt32) (newHeight*4);
				auto newLinesOffset = maskOffset + newMaskSize;
				auto newLinesSize = (UInt32) (newHeight*4);
				auto newLineDataStart = newLinesOffset + newLinesSize;

				MemoryStream ^outStream = gcnew MemoryStream();
				BinaryWriter ^writer = gcnew BinaryWriter(outStream);

				// Added by Master_G for testing purposes
				// UserFeedback.Info(string.Format("Resizing image #{0} for {1}x{2} to {3}x{4}",
				//    id, oldWidth, oldHeight, newWidth, newHeight));

				// writing the information provided above
				writer->Write(version);
				writer->Write(framecount);
				writer->Write(comment);
				writer->Write(newLinesOffset);
				writer->Write(maskOffset);
				writer->Write(paletteOffset);
				writer->Write(properties);
				writer->Write(newWidth);
				writer->Write(newHeight);
				writer->Write(centerX);
				writer->Write(centerY);

				//UserFeedback.Info(string.Format("Version: {0}, FrameCount: {1}, Comment: {2}, newLinesOffset: {3}",
				//    version, framecount, comment, newLinesOffset));
				//UserFeedback.Info(string.Format("MaskOffSet: {0}, PaletteOffset: {1}, Properties: {2}",
				//    maskOffset, paletteOffset, properties));
				//UserFeedback.Info(string.Format("NewWidth: {0}, NewHeight: {1}, CenterX {2}, CenterY {3}",
				//   newWidth, newHeight, centerX, centerY));
				
				auto osp = outStream->Position;
				Trace::Assert(osp == maskOffset);

				// read every line of pixels from file into orgLineMasks array
				array<UInt32> ^orgLineMasks = gcnew array<UInt32>(oldHeight);
				for (auto inLine = 0; inLine < oldHeight; inLine++)
					orgLineMasks[inLine] = reader->ReadUInt32();

				// read every original line start of old height into array
				array<UInt32> ^orgLineStarts = gcnew array<UInt32>(oldHeight + 1);
				for (auto inLine = 0; inLine < oldHeight; inLine++)
					orgLineStarts[inLine] = reader->ReadUInt32();
				orgLineStarts[oldHeight] = safe_cast<UInt32>(data->Length);

				// Subtract the next piece in orgLineStarts from the previous piece
				// and then store into a new autoiable called orgLines
				List<array<Byte>^> ^orgLines = gcnew List<array<Byte>^>(oldHeight);
				for (auto inLine = 0; inLine < oldHeight; inLine++)
				{

					auto orgLineSize = orgLineStarts[inLine + 1] - orgLineStarts[inLine];
					orgLines->Add(reader->ReadBytes(safe_cast<int>(orgLineSize)));
				}

				// initialize new lists
				array<UInt32> ^newLineMasks = gcnew array<UInt32>(newHeight);
				List<array<Byte>^> ^newLines = gcnew List<array<Byte>^>(newHeight);

				// difference in the lines from oldHeight compared to newHeight
				// e.g. 1200 - 1024 = 176

				auto extraLines = newHeight - oldHeight;

				// determine whether shrinking resolution or expanding it

				auto shrinking = extraLines < 0;

				auto expanding = extraLines > 0;

				// define middle of oldHeight
				// e.g. 1024/2 = 512

				auto centreLine = oldHeight / 2;

				// e.g. 512 + 176 = 688

				auto shrinkSkipStart = centreLine + extraLines;
				auto shrinkSkipEnd = centreLine;
				// duplication is the amount of times every duplicated line, is duplicated
				// e.g. duplication = 1 + (176 + 1)/(1024/2)
				// e.g. duplication = 1.34570

				auto duplication = 1 + (extraLines + 1)/(oldHeight/2);
				// the duplication block size is the block that is being duplicated
				// the last line of which MIGHT not be duplicated 'duplication' times
				//  eg if duplication is 2, extralines = 501, dbs = 251, the last of which is
				//  duped just once.

				auto duplicationBlockSize = (extraLines + duplication - 1)/duplication;


				auto dupStart = centreLine - duplicationBlockSize / 2;

				auto dupEnd = dupStart + duplicationBlockSize;

				int dupedLines = 0; //'UNIT'TEST
				for (auto inLine = 0; inLine < oldHeight; inLine++)
				{
					// If shrinking skip 'extralines' lines on the centerline and above
					if (shrinking && inLine >= shrinkSkipStart && inLine < shrinkSkipEnd)
					{
						dupedLines--;
						continue;
					}
					// newLineMasks has same ammount of positions as newHeight
					// e.g. 1200 => 1200
					// 
					newLineMasks[newLines->Count] = orgLineMasks[inLine];


					auto newLine = StretchLine(orgLines[inLine], oldWidth, newWidth);
					newLines->Add(newLine);

					// If expanding, duplicate the right amount of lines before centreLine
					if (!expanding || inLine < dupStart || inLine >= dupEnd)
						continue;

					for (auto rep = 0; rep < duplication && dupedLines < extraLines; rep++)
					{
						newLineMasks[newLines->Count] = orgLineMasks[inLine];
						newLines->Add(newLine);
						dupedLines++;
					}
				}
				Trace::Assert(newLines->Count == newHeight);
				Trace::Assert(dupedLines == extraLines);


				auto nextLineStart = newLineDataStart;


				for each (auto newLineMask in newLineMasks)
					writer->Write(newLineMask);

				osp = outStream::Position;
				Trace::Assert(newLinesOffset == osp);


				for each (auto newLine in newLines)
				{
					writer->Write(nextLineStart);
					nextLineStart += safe_cast<UInt32>(newLine->Length);
				}

				osp = outStream::Position;
				Trace::Assert(newLineDataStart == osp);


				for each (auto newLine in newLines)
					writer->Write(newLine);

				Trace::Assert(outStream->Position == nextLineStart);

				writer->Close();


				array<Object^> ^newSlp = outStream->ToArray();

				// For debugging:
				//File.WriteAllBytes(string.Format(@"slp\{0}org.slp", id), data);
				//File.WriteAllBytes(string.Format(@"slp\{0}new.slp", id), newSlp);

				return newSlp;
			}
	private:
		static array<Byte> ^BlitColor(int amount, Byte color)
				{
					if (amount <=0)
						return nullptr;


					//	using (auto outStream = new MemoryStream())
					MemoryStream ^outStream = gcnew MemoryStream();
					try
					{
						while (amount > 15)
						{
		
							auto count = Math::Min(amount, 255);
							outStream->WriteByte(7);
							outStream->WriteByte(safe_cast<Byte>(count));
							outStream->WriteByte(color);
							amount -= count;
						}
						while (amount > 0)
						{

							auto count = Math::Min(amount, 15);
							outStream->WriteByte(safe_cast<Byte>(7 | (count << 4)));
							outStream->WriteByte(color);
							amount -= count;
						}
						return outStream->ToArray();
					}
					finally
					{
						delete outStream;
					}
				}

				static array<Byte> ^StretchLine(array<Byte> ^orgLine, int oldWidth, int newWidth)
				{
					if (orgLine->Length == 1)
						return orgLine;

					// Take the last byte before the 0x0F eol as color (I suppose that's always a color :S )
					auto color = orgLine[orgLine->Length - 2];
					// e.g. 1900-1280 = 620, color is from 
					array<Byte> ^addendum = BlitColor(newWidth - oldWidth, color);
					if (addendum == nullptr || addendum->Length == 0)
						return orgLine;


					//	using (auto outStream = new MemoryStream(orgLine.Length + addendum.Length))
					MemoryStream ^outStream = gcnew MemoryStream(orgLine->Length + addendum->Length);
					try
					{
						outStream->Write(orgLine,0, orgLine->Length - 1);
						outStream->Write(addendum, 0, addendum->Length);
						outStream->WriteByte(orgLine[orgLine->Length - 1]);
						return outStream->ToArray();
					}
					finally
					{
						delete outStream;
					}
				}

	};
};

You need to either explicitly have a using statement for System::Collections::Generic or qualify it as Generic::IEnumberable<Item ^> You're not going to be able to use a std::vector without a lot of hassles. Change it to the cli::array that it's asking for. Google for the syntax.

Also, I don't know why you're using auto all over the place. It should be the default storage class as it is in standard C++.

I don't believe the for each (idiom?) exists in C++/CLI. Just loop over the index.

If you working in VC++ 2010, there is terrible intellisense support for C++/CLI. If you have to, develop your projects in 2008 and import them into 2010 if you need .NET 4.0. That way you can hunt through the namespaces if you absolutely need to (which would have helped with the IEnumerable bit).

I don't believe the for each (idiom?) exists in C++/CLI.

It does:

#include <iostream>
#include <vector>

int main()
{
    std::vector<int> v;

    for (int i = 0; i < 10; i++)
        v.push_back(i);

    // C++/CLI foreach
    for each (int x in v)
        std::cout<< x <<'\n';
}
commented: I believe! I believe! Thanks for the clarification! +6

I had tried it one time with the C# syntax (foreach) and with the way Boost does it (for_each). I should have pressed on further with it. Apologies to the OP, and thanks to Narue.

(I didn't know that VC++ had a compiler extension for it even for STL containers, either)

C++/CLI is surprisingly compatible with standard C++. I know that was part of the design, but they did well, in my opinion.

Ok, so i worked past a few of the issues changing some code around, somehow i don't think this is eve gonna work in the end, which will just be a pain in the ***. Anyways here is the error I am trying to fix right now

SlpStreamer.cpp(16): error C2664: 'System::IO::MemoryStream::MemoryStream(cli::array<Type> ^,bool)' : cannot convert parameter 1 from 'cli::array<Type> ^' to 'cli::array<Type> ^'
1> with
1> [
1> Type=unsigned char
1> ]
1> and
1> [
1> Type=System::Byte ^
1> ]
1> and
1> [
1> Type=unsigned char
1> ]

#include "stdafx.h"
#include "AoE2Wide.h"

using namespace System;
using namespace System::Collections::Generic;
using namespace System::Diagnostics;
using namespace System::IO;

namespace AoE2Wide
{
	private ref class SlpStrecher
	{
		public:
			static cli::array<Byte^> ^ Enlarge(UInt32 id, cli::array<Byte^> ^data, int oldWidth, int oldHeight, int newWidth, int newHeight)
			{
				BinaryReader ^reader = gcnew BinaryReader(gcnew MemoryStream(data, false));
				// testing patch version
				auto version = reader->ReadUInt32();
				if (version != 0x4e302e32)
					return data;

				auto framecount = reader->ReadUInt32();
				if (framecount != 1)
					return data;

				auto comment = reader->ReadBytes(24);
				/*auto linesOffset = */reader->ReadUInt32();
				auto maskOffset = reader->ReadUInt32();
				auto paletteOffset = reader->ReadUInt32();
				auto properties = reader->ReadUInt32();

				auto width = reader->ReadInt32();
				if (width != oldWidth)
					return data;

				auto height = reader->ReadInt32();
				auto centerX = reader->ReadInt32();
				auto centerY = reader->ReadInt32();

				// if height - centerY doesnt equal oldHeight return data due to error
				if (height - centerY != oldHeight)
					return data;

				if (centerY != 0)
				{
					int higher = newHeight - oldHeight;
					centerY -= higher;
					newHeight = oldHeight = height;
				}

				auto newMaskSize = (UInt32) (newHeight*4);
				auto newLinesOffset = maskOffset + newMaskSize;
				auto newLinesSize = (UInt32) (newHeight*4);
				auto newLineDataStart = newLinesOffset + newLinesSize;

				MemoryStream ^outStream = gcnew MemoryStream();
				BinaryWriter ^writer = gcnew BinaryWriter(outStream);

				// Added by Master_G for testing purposes
				// UserFeedback.Info(string.Format("Resizing image #{0} for {1}x{2} to {3}x{4}",
				//    id, oldWidth, oldHeight, newWidth, newHeight));

				// writing the information provided above
				writer->Write(version);
				writer->Write(framecount);
				writer->Write(comment);
				writer->Write(newLinesOffset);
				writer->Write(maskOffset);
				writer->Write(paletteOffset);
				writer->Write(properties);
				writer->Write(newWidth);
				writer->Write(newHeight);
				writer->Write(centerX);
				writer->Write(centerY);

				//UserFeedback.Info(string.Format("Version: {0}, FrameCount: {1}, Comment: {2}, newLinesOffset: {3}",
				//    version, framecount, comment, newLinesOffset));
				//UserFeedback.Info(string.Format("MaskOffSet: {0}, PaletteOffset: {1}, Properties: {2}",
				//    maskOffset, paletteOffset, properties));
				//UserFeedback.Info(string.Format("NewWidth: {0}, NewHeight: {1}, CenterX {2}, CenterY {3}",
				//   newWidth, newHeight, centerX, centerY));
				
				auto osp = outStream->Position;
				Trace::Assert(osp == maskOffset);

				// read every line of pixels from file into orgLineMasks array
				array<UInt32> ^orgLineMasks = gcnew array<UInt32>(oldHeight);
				for (auto inLine = 0; inLine < oldHeight; inLine++)
					orgLineMasks[inLine] = reader->ReadUInt32();

				// read every original line start of old height into array
				array<UInt32> ^orgLineStarts = gcnew array<UInt32>(oldHeight + 1);
				for (auto inLine = 0; inLine < oldHeight; inLine++)
					orgLineStarts[inLine] = reader->ReadUInt32();
				orgLineStarts[oldHeight] = safe_cast<UInt32>(data->Length);

				// Subtract the next piece in orgLineStarts from the previous piece
				// and then store into a new autoiable called orgLines
				List<array<Byte>^> ^orgLines = gcnew List<array<Byte>^>(oldHeight);
				for (auto inLine = 0; inLine < oldHeight; inLine++)
				{

					auto orgLineSize = orgLineStarts[inLine + 1] - orgLineStarts[inLine];
					orgLines->Add(reader->ReadBytes(safe_cast<int>(orgLineSize)));
				}

				// initialize new lists
				array<UInt32> ^newLineMasks = gcnew array<UInt32>(newHeight);
				List<array<Byte>^> ^newLines = gcnew List<array<Byte>^>(newHeight);

				// difference in the lines from oldHeight compared to newHeight
				// e.g. 1200 - 1024 = 176

				auto extraLines = newHeight - oldHeight;

				// determine whether shrinking resolution or expanding it

				auto shrinking = extraLines < 0;

				auto expanding = extraLines > 0;

				// define middle of oldHeight
				// e.g. 1024/2 = 512

				auto centreLine = oldHeight / 2;

				// e.g. 512 + 176 = 688

				auto shrinkSkipStart = centreLine + extraLines;
				auto shrinkSkipEnd = centreLine;
				// duplication is the amount of times every duplicated line, is duplicated
				// e.g. duplication = 1 + (176 + 1)/(1024/2)
				// e.g. duplication = 1.34570

				auto duplication = 1 + (extraLines + 1)/(oldHeight/2);
				// the duplication block size is the block that is being duplicated
				// the last line of which MIGHT not be duplicated 'duplication' times
				//  eg if duplication is 2, extralines = 501, dbs = 251, the last of which is
				//  duped just once.

				auto duplicationBlockSize = (extraLines + duplication - 1)/duplication;


				auto dupStart = centreLine - duplicationBlockSize / 2;

				auto dupEnd = dupStart + duplicationBlockSize;

				int dupedLines = 0; //'UNIT'TEST
				for (auto inLine = 0; inLine < oldHeight; inLine++)
				{
					// If shrinking skip 'extralines' lines on the centerline and above
					if (shrinking && inLine >= shrinkSkipStart && inLine < shrinkSkipEnd)
					{
						dupedLines--;
						continue;
					}
					// newLineMasks has same ammount of positions as newHeight
					// e.g. 1200 => 1200
					// 
					newLineMasks[newLines->Count] = orgLineMasks[inLine];


					auto newLine = StretchLine(orgLines[inLine], oldWidth, newWidth);
					newLines->Add(newLine);

					// If expanding, duplicate the right amount of lines before centreLine
					if (!expanding || inLine < dupStart || inLine >= dupEnd)
						continue;

					for (auto rep = 0; rep < duplication && dupedLines < extraLines; rep++)
					{
						newLineMasks[newLines->Count] = orgLineMasks[inLine];
						newLines->Add(newLine);
						dupedLines++;
					}
				}
				Trace::Assert(newLines->Count == newHeight);
				Trace::Assert(dupedLines == extraLines);


				auto nextLineStart = newLineDataStart;


				for each (auto newLineMask in newLineMasks)
					writer->Write(newLineMask);

				osp = outStream->Position;
				Trace::Assert(newLinesOffset == osp);


				for each (auto newLine in newLines)
				{
					writer->Write(nextLineStart);
					nextLineStart += safe_cast<UInt32>(newLine->Length);
				}

				osp = outStream->Position;
				Trace::Assert(newLineDataStart == osp);


				for each (auto newLine in newLines)
					writer->Write(newLine);

				Trace::Assert(outStream->Position == nextLineStart);

				writer->Close();


				array<Object^> ^newSlp = outStream->ToArray();

				// For debugging:
				//File.WriteAllBytes(string.Format(@"slp\{0}org.slp", id), data);
				//File.WriteAllBytes(string.Format(@"slp\{0}new.slp", id), newSlp);

				return newSlp;
			}
	private:
		static array<Byte> ^BlitColor(int amount, Byte color)
				{
					if (amount <=0)
						return nullptr;


					//	using (auto outStream = new MemoryStream())
					MemoryStream ^outStream = gcnew MemoryStream();
					try
					{
						while (amount > 15)
						{
		
							auto count = Math::Min(amount, 255);
							outStream->WriteByte(7);
							outStream->WriteByte(safe_cast<Byte>(count));
							outStream->WriteByte(color);
							amount -= count;
						}
						while (amount > 0)
						{

							auto count = Math::Min(amount, 15);
							outStream->WriteByte(safe_cast<Byte>(7 | (count << 4)));
							outStream->WriteByte(color);
							amount -= count;
						}
						return outStream->ToArray();
					}
					finally
					{
						delete outStream;
					}
				}

				static array<Byte> ^StretchLine(array<Byte> ^orgLine, int oldWidth, int newWidth)
				{
					if (orgLine->Length == 1)
						return orgLine;

					// Take the last byte before the 0x0F eol as color (I suppose that's always a color :S )
					auto color = orgLine[orgLine->Length - 2];
					// e.g. 1900-1280 = 620, color is from 
					array<Byte> ^addendum = BlitColor(newWidth - oldWidth, color);
					if (addendum == nullptr || addendum->Length == 0)
						return orgLine;


					//	using (auto outStream = new MemoryStream(orgLine.Length + addendum.Length))
					MemoryStream ^outStream = gcnew MemoryStream(orgLine->Length + addendum->Length);
					try
					{
						outStream->Write(orgLine,0, orgLine->Length - 1);
						outStream->Write(addendum, 0, addendum->Length);
						outStream->WriteByte(orgLine[orgLine->Length - 1]);
						return outStream->ToArray();
					}
					finally
					{
						delete outStream;
					}
				}

	};
};

Another smaller question, at this point I am starting to get frustrated that I cannot understand this code anymore, and I would rather try re-coding it from scratch, the 2 biggest issues I see so far in the code is the use of "var" and the for each, i see how you used the for each above, and i know auto is supposed to be like var, but how do i make the for each if i am using auto? Ty :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.