bonjour
Je vous met une méthode qui doit avoir une parenthèse ouvrante de trop:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
    /*------------------------------------------------------------------------------*/
    /*Name          ParseObjects                                                    */
    /*Role          Check the coherence of the objects Objects                      */
    /*Interface                                                                     */
    /*In                                                                            */
    /*In/Out        pSegment                                                        */
    /*Result        bStatus                                                         */
    /*------------------------------------------------------------------------------*/
 
    bool BuildComponents::ParseObjects( List<PropositionNormalizedM^>^ plistPreconditionNormalized, List<PropositionNormalizedM^>^ plistPredicatNormalized, List<CObjetM^>^ plistObjectsNormalized, CObjetM^ pRefObjet, System::String^ sKeyName)
    { // 1
		List<PropositionNormalizedM^>^ plisteAPreconditionToCompare;
		List<PropositionNormalizedM^>::Enumerator itPrecondition;
		PropositionNormalizedM^ pPrecondition;
		PropositionNormalizedM^ pPredicat;
		CObjetM^ pRefObject;
		CObjetM^ pObjet;
		CAnalysedWordM^ pWord;
		int len;
		int i = 0;
		int j = 0;
		int k = 0;
		int l = 0;
		int min = 0;
		int max = 0;
		int type = 0;
		int iPred = 0;
		int iSize = 0;
		int iSize1 = 0;
		int iSize3 = 0;
		int value;
		cli::array<Int32,1>^ iiValue;
		iiValue = gcnew cli::array<Int32,1>(25);
		System::String^ pString;
		std::string sPhrase;
		System::String^ wsText = L"";
		System::String^ Reference = L"";
		System::String^ wsRefName = L"";
		System::String^ Identifiant = L"";
		System::String^ wsBuffer;
		System::String^ wsWord;
		std::wstring wsTemp;
		const wchar_t* chars;
		int Occurence = 0;
		bool bColorIsCoherent = true;
		bool bValueIsCoherent = true;
		bool bOK;
		bool b0;
		// on procède en deux temps: d'abord les predicats puis les préconditions
		// dans chacune on cherche les éléments qui peuvent être contradictoire
		// et on réévalue les cardianlités en fonction des héritages
		// il faut pouvoir parser la ListWord qu'on constitue au départ
		// on commence par les prédicats
		pObjet = gcnew CObjetM();
		plisteAPreconditionToCompare = plistPreconditionNormalized;
		for each( pPredicat in plistPredicatNormalized)
		{ // 2
			System::String^ phrase;
			if( sKeyName == L"")
			{ // 3
				break;
			} // 3
			// il faut d'abord rechercher l'identifiant de l'objet
			wsText = pPredicat->Comment;
			phrase = L"";
			for each( pWord in pPredicat->pWord)
			{ // 3
				if(  sKeyName == L"")
					break;
				phrase += pWord->wsWord;
				phrase += L" ";
				System::String^ wsComment = pObjet->Text;
				if( pObjet->Name == sKeyName)
				{ // 4
					//on met à jour l'origine de l'heritage
					pPredicat->Occurence += 3;
				} // 4
				wsWord = pWord->wsWord;
				switch( pWord->POS)
				{ // 4
					case enPOSM::POS_NB:
						for each( pObjet in plistObjectsNormalized)
						{ // 5
							// on ne prend à ce stade que le premier objet
							// en fait pour diagnostiquer tous les risques d'incohérence il faut boucler sur tous les objets
							System::String^ wsNameOfObject = pObjet->Name;
							// il faut là rajouter une recherche sur le nom de l'objet
							int pos = pPredicat->Comment->IndexOf( pObjet->Name, 0);
							if( pos > -1)
							{ // 6
								if( pWord->wsWord != L"1")
								{ // 7
									pos = pWord->wsWord->IndexOf( L"-1", 0);
									int pos1 = pWord->wsWord->IndexOf( L"5", 0);
									if( pos > -1 || pos1 > -1)
									{ // 8   
										bValueIsCoherent = false;
										const wchar_t* chars = (const wchar_t*)(Marshal::StringToHGlobalUni( pWord->wsWord)).ToPointer();
										wsTemp.append( chars);
										Marshal::FreeHGlobal(IntPtr((void*)chars));
										unsigned int itemp = _wtoi( (wchar_t*) wsTemp.c_str());
										value = itemp;
										// c'est une simplification abusive on utilise l'heritage de la pluie
										// mais pour un autre objet il faut utiliser une référence variable
										if( !(pObjet->min == 0 &&  pObjet->max == 0))
										{ // 9
											if( pObjet->min - 1 < value && pObjet->max +1 > value || value == pObjet->type)
											{ // 10
												bValueIsCoherent = false;
											} // 10
										} // 9
										else
										{ // 9
											bValueIsCoherent = true;
										} // 9
									} // 8
								} // 7
							} // 6
							if( bValueIsCoherent == false)
							{ // 6
								System::String^ wsParagraph = pPredicat->ListParagraph;
								wsTemp = L"";
								msg = "Incoherence inter an object named ";
								const wchar_t* chars = (const wchar_t*)(Marshal::StringToHGlobalUni( pWord->wsWord)).ToPointer();
								wsTemp.append( chars);
								Marshal::FreeHGlobal(IntPtr((void*)chars));
								char* temp = objStrConv.awcstombs( (wchar_t *)wsTemp.c_str());
								msg  += temp;
								msg += " ";
								objStrConv.StrFreeA( temp);
								wsTemp = L"";
								chars = (const wchar_t*)(Marshal::StringToHGlobalUni( phrase)).ToPointer();
								wsTemp.append( chars);
								Marshal::FreeHGlobal(IntPtr((void*)chars));
								temp = objStrConv.awcstombs( (wchar_t *)wsTemp.c_str());
								msg  += temp;
								objStrConv.StrFreeA( temp);
								msg += " with the minimum value is ";
								msg += pObjet->min;
								msg += " and the maximum value is ";
								msg += pObjet->max;
								msg += " with the number of value is ";
								msg += pObjet->nValue;
								msg += " in the sentence ";
								msg += temp;
								throw Doc_exception( (const char*)msg.c_str(), nParagraph);
							} // 6
						} // 5
						break;
					case enPOSM::POS_COLOR :
						System::String^ wsName;
						System::String^ listOfColors;
						k = 0;
						iSize = 0;
						listOfColors = L"";
						bColorIsCoherent = false;
						for each( pObjet in plistObjectsNormalized)
						{ // 5
							l = 0;
							int pos = pObjet->Name->IndexOf( L"indicator", 0);
							if( pos > -1)
							{ // 6
								for each( pString in pObjet->Enumerated)
								{ // 7
									System::String^ color = pString;
									listOfColors += color;
									iSize = pObjet->nValue;
									listOfColors += L" ";
									if( pWord->wsWord == color)
									{ // 8
										bColorIsCoherent = true;
										wsName = pObjet->Name;
									} // 8
								} // 7
							} // 6
						} // 5
						if( bColorIsCoherent == false)
						{ // 5
							if( pObjet->nValue == 0)
							{ // 6
								pObjet->nValue = pPredicat->pColors->Count;
							} // 6
							else
							{ // 6
								System::String^ wsParagraph = pPredicat->ListParagraph;
								k = 0;
								// il faut positioner objet sur l'indicateur
								wsBuffer = L"Incoherence inter an object named ";
								wsBuffer += wsName;
								wsBuffer += L" with the list of value value is ";
								wsBuffer += listOfColors;
								wsBuffer += L" with the number of value is ";
								wsBuffer += iSize;
								wsBuffer += L" in the sentence " + phrase; 
								// char* =CStrConv::awcstombs(wchar_t *sczW)
								chars = (const wchar_t*)(Marshal::StringToHGlobalUni( wsBuffer)).ToPointer();
								wsTemp.append( chars);
								Marshal::FreeHGlobal(IntPtr((void*)chars));
								char* tmp = objStrConv.awcstombs( (wchar_t*)wsTemp.c_str());
								msg = tmp;
								objStrConv.StrFreeA( tmp); 
								throw Doc_exception( (const char*)msg.c_str(), nParagraph);
							} // 6
						} // 5
						break;
					default:
						break;
				j++;
			} // 4
			i++;
		} // 3
		// puis on traitera les Préconditions
		i = 0;
		j = 0;
		k = 0;
		if( sKeyName != L"")
		{ // 3
			itPrecondition = plistPreconditionNormalized->GetEnumerator();
			while( itPrecondition.MoveNext())
			{ // 4
				pPrecondition = itPrecondition.Current;
				// il faut parser chaque précondition pour identifier les termes qui se raccordent à l'héritage
				wsText = pPrecondition->Comment;
				pPrecondition->bAllocated = false;
				Identifiant = pPrecondition->Identifier;
				Occurence = pPrecondition->Occurence;
				Reference = sKeyName;
				for each( pWord in pPrecondition->pWord)
				{ // 5
					System::String^ wsTemp1 = pWord->wsWord;
					wsTemp1->ToLower();
					System::String^ wsTemp = sKeyName;
					wsTemp->ToLower();
					int pos = wsTemp->IndexOf(wsTemp1, 0);
					if( pos > -1)
					{ // 6
						pPrecondition->Occurence += 3;
						pPrecondition->bAllocated = true;
					} // 6
					j++;
				} // 5
				i++;
			} // 4
		} // 3
		bOK = CheckPeconditions( plistObjectsNormalized, plistPreconditionNormalized, pRefObjet);
		// il y a encore un contrôle à faire entre les préconditions: on cherche des conditions potentiellement ambigüe
		// pour chaque objet
		// pour chaque précondition
		// la precondition en cours risque t-elle de provoquer une incohérence
		System::String^ pRefValue1 = L"";
		System::String^ pRefValue2 = L"";
		System::String^ pRefValue3 = L"";
		int covered = 0;
		wsText = L"";
		// pour chaque objet on cherche l'objet dont le nom est inclus dans la précondition
		for each( pObjet in plistObjectsNormalized)
		{ // 3
			std::wstring wsTemp = L"";
			List<CAnalysedWordM^>::Enumerator itWord;
			pRefObject = pObjet;
			System::String^ wsNameOfCurrentObject = pRefObject->Name;
			if( pRefObject->type < 5)
			{ // 4
				min = pRefObject->min;
				max = pRefObject->max;
				type = pRefObject->type;
				j = 0;
				itPrecondition = plistPreconditionNormalized->GetEnumerator();
				while( itPrecondition.MoveNext())
				{ // 5
					pPrecondition = itPrecondition.Current;
					const wchar_t* chars = (const wchar_t*)(Marshal::StringToHGlobalUni( wsNameOfCurrentObject)).ToPointer();
					wsTemp.append( chars);
					Marshal::FreeHGlobal(IntPtr((void*)chars));
					int pos = (pPrecondition->Comment)->IndexOf( *wsTemp.c_str(), 0);
					if( pos > -1)
					{ // 6
						if( !( pRefObject->min == 0 &&  pRefObject->max == 0))
						{ // 7
							// il faut extraire la valeur à évaluer
							// on parcours la précondition à la recherche de valeur numérique
							itWord = pPrecondition->pWord->GetEnumerator();
							while( itWord.MoveNext())
							{ // 8
								pWord = itWord.Current;
								System::String^ wsWord = pWord->wsWord;
								if( pWord->POS == enPOSM::POS_NAMED_ENTITY)
								{ // 9
									for each( pString in pRefObject->Enumerated)
									{ // 10
										switch( l)
											{ // 11
												case 0:
													pRefValue1 = pString;
													covered++;
													break;
												case 1:
													pRefValue3 = pString;
													covered++;
													break;
												case 2:
													if( pRefObject->nValue == 3)
													{ // 12
														pRefValue3 = pString;
													} // 12
													covered++;
													break;
												default:
													break;
									} // 10
								} // 9
							} // 8
							else if( pWord->POS == enPOSM::POS_NB)
							{ // 8
								if( pWord->wsWord != L"1")
								{ // 9
									if( pWord->wsWord != L"one" && wsText != pWord->wsWord + L" -")
									{ // 10
										bValueIsCoherent = false;
										pos = pWord->wsWord->IndexOf( L"N", 0);
										if( pos > -1 )
										{ // 11
											std::wstring wsTemp;
											const wchar_t* chars = (const wchar_t*)(Marshal::StringToHGlobalUni( pWord->wsWord->Substring(1))).ToPointer();
											wsTemp.append( chars);
											Marshal::FreeHGlobal(IntPtr((void*)chars));
											value = _wtoi( wsTemp.c_str());
										} // 11
										else
										{ // 11
											iiValue = ComputeNumber( iiValue, pWord->wsWord, u);
										} // 11
										int i = u-1;
										value = iiValue[i];
										if( min -1 < value && max +1 > value || value == type)
										{ // 11
											bValueIsCoherent = true;
										} // 11
									} // 10
								} // 9
								else
								{ // 9
									bValueIsCoherent = true;
								} // 9
							} // 8
						} // 7
						if( bValueIsCoherent == false)
						{ // 7
							std::wstring wsTemp;
							char* temp;
							wsTemp = L"";
							System::String^ phrase = L"";
							msg = "Incoherence inter an object named ";
							chars = (const wchar_t*)(Marshal::StringToHGlobalUni( pRefObject->Name)).ToPointer();
							wsTemp.append( chars);
							Marshal::FreeHGlobal(IntPtr((void*)chars));
							temp = objStrConv.awcstombs( (wchar_t *)wsTemp.c_str());
							msg += temp;
							objStrConv.StrFreeA( temp);
							msg += " with tne minimum value is ";
							msg += pRefObject->min;
							msg += " and the maximum value is ";
							msg += pRefObject->max;
							msg += " with the number of value is ";
							msg += pRefObject->nValue;
							msg += " in the sentence ";
							phrase = FormatPhrase( pPrecondition);
							wsTemp = L"";
							chars = (const wchar_t*)(Marshal::StringToHGlobalUni( phrase)).ToPointer();
							wsTemp.append( chars);
							Marshal::FreeHGlobal(IntPtr((void*)chars));
							temp = objStrConv.awcstombs( (wchar_t *)wsTemp.c_str());
							msg += temp;
							objStrConv.StrFreeA( temp);
							throw Doc_exception( (const char *)msg.c_str(), nParagraph);
						} // 7
					} // 6
				} // 5
			} // 4
		} // 3
		len = pRefValue1->Length;
		b0 = covered <= 3 || covered == 0;
		if( b0 == true && len > 0)
		{ // 3
			std::wstring wsTemp;
			char* temp;
			msg = "the values ";
			chars = (const wchar_t*)(Marshal::StringToHGlobalUni( pRefValue1)).ToPointer();
			wsTemp.append( chars);
			Marshal::FreeHGlobal(IntPtr((void*)chars));
			temp = objStrConv.awcstombs( (wchar_t *)wsTemp.c_str());
			msg += temp;
			objStrConv.StrFreeA( temp);
			msg += ", ";
			chars = (const wchar_t*)(Marshal::StringToHGlobalUni( pRefValue2)).ToPointer();
			wsTemp.append( chars);
			Marshal::FreeHGlobal(IntPtr((void*)chars));
			temp = objStrConv.awcstombs( (wchar_t *)wsTemp.c_str());
			msg += temp;
			objStrConv.StrFreeA( temp);
			msg += ", ";
			chars = (const wchar_t*)(Marshal::StringToHGlobalUni( pRefValue3)).ToPointer();
			wsTemp.append( chars);
			Marshal::FreeHGlobal(IntPtr((void*)chars));
			temp = objStrConv.awcstombs( (wchar_t *)wsTemp.c_str());
			msg += temp;
			objStrConv.StrFreeA( temp);
			msg += " have not be completly covered";
			throw Doc_exception( (const char *)msg.c_str(), nParagraph);
		} // 3
		covered = 0;
		for each( pPrecondition in plisteAPreconditionToCompare)
		{ // 3
			int pos;
			if(pPrecondition->Comment != nullptr)
			{ // 4
				pos = wsText->IndexOf( pPrecondition->Comment, 0);
			} // 4
			else
			{ // 4
				pos = -1;
			} // 4
			int pos1 = wsText->IndexOf( L"Door N2", 0);
			int pos2 = pPrecondition->Comment->IndexOf( L"Door N1", 0);
			int pos3 =  pPrecondition->Comment->IndexOf( L"Door N2", 0);
			if( wsText->Length > 0 && pos != -1 && pos1 > 0 && pos2 > -1 && pos3 > -1)
			{ // 4
				char* temp;
				msg = "There is a high risk on uncoherence related to the precondition ";
				chars = (const wchar_t*)(Marshal::StringToHGlobalUni( wsText)).ToPointer();
				wsTemp.append( chars);
				Marshal::FreeHGlobal(IntPtr((void*)chars));
				temp = objStrConv.awcstombs( (wchar_t *)wsTemp.c_str());
				msg += temp;
				objStrConv.StrFreeA( temp);
				msg += " and the precondition ";
				chars = (const wchar_t*)(Marshal::StringToHGlobalUni( pPrecondition->Comment)).ToPointer();
				wsTemp.append( chars);
				Marshal::FreeHGlobal(IntPtr((void*)chars));
				temp = objStrConv.awcstombs( (wchar_t *)wsTemp.c_str());
				msg += temp;
				objStrConv.StrFreeA( temp);
				msg += " What is to be done with the object's about Door N1 in the first précondition";
				throw Doc_exception( (const char *)msg.c_str(), nParagraph);
			} // 4
			else
			{ // 4
				wsText += pPrecondition->Comment;
			} // 4
		} // 3
		plistPreconditionNormalized = ReordonneListe( plistPreconditionNormalized);
		bool bCode = false;        
		if( bColorIsCoherent == true && bValueIsCoherent == true)
			bCode = true;
		else
			bCode = false;
		return( bCode);
    } // 1
elle est un peu longue mais par ellimintaion elle doit avoir une parenthèse ouvrante en trop?????
qui m'aidera sera