M
Markus Freitag
Guest
Hello!
I have to get this code to C++.
What possibilities do I have?
Can someone create an example of how best to solve this, convert?
Thanks in advance.
With best regards Markus
[XmlRoot("RECEIVER")]
public class Receiver
{
public class PropertyMaterial
{
[XmlAttribute("batchID")]
public string BatchID { get; set; }
[XmlAttribute("quantity")]
public int Quantity { get; set; }
public PropertyMaterial()
{
BatchID = "";
Quantity = 0;
}
}
[XmlArray("MATERIALS_TOP")]
[XmlArrayItem("MATERIAL")]
public List<PropertyMaterial> ListTop;
[XmlIgnore]
public Dictionary<int, PropertyMaterial> DictionaryMaterial;
[XmlArray("MATERIALS_CURRENT")]
[XmlArrayItem("MATERIAL")]
public List<PropertyMaterial> ListCurrent;
[XmlAttribute("product")]
public string CurrentProduct { get; set; }
[XmlIgnore]
public bool ReleaseOfUpperListGiven { get; set; }
[XmlIgnore]
public string NextStepInstruction { get; set; }
public Receiver()
{
ListTop = new List<PropertyMaterial>();
ListCurrent = new List<PropertyMaterial>();
CurrentProduct = "";
NextStepInstruction = "";
DictionaryMaterial = new Dictionary<int, PropertyMaterial>();
DictionaryMaterial.Add(1, new PropertyMaterial() { BatchID = "Test", Quantity = 2 });
ListCurrent.Add(new PropertyMaterial() { BatchID = "TestList", Quantity = 22 });
}
public PropertyMaterial GetMaterial(int number)
{
if (DictionaryMaterial.ContainsKey(number))
return DictionaryMaterial[number];
return null;
}
public PropertyMaterial GetMaterialList(int number)
{
if (DictionaryMaterial.ContainsKey(number))
return DictionaryMaterial[number];
return null;
}
public PropertyMaterial GetMaterialList(int number)
{
var qry = ListCurrent.Where(x => x.BatchID == number.ToString()).FirstOrDefault();
return qry;
}
public void Reset()
{
ListTop.Clear();
ListCurrent.Clear();
ReleaseOfUpperListGiven = false;
NextStepInstruction = "";
}
public int Process(int numberOfPieces)
{
int newQuantity = 0;
ListCurrent[0].Quantity = ListCurrent[0].Quantity - numberOfPieces;
if (ListCurrent[0].Quantity <= 0)
ListCurrent.RemoveAt(0);
else
newQuantity = ListCurrent[0].Quantity;
return newQuantity;
}
}
Continue reading...
I have to get this code to C++.
What possibilities do I have?
- - Dictionary?
- List?
I could use the MFC library. Unmanaged code.
Can someone create an example of how best to solve this, convert?
Thanks in advance.
With best regards Markus
[XmlRoot("RECEIVER")]
public class Receiver
{
public class PropertyMaterial
{
[XmlAttribute("batchID")]
public string BatchID { get; set; }
[XmlAttribute("quantity")]
public int Quantity { get; set; }
public PropertyMaterial()
{
BatchID = "";
Quantity = 0;
}
}
[XmlArray("MATERIALS_TOP")]
[XmlArrayItem("MATERIAL")]
public List<PropertyMaterial> ListTop;
[XmlIgnore]
public Dictionary<int, PropertyMaterial> DictionaryMaterial;
[XmlArray("MATERIALS_CURRENT")]
[XmlArrayItem("MATERIAL")]
public List<PropertyMaterial> ListCurrent;
[XmlAttribute("product")]
public string CurrentProduct { get; set; }
[XmlIgnore]
public bool ReleaseOfUpperListGiven { get; set; }
[XmlIgnore]
public string NextStepInstruction { get; set; }
public Receiver()
{
ListTop = new List<PropertyMaterial>();
ListCurrent = new List<PropertyMaterial>();
CurrentProduct = "";
NextStepInstruction = "";
DictionaryMaterial = new Dictionary<int, PropertyMaterial>();
DictionaryMaterial.Add(1, new PropertyMaterial() { BatchID = "Test", Quantity = 2 });
ListCurrent.Add(new PropertyMaterial() { BatchID = "TestList", Quantity = 22 });
}
public PropertyMaterial GetMaterial(int number)
{
if (DictionaryMaterial.ContainsKey(number))
return DictionaryMaterial[number];
return null;
}
public PropertyMaterial GetMaterialList(int number)
{
if (DictionaryMaterial.ContainsKey(number))
return DictionaryMaterial[number];
return null;
}
public PropertyMaterial GetMaterialList(int number)
{
var qry = ListCurrent.Where(x => x.BatchID == number.ToString()).FirstOrDefault();
return qry;
}
public void Reset()
{
ListTop.Clear();
ListCurrent.Clear();
ReleaseOfUpperListGiven = false;
NextStepInstruction = "";
}
public int Process(int numberOfPieces)
{
int newQuantity = 0;
ListCurrent[0].Quantity = ListCurrent[0].Quantity - numberOfPieces;
if (ListCurrent[0].Quantity <= 0)
ListCurrent.RemoveAt(0);
else
newQuantity = ListCurrent[0].Quantity;
return newQuantity;
}
}
Continue reading...