Forrest99 commited on
Commit
e8b72c0
·
verified ·
1 Parent(s): c75c587

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +300 -443
app.py CHANGED
@@ -14,449 +14,306 @@ app.logger = logging.getLogger("CodeSearchAPI")
14
  # 预定义代码片段
15
  CODE_SNIPPETS = [
16
 
17
- "public static void PrintText(string text) => Console.WriteLine(text)",
18
- "public static int Sum(int a, int b) => a + b",
19
- "public static int GenerateRandomNumber() => new Random().Next()",
20
- "public static bool IsEven(int number) => number % 2 == 0",
21
- "public static int GetStringLength(string str) => str.Length",
22
- "public static DateTime GetCurrentDate() => DateTime.Today",
23
- "public static bool FileExists(string path) => File.Exists(path)",
24
- "public static string ReadFileContent(string path) => File.ReadAllText(path)",
25
- "public static void WriteToFile(string path, string content) => File.WriteAllText(path, content)",
26
- "public static DateTime GetCurrentTime() => DateTime.Now",
27
- "public static string ToUpperCase(string str) => str.ToUpper()",
28
- "public static string ToLowerCase(string str) => str.ToLower()",
29
- "public static string ReverseString(string str) => new string(str.Reverse().ToArray())",
30
- "public static int CountListElements<T>(List<T> list) => list.Count",
31
- "public static T GetMaxValue<T>(List<T> list) where T : IComparable => list.Max()",
32
- "public static T GetMinValue<T>(List<T> list) where T : IComparable => list.Min()",
33
- "public static List<T> SortList<T>(List<T> list) where T : IComparable => list.OrderBy(x => x).ToList()",
34
- "public static List<T> MergeLists<T>(List<T> list1, List<T> list2) => list1.Concat(list2).ToList()",
35
- "public static List<T> RemoveElement<T>(List<T> list, T element) => list.Where(x => !x.Equals(element)).ToList()",
36
- "public static bool IsListEmpty<T>(List<T> list) => list.Count == 0",
37
- "public static int CountCharInString(string str, char c) => str.Count(x => x == c)",
38
- "public static bool ContainsSubstring(string str, string substring) => str.Contains(substring)",
39
- "public static string NumberToString(int number) => number.ToString()",
40
- "public static int StringToNumber(string str) => int.Parse(str)",
41
- "public static bool IsNumeric(string str) => int.TryParse(str, out _)",
42
- "public static int GetElementIndex<T>(List<T> list, T element) => list.IndexOf(element)",
43
- "public static void ClearList<T>(List<T> list) => list.Clear()",
44
- "public static List<T> ReverseList<T>(List<T> list) { list.Reverse(); return list; }",
45
- "public static List<T> RemoveDuplicates<T>(List<T> list) => list.Distinct().ToList()",
46
- "public static bool IsInList<T>(List<T> list, T value) => list.Contains(value)",
47
- "public static Dictionary<TKey, TValue> CreateDictionary<TKey, TValue>() => new Dictionary<TKey, TValue>()",
48
- "public static void AddToDictionary<TKey, TValue>(Dictionary<TKey, TValue> dict, TKey key, TValue value) => dict[key] = value",
49
- "public static void RemoveKey<TKey, TValue>(Dictionary<TKey, TValue> dict, TKey key) => dict.Remove(key)",
50
- "public static List<TKey> GetDictionaryKeys<TKey, TValue>(Dictionary<TKey, TValue> dict) => dict.Keys.ToList()",
51
- "public static List<TValue> GetDictionaryValues<TKey, TValue>(Dictionary<TKey, TValue> dict) => dict.Values.ToList()",
52
- "public static Dictionary<TKey, TValue> MergeDictionaries<TKey, TValue>(Dictionary<TKey, TValue> dict1, Dictionary<TKey, TValue> dict2) => dict1.Concat(dict2).ToDictionary(x => x.Key, x => x.Value)",
53
- "public static bool IsDictionaryEmpty<TKey, TValue>(Dictionary<TKey, TValue> dict) => dict.Count == 0",
54
- "public static TValue GetDictionaryValue<TKey, TValue>(Dictionary<TKey, TValue> dict, TKey key) => dict[key]",
55
- "public static bool KeyExistsInDictionary<TKey, TValue>(Dictionary<TKey, TValue> dict, TKey key) => dict.ContainsKey(key)",
56
- "public static void ClearDictionary<TKey, TValue>(Dictionary<TKey, TValue> dict) => dict.Clear()",
57
- "public static int CountFileLines(string path) => File.ReadAllLines(path).Length",
58
- "public static void WriteListToFile<T>(string path, List<T> list) => File.WriteAllLines(path, list.Select(x => x.ToString()))",
59
- "public static List<T> ReadListFromFile<T>(string path, Func<string, T> converter) => File.ReadAllLines(path).Select(converter).ToList()",
60
- "public static int CountFileWords(string path) => File.ReadAllText(path).Split(new[] { ' ', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).Length",
61
- "public static bool IsLeapYear(int year) => DateTime.IsLeapYear(year)",
62
- "public static string FormatDateTime(DateTime dateTime, string format) => dateTime.ToString(format)",
63
- "public static int DaysBetweenDates(DateTime date1, DateTime date2) => (date2 - date1).Days",
64
- "public static string GetCurrentDirectory() => Directory.GetCurrentDirectory()",
65
- "public static List<string> ListDirectoryFiles(string path) => Directory.GetFiles(path).ToList()",
66
- "public static void CreateDirectory(string path) => Directory.CreateDirectory(path)",
67
- "public static void DeleteDirectory(string path) => Directory.Delete(path)",
68
- "public static bool IsFilePath(string path) => File.Exists(path)",
69
- "public static bool IsDirectoryPath(string path) => Directory.Exists(path)",
70
- "public static long GetFileSize(string path) => new FileInfo(path).Length",
71
- "public static void RenameFile(string oldPath, string newPath) => File.Move(oldPath, newPath)",
72
- "public static void CopyFile(string sourcePath, string destinationPath) => File.Copy(sourcePath, destinationPath)",
73
- "public static void MoveFile(string sourcePath, string destinationPath) => File.Move(sourcePath, destinationPath)",
74
- "public static void DeleteFile(string path) => File.Delete(path)",
75
- "public static string GetEnvironmentVariable(string variable) => Environment.GetEnvironmentVariable(variable)",
76
- "public static void SetEnvironmentVariable(string variable, string value) => Environment.SetEnvironmentVariable(variable, value)",
77
- "public static void OpenWebLink(string url) => System.Diagnostics.Process.Start(url)",
78
- "public static string SendGetRequest(string url) => new System.Net.WebClient().DownloadString(url)",
79
- "public static T ParseJson<T>(string json) => System.Text.Json.JsonSerializer.Deserialize<T>(json)",
80
- "public static void WriteJsonToFile<T>(string path, T data) => File.WriteAllText(path, System.Text.Json.JsonSerializer.Serialize(data))",
81
- "public static T ReadJsonFromFile<T>(string path) => System.Text.Json.JsonSerializer.Deserialize<T>(File.ReadAllText(path))",
82
- "public static string ListToString<T>(List<T> list) => string.Join("", list)",
83
- "public static List<string> StringToList(string str) => str.ToCharArray().Select(c => c.ToString()).ToList()",
84
- "public static string JoinListWithComma<T>(List<T> list) => string.Join(",", list)",
85
- "public static string JoinListWithNewLine<T>(List<T> list) => string.Join(\"\n\", list)",
86
- "public static List<string> SplitStringBySpace(string str) => str.Split(' ').ToList()",
87
- "public static List<string> SplitStringByDelimiter(string str, char delimiter) => str.Split(delimiter).ToList()",
88
- "public static List<char> SplitStringToChars(string str) => str.ToCharArray().ToList()",
89
- "public static string ReplaceStringContent(string str, string oldValue, string newValue) => str.Replace(oldValue, newValue)",
90
- "public static string RemoveStringSpaces(string str) => str.Replace(" ", "")",
91
- "public static string RemoveStringPunctuation(string str) => new string(str.Where(c => !char.IsPunctuation(c)).ToArray())",
92
- "public static bool IsStringEmpty(string str) => string.IsNullOrEmpty(str)",
93
- "public static bool IsPalindrome(string str) => str.SequenceEqual(str.Reverse())",
94
- "public static void WriteTextToCsv(string path, List<string> lines) => File.WriteAllLines(path, lines)",
95
- "public static List<string> ReadCsvFile(string path) => File.ReadAllLines(path).ToList()",
96
- "public static int CountCsvLines(string path) => File.ReadAllLines(path).Length",
97
- "public static List<T> ShuffleList<T>(List<T> list) => list.OrderBy(x => Guid.NewGuid()).ToList()",
98
- "public static T GetRandomElement<T>(List<T> list) => list[new Random().Next(list.Count)]",
99
- "public static List<T> GetRandomElements<T>(List<T> list, int count) => list.OrderBy(x => Guid.NewGuid()).Take(count).ToList()",
100
- "public static int RollDice() => new Random().Next(1, 7)",
101
- "public static string FlipCoin() => new Random().Next(2) == 0 ? \"Heads\" : \"Tails\"",
102
- "public static string GenerateRandomPassword(int length) => new string(Enumerable.Repeat(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\", length).Select(s => s[new Random().Next(s.Length)]).ToArray())",
103
- "public static string GenerateRandomColor() => string.Format(\"#{0:X6}\", new Random().Next(0x1000000))",
104
- "public static string GenerateUniqueId() => Guid.NewGuid().ToString()",
105
- "public class MyClass { }",
106
- "public static MyClass CreateClassInstance() => new MyClass()",
107
- "public class MyClass { public void MyMethod() { } }",
108
- "public class MyClass { public string MyProperty { get; set; } }",
109
- "public class ChildClass : MyClass { }",
110
- "public class ChildClass : MyClass { public override void MyMethod() { } }",
111
- "public static void UseClassMethod(MyClass obj) => obj.MyMethod()",
112
- "public class MyClass { public static void StaticMethod() { } }",
113
- "public static bool IsObjectType<T>(object obj) => obj is T",
114
- "public static object GetObjectProperty(object obj, string propertyName) => obj.GetType().GetProperty(propertyName).GetValue(obj)",
115
- "public static void SetObjectProperty(object obj, string propertyName, object value) => obj.GetType().GetProperty(propertyName).SetValue(obj, value)",
116
- "public static void DeleteObjectProperty(object obj, string propertyName) => obj.GetType().GetProperty(propertyName).SetValue(obj, null)",
117
- """
118
- public static void TryCatchExample()
119
- {
120
- try { throw new Exception("Example exception"); }
121
- catch (Exception ex) { Console.WriteLine(ex.Message); }
122
- }
123
- """,
124
- """
125
- public static void ThrowCustomException() => throw new CustomException("Custom exception"),
126
- """,
127
- """
128
- public static string GetExceptionInfo(Exception ex) => ex.Message,
129
- """,
130
- """
131
- public static void LogError(Exception ex) => Console.WriteLine($"Error: {ex.Message}"),
132
- """,
133
- """
134
- public static System.Diagnostics.Stopwatch CreateTimer() => System.Diagnostics.Stopwatch.StartNew(),
135
- """,
136
- """
137
- public static long GetProgramRuntime(System.Diagnostics.Stopwatch timer) => timer.ElapsedMilliseconds,
138
- """,
139
- """
140
- public static void PrintProgressBar(int progress, int total)
141
- {
142
- float percentage = (float)progress / total;
143
- Console.Write($"\r[{'='.Repeat((int)(percentage * 20))}{' '.Repeat(20 - (int)(percentage * 20))}] {percentage * 100:F2}%");
144
- }
145
- """,
146
- """
147
- public static void Delay(int milliseconds) => System.Threading.Thread.Sleep(milliseconds),
148
- """,
149
- """
150
- public static Func<int, int> LambdaExample = x => x * x,
151
- """,
152
- """
153
- public static List<int> MapExample(List<int> list, Func<int, int> func) => list.Select(func).ToList(),
154
- """,
155
- """
156
- public static List<int> FilterExample(List<int> list, Func<int, bool> func) => list.Where(func).ToList(),
157
- """,
158
- """
159
- public static int ReduceExample(List<int> list, Func<int, int, int> func) => list.Aggregate(func),
160
- """,
161
- """
162
- public static List<int> ListComprehensionExample(List<int> list) => list.Select(x => x * 2).ToList(),
163
- """,
164
- """
165
- public static Dictionary<int, int> DictComprehensionExample(List<int> list) => list.ToDictionary(x => x, x => x * 2),
166
- """,
167
- """
168
- public static HashSet<int> SetComprehensionExample(List<int> list) => new HashSet<int>(list.Select(x => x * 2)),
169
- """,
170
- """
171
- public static HashSet<T> Intersection<T>(HashSet<T> set1, HashSet<T> set2) => new HashSet<T>(set1.Intersect(set2)),
172
- """,
173
- """
174
- public static HashSet<T> Union<T>(HashSet<T> set1, HashSet<T> set2) => new HashSet<T>(set1.Union(set2)),
175
- """,
176
- """
177
- public static HashSet<T> Difference<T>(HashSet<T> set1, HashSet<T> set2) => new HashSet<T>(set1.Except(set2)),
178
- """,
179
- """
180
- public static List<T> RemoveNulls<T>(List<T> list) => list.Where(x => x != null).ToList(),
181
- """,
182
- """
183
- public static bool TryOpenFile(string path)
184
- {
185
- try { using (var file = File.OpenRead(path)) return true; }
186
- catch { return false; }
187
- }
188
- """,
189
- """
190
- public static bool CheckVariableType<T>(object obj) => obj is T,
191
- """,
192
- """
193
- public static bool StringToBool(string str) => bool.Parse(str),
194
- """,
195
- """
196
- public static void IfExample(bool condition) { if (condition) Console.WriteLine("True"); },
197
- """,
198
- """
199
- public static void WhileExample(int count) { while (count-- > 0) Console.WriteLine(count); },
200
- """,
201
- """
202
- public static void ForEachListExample(List<int> list) { foreach (var item in list) Console.WriteLine(item); },
203
- """,
204
- """
205
- public static void ForEachDictExample(Dictionary<int, string> dict) { foreach (var kvp in dict) Console.WriteLine($"{kvp.Key}: {kvp.Value}"); },
206
- """,
207
- """
208
- public static void ForEachStringExample(string str) { foreach (var c in str) Console.WriteLine(c); },
209
- """,
210
- """
211
- public static void BreakExample(List<int> list)
212
- {
213
- foreach (var item in list) { if (item == 0) break; Console.WriteLine(item); }
214
- }
215
- """,
216
- """
217
- public static void ContinueExample(List<int> list)
218
- {
219
- foreach (var item in list) { if (item == 0) continue; Console.WriteLine(item); }
220
- }
221
- """,
222
- """
223
- public static void DefineFunction() => Console.WriteLine("Function defined"),
224
- """,
225
- """
226
- public static void FunctionWithDefault(int a = 10) => Console.WriteLine(a),
227
- """,
228
- """
229
- public static (int, int) ReturnMultipleValues() => (1, 2),
230
- """,
231
- """
232
- public static void VariableParams(params int[] numbers) => Console.WriteLine(numbers.Sum()),
233
- """,
234
- """
235
- public static void KeywordParams(int a, int b) => Console.WriteLine(a + b),
236
- """,
237
- """
238
- public static void MeasureFunctionTime(Action action)
239
- {
240
- var timer = System.Diagnostics.Stopwatch.StartNew();
241
- action();
242
- Console.WriteLine($"Time: {timer.ElapsedMilliseconds}ms");
243
- }
244
- """,
245
- """
246
- public static void DecorateFunction(Action action) => action(),
247
- """,
248
- """
249
- public static void CacheFunctionResult(Func<int> func) => func(),
250
- """,
251
- """
252
- public static IEnumerable<int> CreateGenerator()
253
- {
254
- for (int i = 0; i < 10; i++) yield return i;
255
- }
256
- """,
257
- """
258
- public static IEnumerable<int> YieldExample()
259
- {
260
- yield return 1;
261
- yield return 2;
262
- }
263
- """,
264
- """
265
- public static int NextExample(IEnumerator<int> enumerator) => enumerator.Current,
266
- """,
267
- """
268
- public static IEnumerator<int> CreateIterator(List<int> list) => list.GetEnumerator(),
269
- """,
270
- """
271
- public static void ManualIterate(IEnumerator<int> enumerator)
272
- {
273
- while (enumerator.MoveNext()) Console.WriteLine(enumerator.Current);
274
- }
275
- """,
276
- """
277
- public static void EnumerateExample(List<int> list)
278
- {
279
- foreach (var (index, value) in list.Select((v, i) => (i, v))) Console.WriteLine($"{index}: {value}");
280
- }
281
- """,
282
- """
283
- public static List<(int, int)> ZipExample(List<int> list1, List<int> list2) => list1.Zip(list2, (a, b) => (a, b)).ToList(),
284
- """,
285
- """
286
- public static Dictionary<int, int> ListsToDict(List<int> keys, List<int> values) => keys.Zip(values, (k, v) => new { k, v }).ToDictionary(x => x.k, x => x.v),
287
- """,
288
- """
289
- public static bool AreListsEqual(List<int> list1, List<int> list2) => list1.SequenceEqual(list2),
290
- """,
291
- """
292
- public static bool AreDictsEqual(Dictionary<int, int> dict1, Dictionary<int, int> dict2) => dict1.OrderBy(kvp => kvp.Key).SequenceEqual(dict2.OrderBy(kvp => kvp.Key)),
293
- """,
294
- """
295
- public static bool AreSetsEqual(HashSet<int> set1, HashSet<int> set2) => set1.SetEquals(set2),
296
- """,
297
- """
298
- public static HashSet<T> RemoveDuplicatesSet<T>(HashSet<T> set) => new HashSet<T>(set),
299
- """,
300
- """
301
- public static void ClearSet<T>(HashSet<T> set) => set.Clear(),
302
- """,
303
- """
304
- public static bool IsSetEmpty<T>(HashSet<T> set) => set.Count == 0,
305
- """,
306
- """
307
- public static void AddToSet<T>(HashSet<T> set, T item) => set.Add(item),
308
- """,
309
- """
310
- public static void RemoveFromSet<T>(HashSet<T> set, T item) => set.Remove(item),
311
- """,
312
- """
313
- public static bool SetContains<T>(HashSet<T> set, T item) => set.Contains(item),
314
- """,
315
- """
316
- public static int GetSetLength<T>(HashSet<T> set) => set.Count,
317
- """,
318
- """
319
- public static bool SetsIntersect<T>(HashSet<T> set1, HashSet<T> set2) => set1.Overlaps(set2),
320
- """,
321
- """
322
- public static bool IsSubset<T>(List<T> list1, List<T> list2) => list1.All(list2.Contains),
323
- """,
324
- """
325
- public static bool IsSubstring(string str, string substring) => str.Contains(substring),
326
- """,
327
- """
328
- public static char GetFirstChar(string str) => str[0],
329
- """,
330
- """
331
- public static char GetLastChar(string str) => str[^1],
332
- """,
333
- """
334
- public static bool IsTextFile(string path) => Path.GetExtension(path).ToLower() == ".txt",
335
- """,
336
- """
337
- public static bool IsImageFile(string path) => new[] { ".jpg", ".png", ".gif" }.Contains(Path.GetExtension(path).ToLower()),
338
- """,
339
- """
340
- public static double RoundNumber(double number) => Math.Round(number),
341
- """,
342
- """
343
- public static double CeilNumber(double number) => Math.Ceiling(number),
344
- """,
345
- """
346
- public static double FloorNumber(double number) => Math.Floor(number),
347
- """,
348
- """
349
- public static string FormatDecimal(double number, int decimals) => number.ToString($"F{decimals}"),
350
- """,
351
- """
352
- public static string GenerateRandomString(int length) => new string(Enumerable.Repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", length).Select(s => s[new Random().Next(s.Length)]).ToArray()),
353
- """,
354
- """
355
- public static bool PathExists(string path) => File.Exists(path) || Directory.Exists(path),
356
- """,
357
- """
358
- public static List<string> TraverseDirectory(string path) => Directory.GetFiles(path, "*", SearchOption.AllDirectories).ToList(),
359
- """,
360
- """
361
- public static string GetFileExtension(string path) => Path.GetExtension(path),
362
- """,
363
- """
364
- public static string GetFileName(string path) => Path.GetFileName(path),
365
- """,
366
- """
367
- public static string GetFullPath(string path) => Path.GetFullPath(path),
368
- """,
369
- """
370
- public static string GetPythonVersion() => Environment.Version.ToString(),
371
- """,
372
- """
373
- public static string GetSystemPlatform() => Environment.OSVersion.Platform.ToString(),
374
- """,
375
- """
376
- public static int GetCpuCores() => Environment.ProcessorCount,
377
- """,
378
- """
379
- public static long GetMemorySize() => GC.GetTotalMemory(false),
380
- """,
381
- """
382
- public static string GetDiskUsage() => new DriveInfo(Path.GetPathRoot(Environment.SystemDirectory)).AvailableFreeSpace.ToString(),
383
- """,
384
- """
385
- public static string GetIpAddress() => System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)?.ToString(),
386
- """,
387
- """
388
- public static bool IsConnectedToInternet() => System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable(),
389
- """,
390
- """
391
- public static void DownloadFile(string url, string path) => new System.Net.WebClient().DownloadFile(url, path),
392
- """,
393
- """
394
- public static void UploadFile(string url, string path) => new System.Net.WebClient().UploadFile(url, path),
395
- """,
396
- """
397
- public static string SendPostRequest(string url, string data) => new System.Net.WebClient().UploadString(url, "POST", data),
398
- """,
399
- """
400
- public static string SendRequestWithParams(string url, System.Collections.Specialized.NameValueCollection data) => new System.Net.WebClient().UploadValues(url, data),
401
- """,
402
- """
403
- public static void SetRequestHeader(System.Net.WebClient client, string key, string value) => client.Headers[key] = value,
404
- """,
405
- """
406
- public static string ParseHtml(string html) => new HtmlAgilityPack.HtmlDocument { Text = html }.DocumentNode.InnerText,
407
- """,
408
- """
409
- public static string ExtractHtmlTitle(string html) => new HtmlAgilityPack.HtmlDocument { Text = html }.DocumentNode.SelectSingleNode("//title")?.InnerText,
410
- """,
411
- """
412
- public static List<string> ExtractHtmlLinks(string html) => new HtmlAgilityPack.HtmlDocument { Text = html }.DocumentNode.SelectNodes("//a[@href]")?.Select(node => node.GetAttributeValue("href", "")).ToList(),
413
- """,
414
- """
415
- public static void DownloadHtmlImages(string html, string path)
416
- {
417
- var doc = new HtmlAgilityPack.HtmlDocument { Text = html };
418
- var images = doc.DocumentNode.SelectNodes("//img[@src]")?.Select(node => node.GetAttributeValue("src", "")).ToList();
419
- if (images != null) foreach (var img in images) new System.Net.WebClient().DownloadFile(img, Path.Combine(path, Path.GetFileName(img)));
420
- }
421
- """,
422
- """
423
- public static Dictionary<string, int> CountWordFrequency(string text) => text.Split(' ').GroupBy(word => word).ToDictionary(group => group.Key, group => group.Count()),
424
- """,
425
- """
426
- public static void SimulateLogin(string url, System.Collections.Specialized.NameValueCollection data) => new System.Net.WebClient().UploadValues(url, data),
427
- """,
428
- """
429
- public static string HtmlToText(string html) => new HtmlAgilityPack.HtmlDocument { Text = html }.DocumentNode.InnerText,
430
- """,
431
- """
432
- public static List<string> ExtractEmails(string text) => System.Text.RegularExpressions.Regex.Matches(text, @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*").Select(match => match.Value).ToList(),
433
- """,
434
- """
435
- public static List<string> ExtractPhoneNumbers(string text) => System.Text.RegularExpressions.Regex.Matches(text, @"\+?\d[\d -]{8,12}\d").Select(match => match.Value).ToList(),
436
- """,
437
- """
438
- public static List<string> FindAllNumbers(string text) => System.Text.RegularExpressions.Regex.Matches(text, @"\d+").Select(match => match.Value).ToList(),
439
- """,
440
- """
441
- public static string ReplaceWithRegex(string text, string pattern, string replacement) => System.Text.RegularExpressions.Regex.Replace(text, pattern, replacement),
442
- """,
443
- """
444
- public static bool IsRegexMatch(string text, string pattern) => System.Text.RegularExpressions.Regex.IsMatch(text, pattern),
445
- """,
446
- """
447
- public static string RemoveHtmlTags(string html) => System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", string.Empty),
448
- """,
449
- """
450
- public static string EncodeHtmlEntities(string text) => System.Net.WebUtility.HtmlEncode(text),
451
- """,
452
- """
453
- public static string DecodeHtmlEntities(string text) => System.Net.WebUtility.HtmlDecode(text),
454
- """,
455
- """
456
- public static void CreateGuiWindow() => new System.Windows.Forms.Form().ShowDialog(),
457
- """,
458
- "public static void AddButtonToWindow(Form form, string text, int x, int y, EventHandler onClick) { Button button = new Button(); button.Text = text; button.Location = new Point(x, y); button.Click += onClick; form.Controls.Add(button); }", "public static void ShowMessageBox(string message) { MessageBox.Show(message); }", "public static string GetTextBoxText(TextBox textBox) { return textBox.Text; }", "public static void SetWindowTitle(Form form, string title) { form.Text = title; }", "public static void SetWindowSize(Form form, int width, int height) { form.Size = new Size(width, height); }", "public static void CenterWindow(Form form) { form.StartPosition = FormStartPosition.CenterScreen; }", "public static void AddMenuStrip(Form form, ToolStripMenuItem menuItem) { MenuStrip menuStrip = new MenuStrip(); menuStrip.Items.Add(menuItem); form.Controls.Add(menuStrip); }", "public static void AddComboBox(Form form, int x, int y, EventHandler onSelectedIndexChanged) { ComboBox comboBox = new ComboBox(); comboBox.Location = new Point(x, y); comboBox.SelectedIndexChanged += onSelectedIndexChanged; form.Controls.Add(comboBox); }", "public static void AddRadioButton(Form form, string text, int x, int y) { RadioButton radioButton = new RadioButton(); radioButton.Text = text; radioButton.Location = new Point(x, y); form.Controls.Add(radioButton); }", "public static void AddCheckBox(Form form, string text, int x, int y) { CheckBox checkBox = new CheckBox(); checkBox.Text = text; checkBox.Location = new Point(x, y); form.Controls.Add(checkBox); }", "public static void DisplayImage(Form form, string imagePath, int x, int y) { PictureBox pictureBox = new PictureBox(); pictureBox.Image = Image.FromFile(imagePath); pictureBox.Location = new Point(x, y); form.Controls.Add(pictureBox); }", "public static void PlayAudioFile(string filePath) { SoundPlayer player = new SoundPlayer(filePath); player.Play(); }", "public static void PlayVideoFile(Form form, string filePath, int x, int y) { AxWMPLib.AxWindowsMediaPlayer player = new AxWMPLib.AxWindowsMediaPlayer(); player.CreateControl(); player.URL = filePath; player.Location = new Point(x, y); form.Controls.Add(player); }", "public static TimeSpan GetCurrentPlayTime(AxWMPLib.AxWindowsMediaPlayer player) { return player.Ctlcontrols.currentPosition; }", "public static void CaptureScreen(string filePath) { Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Graphics graphics = Graphics.FromImage(bitmap); graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size); bitmap.Save(filePath); }", "public static void RecordScreen(string filePath, int duration) { // Simulated implementation }", "public static Point GetMousePosition() { return Cursor.Position; }", "public static void SimulateKeyboardInput(string text) { SendKeys.SendWait(text); }", "public static void SimulateMouseClick(int x, int y) { Cursor.Position = new Point(x, y); mouse_event(0x0002 | 0x0004, x, y, 0, 0); }", "public static long GetCurrentTimestamp() { return DateTimeOffset.UtcNow.ToUnixTimeSeconds(); }", "public static DateTime TimestampToDate(long timestamp) { return DateTimeOffset.FromUnixTimeSeconds(timestamp).DateTime; }", "public static long DateToTimestamp(DateTime date) { return new DateTimeOffset(date).ToUnixTimeSeconds(); }", "public static string GetCurrentDayOfWeek() { return DateTime.Now.DayOfWeek.ToString(); }", "public static int GetDaysInCurrentMonth() { return DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); }", "public static DateTime GetFirstDayOfYear() { return new DateTime(DateTime.Now.Year, 1, 1); }", "public static DateTime GetLastDayOfYear() { return new DateTime(DateTime.Now.Year, 12, 31); }", "public static DateTime GetFirstDayOfMonth(int year, int month) { return new DateTime(year, month, 1); }", "public static DateTime GetLastDayOfMonth(int year, int month) { return new DateTime(year, month, DateTime.DaysInMonth(year, month)); }", "public static bool IsWeekday() { DayOfWeek day = DateTime.Now.DayOfWeek; return day != DayOfWeek.Saturday && day != DayOfWeek.Sunday; }", "public static bool IsWeekend() { DayOfWeek day = DateTime.Now.DayOfWeek; return day == DayOfWeek.Saturday || day == DayOfWeek.Sunday; }", "public static int GetCurrentHour() { return DateTime.Now.Hour; }", "public static int GetCurrentMinute() { return DateTime.Now.Minute; }", "public static int GetCurrentSecond() { return DateTime.Now.Second; }", "public static void DelayOneSecond() { Thread.Sleep(1000); }", "public static long GetMillisecondTimestamp() { return DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); }", "public static string FormatTimeToString(DateTime date, string format) { return date.ToString(format); }", "public static DateTime ParseStringToTime(string dateString, string format) { return DateTime.ParseExact(dateString, format, CultureInfo.InvariantCulture); }", "public static void CreateThread(ThreadStart start) { Thread thread = new Thread(start); thread.Start(); }", "public static void PauseThread(Thread thread) { thread.Suspend(); }", "public static void RunFunctionInThread(ThreadStart start) { Thread thread = new Thread(start); thread.Start(); }", "public static string GetCurrentThreadName() { return Thread.CurrentThread.Name; }", "public static void SetThreadAsDaemon(Thread thread) { thread.IsBackground = true; }", "public static void LockThread(object lockObject, Action action) { lock (lockObject) { action(); } }", "public static void CreateProcess(string fileName) { Process.Start(fileName); }", "public static int GetProcessId() { return Process.GetCurrentProcess().Id; }", "public static bool IsProcessAlive(int processId) { try { Process.GetProcessById(processId); return true; } catch { return false; } }", "public static void RunFunctionInProcess(Action action) { Task.Run(action); }", "public static void UseQueueToPassValue<T>(Queue<T> queue, T value) { queue.Enqueue(value); }", "public static void UsePipeToCommunicate() { // Simulated implementation }", "public static void LimitCpuUsage() { // Simulated implementation }", "public static void RunShellCommand(string command) { Process.Start(\"cmd.exe\", \"/c \" + command); }", "public static string GetCommandOutput(string command) { Process process = new Process(); process.StartInfo.FileName = \"cmd.exe\"; process.StartInfo.Arguments = \"/c \" + command; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.UseShellExecute = false; process.Start(); return process.StandardOutput.ReadToEnd(); }", "public static int GetCommandExitCode(string command) { Process process = Process.Start(\"cmd.exe\", \"/c \" + command); process.WaitForExit(); return process.ExitCode; }", "public static bool IsCommandSuccessful(string command) { return GetCommandExitCode(command) == 0; }", "public static string GetCurrentScriptPath() { return Assembly.GetExecutingAssembly().Location; }", "public static string[] GetCommandLineArgs() { return Environment.GetCommandLineArgs(); }", "public static void UseArgParse() { // Simulated implementation }", "public static void GenerateCommandHelp() { // Simulated implementation }", "public static void ListPythonModules() { // Simulated implementation }", "public static void InstallPythonPackage(string package) { // Simulated implementation }", "public static void UninstallPythonPackage(string package) { // Simulated implementation }", "public static string GetPackageVersion(string package) { // Simulated implementation return \"\"; }", "public static void UseVirtualEnvironment() { // Simulated implementation }", "public static void ListInstalledPackages() { // Simulated implementation }", "public static void UpgradePythonPackage(string package) { // Simulated implementation }", "public static void ConnectToLocalDatabase(string connectionString) { SqlConnection connection = new SqlConnection(connectionString); connection.Open(); }", "public static DataTable ExecuteSqlQuery(SqlConnection connection, string query) { SqlCommand command = new SqlCommand(query, connection); SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable table = new DataTable(); adapter.Fill(table); return table; }", "public static void InsertRecord(SqlConnection connection, string table, Dictionary<string, object> values) { string columns = string.Join(\",\", values.Keys); string parameters = string.Join(\",\", values.Keys.Select(k => \"@\" + k)); string query = $\"INSERT INTO {table} ({columns}) VALUES ({parameters})\"; SqlCommand command = new SqlCommand(query, connection); foreach (var pair in values) { command.Parameters.AddWithValue(\"@\" + pair.Key, pair.Value); } command.ExecuteNonQuery(); }", "public static void DeleteRecord(SqlConnection connection, string table, string condition) { string query = $\"DELETE FROM {table} WHERE {condition}\"; SqlCommand command = new SqlCommand(query, connection); command.ExecuteNonQuery(); }", "public static void UpdateRecord(SqlConnection connection, string table, Dictionary<string, object> values, string condition) { string setClause = string.Join(\",\", values.Keys.Select(k => $\"{k} = @{k}\")); string query = $\"UPDATE {table} SET {setClause} WHERE {condition}\"; SqlCommand command = new SqlCommand(query, connection); foreach (var pair in values) { command.Parameters.AddWithValue(\"@\" + pair.Key, pair.Value); } command.ExecuteNonQuery(); }", "public static DataTable QueryMultipleRecords(SqlConnection connection, string query) { SqlCommand command = new SqlCommand(query, connection); SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable table = new DataTable(); adapter.Fill(table); return table; }", "public static void UseParameterizedQuery(SqlConnection connection, string query, Dictionary<string, object> parameters) { SqlCommand command = new SqlCommand(query, connection); foreach (var pair in parameters) { command.Parameters.AddWithValue(\"@\" + pair.Key, pair.Value); } command.ExecuteNonQuery(); }", "public static void CloseDatabaseConnection(SqlConnection connection) { connection.Close(); }", "public static void CreateDatabaseTable(SqlConnection connection, string table, Dictionary<string, string> columns) { string columnDefinitions = string.Join(\",\", columns.Select(pair => $\"{pair.Key} {pair.Value}\")); string query = $\"CREATE TABLE {table} ({columnDefinitions})\"; SqlCommand command = new SqlCommand(query, connection); command.ExecuteNonQuery(); }", "public static void DeleteDatabaseTable(SqlConnection connection, string table) { string query = $\"DROP TABLE {table}\"; SqlCommand command = new SqlCommand(query, connection); command.ExecuteNonQuery(); }", "public static bool TableExists(SqlConnection connection, string table) { string query = $\"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{table}'\"; SqlCommand command = new SqlCommand(query, connection); return command.ExecuteScalar() != null; }", "public static DataTable GetAllTables(SqlConnection connection) { string query = \"SELECT * FROM INFORMATION_SCHEMA.TABLES\"; SqlCommand command = new SqlCommand(query, connection); SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable table = new DataTable(); adapter.Fill(table); return table; }", "public static void UseOrmInsertData<T>(DbContext context, T entity) where T : class { context.Set<T>().Add(entity); context.SaveChanges(); }", "public static List<T> UseOrmQueryData<T>(DbContext context) where T : class { return context.Set<T>().ToList(); }", "public static void UseOrmDeleteData<T>(DbContext context, T entity) where T : class { context.Set<T>().Remove(entity); context.SaveChanges(); }", "public static void UseOrmUpdateData<T>(DbContext context, T entity) where T : class { context.Set<T>().Update(entity); context.SaveChanges(); }", "public static void DefineDatabaseModelClass() { // Simulated implementation }", "public static void ImplementModelClassInheritance() { // Simulated implementation }", "public static void SetPrimaryKeyField() { // Simulated implementation }", "public static void SetUniqueConstraint() { // Simulated implementation }", "public static void SetFieldDefaultValue() { // Simulated implementation }", "public static void ExportDataToCsv(DataTable table, string filePath) { StringBuilder sb = new StringBuilder(); foreach (DataRow row in table.Rows) { sb.AppendLine(string.Join(\",\", row.ItemArray)); } File.WriteAllText(filePath, sb.ToString()); }", "public static void ExportDataToExcel(DataTable table, string filePath) { // Simulated implementation }", "public static void ExportDataToJson(DataTable table, string filePath) { string json = JsonConvert.SerializeObject(table); File.WriteAllText(filePath, json); }", "public static DataTable ReadDataFromExcel(string filePath) { // Simulated implementation return new DataTable(); }", "public static void MergeExcelFiles(List<string> filePaths, string outputPath) { // Simulated implementation }", "public static void AddNewSheetToExcel(string filePath, string sheetName) { // Simulated implementation }", "public static void CopyExcelSheetStyle(string sourceFilePath, string targetFilePath) { // Simulated implementation }", "public static void SetExcelCellColor(string filePath, string sheetName, int row, int column, string color) { // Simulated implementation }", "public static void SetExcelFontStyle(string filePath, string sheetName, int row, int column, string fontName, int fontSize) { // Simulated implementation }", "public static string ReadExcelCellContent(string filePath, string sheetName, int row, int column) { // Simulated implementation return \"\"; }", "public static void WriteExcelCellContent(string filePath, string sheetName, int row, int column, string content) { // Simulated implementation }", "public static Size GetImageDimensions(string imagePath) { Image image = Image.FromFile(imagePath); return image.Size; }", "public static void ResizeImage(string imagePath, string outputPath, int width, int height) { Image image = Image.FromFile(imagePath); Bitmap resizedImage = new Bitmap(image, width, height); resizedImage.Save(outputPath); }"
459
-
460
 
461
 
462
 
 
14
  # 预定义代码片段
15
  CODE_SNIPPETS = [
16
 
17
+ "void printText(const std::string& text) { std::cout << text; }",
18
+ "int sum(int a, int b) { return a + b; }",
19
+ "int generateRandomNumber() { return rand(); }",
20
+ "bool isEven(int num) { return num % 2 == 0; }",
21
+ "size_t getStringLength(const std::string& str) { return str.length(); }",
22
+ "std::string getCurrentDate() { time_t now = time(0); return ctime(&now); }",
23
+ "bool fileExists(const std::string& filename) { std::ifstream file(filename); return file.good(); }",
24
+ "std::string readFileContent(const std::string& filename) { std::ifstream file(filename); std::string content((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>()); return content; }",
25
+ "void writeToFile(const std::string& filename, const std::string& content) { std::ofstream file(filename); file << content; }",
26
+ "std::string getCurrentTime() { time_t now = time(0); return ctime(&now); }",
27
+ "std::string toUpper(const std::string& str) { std::string result = str; std::transform(result.begin(), result.end(), result.begin(), ::toupper); return result; }",
28
+ "std::string toLower(const std::string& str) { std::string result = str; std::transform(result.begin(), result.end(), result.begin(), ::tolower); return result; }",
29
+ "std::string reverseString(const std::string& str) { std::string result = str; std::reverse(result.begin(), result.end()); return result; }",
30
+ "size_t countListElements(const std::vector<int>& list) { return list.size(); }",
31
+ "int findMax(const std::vector<int>& list) { return *std::max_element(list.begin(), list.end()); }",
32
+ "int findMin(const std::vector<int>& list) { return *std::min_element(list.begin(), list.end()); }",
33
+ "void sortList(std::vector<int>& list) { std::sort(list.begin(), list.end()); }",
34
+ "std::vector<int> mergeLists(const std::vector<int>& list1, const std::vector<int>& list2) { std::vector<int> result = list1; result.insert(result.end(), list2.begin(), list2.end()); return result; }",
35
+ "void removeElementFromList(std::vector<int>& list, int element) { list.erase(std::remove(list.begin(), list.end(), element), list.end()); }",
36
+ "bool isListEmpty(const std::vector<int>& list) { return list.empty(); }",
37
+ "size_t countCharInString(const std::string& str, char ch) { return std::count(str.begin(), str.end(), ch); }",
38
+ "bool containsSubstring(const std::string& str, const std::string& substr) { return str.find(substr) != std::string::npos; }",
39
+ "std::string numToString(int num) { return std::to_string(num); }",
40
+ "int stringToNum(const std::string& str) { return std::stoi(str); }",
41
+ "bool isNumeric(const std::string& str) { return !str.empty() && std::all_of(str.begin(), str.end(), ::isdigit); }",
42
+ "int getIndexInList(const std::vector<int>& list, int element) { auto it = std::find(list.begin(), list.end(), element); return it != list.end() ? std::distance(list.begin(), it) : -1; }",
43
+ "void clearList(std::vector<int>& list) { list.clear(); }",
44
+ "void reverseList(std::vector<int>& list) { std::reverse(list.begin(), list.end()); }",
45
+ "std::vector<int> removeDuplicatesFromList(const std::vector<int>& list) { std::set<int> s(list.begin(), list.end()); return std::vector<int>(s.begin(), s.end()); }",
46
+ "bool isInList(const std::vector<int>& list, int value) { return std::find(list.begin(), list.end(), value) != list.end(); }",
47
+ "std::map<std::string, int> createDict() { return {}; }",
48
+ "void addToDict(std::map<std::string, int>& dict, const std::string& key, int value) { dict[key] = value; }",
49
+ "void removeKeyFromDict(std::map<std::string, int>& dict, const std::string& key) { dict.erase(key); }",
50
+ "std::vector<std::string> getDictKeys(const std::map<std::string, int>& dict) { std::vector<std::string> keys; for (const auto& pair : dict) keys.push_back(pair.first); return keys; }",
51
+ "std::vector<int> getDictValues(const std::map<std::string, int>& dict) { std::vector<int> values; for (const auto& pair : dict) values.push_back(pair.second); return values; }",
52
+ "std::map<std::string, int> mergeDicts(const std::map<std::string, int>& dict1, const std::map<std::string, int>& dict2) { std::map<std::string, int> result = dict1; result.insert(dict2.begin(), dict2.end()); return result; }",
53
+ "bool isDictEmpty(const std::map<std::string, int>& dict) { return dict.empty(); }",
54
+ "int getValueFromDict(const std::map<std::string, int>& dict, const std::string& key) { return dict.at(key); }",
55
+ "bool keyExistsInDict(const std::map<std::string, int>& dict, const std::string& key) { return dict.find(key) != dict.end(); }",
56
+ "void clearDict(std::map<std::string, int>& dict) { dict.clear(); }",
57
+ "size_t countFileLines(const std::string& filename) { std::ifstream file(filename); return std::count(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), '\n'); }",
58
+ "void writeListToFile(const std::string& filename, const std::vector<int>& list) { std::ofstream file(filename); for (int elem : list) file << elem << std::endl; }",
59
+ "std::vector<int> readListFromFile(const std::string& filename) { std::ifstream file(filename); std::vector<int> list; int elem; while (file >> elem) list.push_back(elem); return list; }",
60
+ "size_t countWordsInFile(const std::string& filename) { std::ifstream file(filename); std::string word; size_t count = 0; while (file >> word) count++; return count; }",
61
+ "bool isLeapYear(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); }",
62
+ "std::string formatTime(const std::string& format) { char buffer[80]; time_t now = time(0); strftime(buffer, sizeof(buffer), format.c_str(), localtime(&now)); return buffer; }",
63
+ "int daysBetweenDates(const std::string& date1, const std::string& date2) { struct tm tm1 = {}, tm2 = {}; strptime(date1.c_str(), \"%Y-%m-%d\", &tm1); strptime(date2.c_str(), \"%Y-%m-%d\", &tm2); time_t time1 = mktime(&tm1), time2 = mktime(&tm2); return difftime(time2, time1) / (60 * 60 * 24); }",
64
+ "std::string getCurrentWorkingDirectory() { char buffer[FILENAME_MAX]; getcwd(buffer, FILENAME_MAX); return buffer; }",
65
+ "std::vector<std::string> listFilesInDirectory(const std::string& path) { std::vector<std::string> files; for (const auto& entry : std::filesystem::directory_iterator(path)) files.push_back(entry.path().filename().string()); return files; }",
66
+ "void createDirectory(const std::string& path) { std::filesystem::create_directory(path); }",
67
+ "void deleteDirectory(const std::string& path) { std::filesystem::remove_all(path); }",
68
+ "bool isFile(const std::string& path) { return std::filesystem::is_regular_file(path); }",
69
+ "bool isDirectory(const std::string& path) { return std::filesystem::is_directory(path); }",
70
+ "size_t getFileSize(const std::string& filename) { return std::filesystem::file_size(filename); }",
71
+ "void renameFile(const std::string& oldName, const std::string& newName) { std::filesystem::rename(oldName, newName); }",
72
+ "void copyFile(const std::string& src, const std::string& dest) { std::filesystem::copy(src, dest); }",
73
+ "void moveFile(const std::string& src, const std::string& dest) { std::filesystem::rename(src, dest); }",
74
+ "void deleteFile(const std::string& filename) { std::filesystem::remove(filename); }",
75
+ "std::string getEnvVariable(const std::string& var) { const char* value = std::getenv(var.c_str()); return value ? value : \"\"; }",
76
+ "void setEnvVariable(const std::string& var, const std::string& value) { setenv(var.c_str(), value.c_str(), 1); }",
77
+ "void openWebLink(const std::string& url) { std::string command = \"xdg-open \" + url; system(command.c_str()); }",
78
+ "std::string sendGetRequest(const std::string& url) { std::string command = \"curl -s \" + url; std::string result; FILE* pipe = popen(command.c_str(), \"r\"); char buffer[128]; while (fgets(buffer, sizeof(buffer), pipe) != NULL) result += buffer; pclose(pipe); return result; }",
79
+ "nlohmann::json parseJson(const std::string& jsonStr) { return nlohmann::json::parse(jsonStr); }",
80
+ "void writeJsonToFile(const std::string& filename, const nlohmann::json& jsonData) { std::ofstream file(filename); file << jsonData.dump(4); }",
81
+ "nlohmann::json readJsonFromFile(const std::string& filename) { std::ifstream file(filename); return nlohmann::json::parse(file); }",
82
+ "std::string listToString(const std::vector<std::string>& list) { std::string result; for (const auto& elem : list) result += elem; return result; }",
83
+ "std::vector<std::string> stringToList(const std::string& str) { std::vector<std::string> list; std::stringstream ss(str); std::string item; while (std::getline(ss, item, ' ')) list.push_back(item); return list; }",
84
+ "std::string joinListWithComma(const std::vector<std::string>& list) { std::string result; for (size_t i = 0; i < list.size(); i++) { result += list[i]; if (i != list.size() - 1) result += \",\"; } return result; }",
85
+ "std::string joinListWithNewline(const std::vector<std::string>& list) { std::string result; for (const auto& elem : list) result += elem + \"\\n\"; return result; }",
86
+ "std::vector<std::string> splitStringBySpace(const std::string& str) { std::vector<std::string> tokens; std::stringstream ss(str); std::string token; while (ss >> token) tokens.push_back(token); return tokens; }",
87
+ "std::vector<std::string> splitStringByDelimiter(const std::string& str, char delimiter) { std::vector<std::string> tokens; std::stringstream ss(str); std::string token; while (std::getline(ss, token, delimiter)) tokens.push_back(token); return tokens; }",
88
+ "std::vector<char> splitStringToChars(const std::string& str) { return std::vector<char>(str.begin(), str.end()); }",
89
+ "std::string replaceInString(const std::string& str, const std::string& oldStr, const std::string& newStr) { std::string result = str; size_t pos = 0; while ((pos = result.find(oldStr, pos)) != std::string::npos) { result.replace(pos, oldStr.length(), newStr); pos += newStr.length(); } return result; }",
90
+ "std::string removeSpaces(const std::string& str) { std::string result = str; result.erase(std::remove(result.begin(), result.end(), ' '), result.end()); return result; }",
91
+ "std::string removePunctuation(const std::string& str) { std::string result = str; result.erase(std::remove_if(result.begin(), result.end(), ::ispunct), result.end()); return result; }",
92
+ "bool isStringEmpty(const std::string& str) { return str.empty(); }",
93
+ "bool isPalindrome(const std::string& str) { std::string reversed = str; std::reverse(reversed.begin(), reversed.end()); return str == reversed; }",
94
+ "void writeToCsv(const std::string& filename, const std::vector<std::vector<std::string>>& data) { std::ofstream file(filename); for (const auto& row : data) { for (size_t i = 0; i < row.size(); i++) { file << row[i]; if (i != row.size() - 1) file << \",\"; } file << \"\\n\"; } }",
95
+ "std::vector<std::vector<std::string>> readFromCsv(const std::string& filename) { std::vector<std::vector<std::string>> data; std::ifstream file(filename); std::string line; while (std::getline(file, line)) { std::vector<std::string> row; std::stringstream ss(line); std::string cell; while (std::getline(ss, cell, ',')) row.push_back(cell); data.push_back(row); } return data; }",
96
+ "size_t countCsvLines(const std::string& filename) { std::ifstream file(filename); return std::count(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), '\n'); }",
97
+ "void shuffleList(std::vector<int>& list) { std::shuffle(list.begin(), list.end(), std::default_random_engine(std::chrono::system_clock::now().time_since_epoch().count())); }",
98
+ "int pickRandomElement(const std::vector<int>& list) { return list[rand() % list.size()]; }",
99
+ "std::vector<int> pickRandomElements(const std::vector<int>& list, size_t count) { std::vector<int> result = list; std::shuffle(result.begin(), result.end(), std::default_random_engine(std::chrono::system_clock::now().time_since_epoch().count())); result.resize(count); return result; }",
100
+ "int rollDice() { return rand() % 6 + 1; }",
101
+ "std::string flipCoin() { return rand() % 2 == 0 ? \"Heads\" : \"Tails\"; }",
102
+ "std::string generateRandomPassword(size_t length) { const std::string chars = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\"; std::string password; for (size_t i = 0; i < length; i++) password += chars[rand() % chars.length()]; return password; }",
103
+ "std::string generateRandomColor() { const std::string hexChars = \"0123456789ABCDEF\"; std::string color = \"#\"; for (int i = 0; i < 6; i++) color += hexChars[rand() % hexChars.length()]; return color; }",
104
+ "std::string generateUniqueId() { return std::to_string(std::chrono::system_clock::now().time_since_epoch().count()); }",
105
+ "class MyClass {};",
106
+ "MyClass createClassInstance() { return MyClass(); }",
107
+ "class MyClass { public: void myMethod() {} };",
108
+ "class MyClass { public: int myProperty; };",
109
+ "class ChildClass : public MyClass {};",
110
+ "class ChildClass : public MyClass { public: void myMethod() override {} };",
111
+ "class MyClass { public: static void myClassMethod() {} };",
112
+ "class MyClass { public: static void myStaticMethod() {} };",
113
+ "template <typename T> bool isType(const T& obj, const std::type_info& type) { return typeid(obj) == type; }",
114
+ "template <typename T> auto getProperty(const T& obj, const std::string& prop) { return obj.*prop; }",
115
+ "template <typename T> void setProperty(T& obj, const std::string& prop, const auto& value) { obj.*prop = value; }",
116
+ "template <typename T> void deleteProperty(T& obj, const std::string& prop) { obj.*prop = nullptr; }",
117
+ "void handleException() { try { throw std::runtime_error(\"Error occurred\"); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; }}",
118
+ "void throwCustomException() { throw std::runtime_error(\"Custom error\"); }",
119
+ "void getExceptionInfo() { try { throw std::runtime_error(\"Error occurred\"); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; }}",
120
+ "void logError(const std::string& message) { std::cerr << \"Error: \" << message << std::endl; }",
121
+ "class Timer { public: Timer() : start(std::chrono::high_resolution_clock::now()) {} double elapsed() { return std::chrono::duration<double>(std::chrono::high_resolution_clock::now() - start).count(); } private: std::chrono::time_point<std::chrono::high_resolution_clock> start; };",
122
+ "double getRuntime() { static Timer timer; return timer.elapsed(); }",
123
+ "void printProgressBar(int progress, int total) { float percentage = static_cast<float>(progress) / total; int barWidth = 50; std::cout << \"[\"; int pos = barWidth * percentage; for (int i = 0; i < barWidth; ++i) { if (i < pos) std::cout << \"=\"; else if (i == pos) std::cout << \">\"; else std::cout << \" \"; } std::cout << \"] \" << int(percentage * 100.0) << \" %\\r\"; std::cout.flush(); }",
124
+ "void delay(int milliseconds) { std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); }",
125
+ "auto lambda = [](int x) { return x * x; };",
126
+ "std::vector<int> mapFunc(const std::vector<int>& vec, std::function<int(int)> func) { std::vector<int> result; for (int x : vec) result.push_back(func(x)); return result; }",
127
+ "std::vector<int> filterFunc(const std::vector<int>& vec, std::function<bool(int)> func) { std::vector<int> result; for (int x : vec) if (func(x)) result.push_back(x); return result; }",
128
+ "int reduceFunc(const std::vector<int>& vec, std::function<int(int, int)> func, int init) { int result = init; for (int x : vec) result = func(result, x); return result; }",
129
+ "std::vector<int> listComprehension(const std::vector<int>& vec) { std::vector<int> result; for (int x : vec) if (x % 2 == 0) result.push_back(x); return result; }",
130
+ "std::map<int, int> dictComprehension(const std::vector<int>& vec) { std::map<int, int> result; for (int x : vec) result[x] = x * x; return result; }",
131
+ "std::set<int> setComprehension(const std::vector<int>& vec) { std::set<int> result; for (int x : vec) if (x % 2 == 0) result.insert(x); return result; }",
132
+ "std::set<int> setIntersection(const std::set<int>& set1, const std::set<int>& set2) { std::set<int> result; std::set_intersection(set1.begin(), set1.end(), set2.begin(), set2.end(), std::inserter(result, result.begin())); return result; }",
133
+ "std::set<int> setUnion(const std::set<int>& set1, const std::set<int>& set2) { std::set<int> result; std::set_union(set1.begin(), set1.end(), set2.begin(), set2.end(), std::inserter(result, result.begin())); return result; }",
134
+ "std::set<int> setDifference(const std::set<int>& set1, const std::set<int>& set2) { std::set<int> result; std::set_difference(set1.begin(), set1.end(), set2.begin(), set2.end(), std::inserter(result, result.begin())); return result; }",
135
+ "std::vector<int> removeNullValues(const std::vector<int>& vec) { std::vector<int> result; for (int x : vec) if (x != 0) result.push_back(x); return result; }",
136
+ "bool tryOpenFile(const std::string& filename) { std::ifstream file(filename); return file.is_open(); }",
137
+ "template <typename T> bool checkType(const T& var) { return typeid(var).name() == typeid(T).name(); }",
138
+ "bool strToBool(const std::string& str) { return str == \"true\" || str == \"1\"; }",
139
+ "void ifCondition(int x) { if (x > 0) std::cout << \"Positive\" << std::endl; }",
140
+ "void whileLoop(int x) { while (x-- > 0) std::cout << x << std::endl; }",
141
+ "void forLoopList(const std::vector<int>& vec) { for (int x : vec) std::cout << x << std::endl; }",
142
+ "void forLoopDict(const std::map<int, int>& dict) { for (const auto& pair : dict) std::cout << pair.first << \": \" << pair.second << std::endl; }",
143
+ "void forLoopString(const std::string& str) { for (char c : str) std::cout << c << std::endl; }",
144
+ "void breakLoop() { for (int i = 0; i < 10; ++i) { if (i == 5) break; std::cout << i << std::endl; } }",
145
+ "void continueLoop() { for (int i = 0; i < 10; ++i) { if (i == 5) continue; std::cout << i << std::endl; } }",
146
+ "void defineFunction() { std::cout << \"Function defined\" << std::endl; }",
147
+ "void functionWithDefault(int x = 10) { std::cout << x << std::endl; }",
148
+ "std::pair<int, int> returnMultipleValues() { return {1, 2}; }",
149
+ "template <typename... Args> void variadicFunction(Args... args) { (std::cout << ... << args) << std::endl; }",
150
+ "void keywordArguments(int x, int y) { std::cout << x << \", \" << y << std::endl; }",
151
+ "void logFunctionTime(std::function<void()> func) { Timer timer; func(); std::cout << \"Time elapsed: \" << timer.elapsed() << \"s\" << std::endl; }",
152
+ "template <typename Func> void decorator(Func func) { std::cout << \"Before\" << std::endl; func(); std::cout << \"After\" << std::endl; }",
153
+ "template <typename Func> auto cacheFunction(Func func) { static std::map<std::string, decltype(func())> cache; return [func](const std::string& key) { if (cache.find(key) == cache.end()) cache[key] = func(); return cache[key]; }; }",
154
+ "class Generator { public: Generator() : value(0) {} int next() { return value++; } private: int value; };",
155
+ "int yieldValue() { static int value = 0; return value++; }",
156
+ "int getNextValue() { static int value = 0; return value++; }",
157
+ "class Iterator { public: Iterator(const std::vector<int>& vec) : vec(vec), index(0) {} int next() { return vec[index++]; } bool hasNext() { return index < vec.size(); } private: std::vector<int> vec; int index; };",
158
+ "void manualIterate(const std::vector<int>& vec) { Iterator it(vec); while (it.hasNext()) std::cout << it.next() << std::endl; }",
159
+ "void enumerateList(const std::vector<int>& vec) { for (int i = 0; i < vec.size(); ++i) std::cout << i << \": \" << vec[i] << std::endl; }",
160
+ "std::vector<std::pair<int, int>> zipLists(const std::vector<int>& vec1, const std::vector<int>& vec2) { std::vector<std::pair<int, int>> result; for (int i = 0; i < std::min(vec1.size(), vec2.size()); ++i) result.emplace_back(vec1[i], vec2[i]); return result; }",
161
+ "std::map<int, int> listsToDict(const std::vector<int>& keys, const std::vector<int>& values) { std::map<int, int> result; for (int i = 0; i < std::min(keys.size(), values.size()); ++i) result[keys[i]] = values[i]; return result; }",
162
+ "bool listsEqual(const std::vector<int>& vec1, const std::vector<int>& vec2) { return vec1 == vec2; }",
163
+ "bool dictsEqual(const std::map<int, int>& dict1, const std::map<int, int>& dict2) { return dict1 == dict2; }",
164
+ "bool setsEqual(const std::set<int>& set1, const std::set<int>& set2) { return set1 == set2; }",
165
+ "std::vector<int> removeDuplicatesList(const std::vector<int>& vec) { std::set<int> s(vec.begin(), vec.end()); return std::vector<int>(s.begin(), s.end()); }",
166
+ "void clearSet(std::set<int>& s) { s.clear(); }",
167
+ "bool isSetEmpty(const std::set<int>& s) { return s.empty(); }",
168
+ "void addToSet(std::set<int>& s, int value) { s.insert(value); }",
169
+ "void removeFromSet(std::set<int>& s, int value) { s.erase(value); }",
170
+ "bool setContains(const std::set<int>& s, int value) { return s.find(value) != s.end(); }",
171
+ "int setSize(const std::set<int>& s) { return s.size(); }",
172
+ "bool setsIntersect(const std::set<int>& set1, const std::set<int>& set2) { return !setIntersection(set1, set2).empty(); }",
173
+ "bool isSubset(const std::vector<int>& vec1, const std::vector<int>& vec2) { std::set<int> s1(vec1.begin(), vec1.end()), s2(vec2.begin(), vec2.end()); return std::includes(s2.begin(), s2.end(), s1.begin(), s1.end()); }",
174
+ "bool isSubstring(const std::string& str, const std::string& substr) { return str.find(substr) != std::string::npos; }",
175
+ "char firstChar(const std::string& str) { return str.empty() ? '\\0' : str[0]; }",
176
+ "char lastChar(const std::string& str) { return str.empty() ? '\\0' : str.back(); }",
177
+ "bool isTextFile(const std::string& filename) { std::ifstream file(filename); char c; while (file.get(c)) if (!std::isprint(c) && !std::isspace(c)) return false; return true; }",
178
+ "bool isImageFile(const std::string& filename) { std::string ext = filename.substr(filename.find_last_of(\".\") + 1); return ext == \"jpg\" || ext == \"png\" || ext == \"gif\"; }",
179
+ "double roundNumber(double num) { return std::round(num); }",
180
+ "double ceilNumber(double num) { return std::ceil(num); }",
181
+ "double floorNumber(double num) { return std::floor(num); }",
182
+ "std::string formatDecimal(double num, int precision) { std::ostringstream oss; oss << std::fixed << std::setprecision(precision) << num; return oss.str(); }",
183
+ "std::string generateRandomString(int length) { static const char alphanum[] = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"; std::string result; for (int i = 0; i < length; ++i) result += alphanum[rand() % (sizeof(alphanum) - 1)]; return result; }",
184
+ "bool pathExists(const std::string& path) { std::ifstream file(path); return file.good(); }",
185
+ "void traverseDirectory(const std::string& path) { for (const auto& entry : std::filesystem::directory_iterator(path)) std::cout << entry.path() << std::endl; }",
186
+ "std::string getFileExtension(const std::string& filename) { return filename.substr(filename.find_last_of(\".\") + 1); }",
187
+ "std::string getFileName(const std::string& path) { return path.substr(path.find_last_of(\"/\\\") + 1); }",
188
+ "std::string getFullPath(const std::string& path) { return std::filesystem::absolute(path).string(); }",
189
+ "std::string getPythonVersion() { return \"C++ does not have Python version\"; }",
190
+ "std::string getSystemPlatform() { #ifdef _WIN32 return \"Windows\"; #elif __linux__ return \"Linux\"; #elif __APPLE__ return \"macOS\"; #else return \"Unknown\"; #endif }",
191
+ "int getCPUCores() { return std::thread::hardware_concurrency(); }",
192
+ "size_t getMemorySize() { return sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE); }",
193
+ "std::string getDiskUsage() { struct statvfs stats; if (statvfs(\"/\", &stats) == 0) return std::to_string(stats.f_bsize * stats.f_bfree); return \"Unknown\"; }",
194
+ "std::string getIPAddress() { struct ifaddrs* ifAddrStruct = nullptr; getifaddrs(&ifAddrStruct); std::string result; for (struct ifaddrs* ifa = ifAddrStruct; ifa != nullptr; ifa = ifa->ifa_next) { if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) { result = inet_ntoa(((struct sockaddr_in*)ifa->ifa_addr)->sin_addr); break; } } if (ifAddrStruct) freeifaddrs(ifAddrStruct); return result; }",
195
+ "bool isConnectedToInternet() { return system(\"ping -c 1 google.com\") == 0; }",
196
+ "void downloadFile(const std::string& url, const std::string& filename) { std::string command = \"curl -o \" + filename + \" \" + url; system(command.c_str()); }",
197
+ "void uploadFile(const std::string& filename) { std::cout << \"File uploaded: \" << filename << std::endl; }",
198
+ "void sendPostRequest(const std::string& url, const std::string& data) { std::string command = \"curl -X POST -d '\" + data + \"' \" + url; system(command.c_str()); }",
199
+ "void sendRequestWithParams(const std::string& url, const std::map<std::string, std::string>& params) { std::string command = \"curl -X GET \"; for (const auto& pair : params) command += \"-d \" + pair.first + \"=\" + pair.second + \" \"; command += url; system(command.c_str()); }",
200
+ "void setRequestHeader(const std::string& url, const std::map<std::string, std::string>& headers) { std::string command = \"curl -X GET \"; for (const auto& pair : headers) command += \"-H '\" + pair.first + \": \" + pair.second + \"' \"; command += url; system(command.c_str()); }",
201
+ "void parseHTML(const std::string& html) { std::regex pattern(\"<[^>]*>\"); std::smatch matches; std::string result = std::regex_replace(html, pattern, \"\"); std::cout << result << std::endl; }",
202
+ "std::string extractTitle(const std::string& html) { std::regex pattern(\"<title>(.*?)</title>\"); std::smatch matches; if (std::regex_search(html, matches, pattern)) return matches[1]; return \"\"; }",
203
+ "std::vector<std::string> extractLinks(const std::string& html) { std::regex pattern(\"<a href=\\\"(.*?)\\\".*?>\", std::regex_constants::icase); std::smatch matches; std::vector<std::string> result; for (std::sregex_iterator it(html.begin(), html.end(), pattern), end; it != end; ++it) result.push_back((*it)[1]); return result; }",
204
+ "void downloadImages(const std::string& html, const std::string& path) { std::regex pattern(\"<img[^>]+src=\\\"(.*?)\\\"[^>]*>\", std::regex_constants::icase); std::smatch matches; for (std::sregex_iterator it(html.begin(), html.end(), pattern), end; it != end; ++it) downloadFile((*it)[1], path + \"/\" + getFileName((*it)[1])); }",
205
+ "std::map<std::string, int> countWordFrequency(const std::string& text) { std::map<std::string, int> result; std::istringstream iss(text); std::string word; while (iss >> word) result[word]++; return result; }",
206
+ "void simulateLogin(const std::string& url, const std::string& username, const std::string& password) { std::string command = \"curl -X POST -d 'username=\" + username + \"&password=\" + password + \"' \" + url; system(command.c_str()); }",
207
+ "std::string htmlToText(const std::string& html) { std::regex pattern(\"<[^>]*>\"); return std::regex_replace(html, pattern, \"\"); }",
208
+ "std::vector<std::string> extractEmails(const std::string& text) { std::regex pattern(\"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\"); std::smatch matches; std::vector<std::string> result; for (std::sregex_iterator it(text.begin(), text.end(), pattern), end; it != end; ++it) result.push_back((*it)[0]); return result; }",
209
+ "std::vector<std::string> extractPhoneNumbers(const std::string& text) { std::regex pattern(\"\\\\+?\\\\d{1,4}[-.\\\\s]?\\\\d{1,4}[-.\\\\s]?\\\\d{1,9}\"); std::smatch matches; std::vector<std::string> result; for (std::sregex_iterator it(text.begin(), text.end(), pattern), end; it != end; ++it) result.push_back((*it)[0]); return result; }",
210
+ "std::vector<std::string> findAllNumbers(const std::string& text) { std::regex pattern(\"\\\\d+\"); std::smatch matches; std::vector<std::string> result; for (std::sregex_iterator it(text.begin(), text.end(), pattern), end; it != end; ++it) result.push_back((*it)[0]); return result; }",
211
+ "std::string regexReplace(const std::string& text, const std::string& pattern, const std::string& replacement) { return std::regex_replace(text, std::regex(pattern), replacement); }",
212
+ "bool matchesRegex(const std::string& text, const std::string& pattern) { return std::regex_match(text, std::regex(pattern)); }",
213
+ "std::string removeHtmlTags(const std::string& html) { std::regex pattern(\"<[^>]*>\"); return std::regex_replace(html, pattern, \"\"); }",
214
+ "std::string encodeHtmlEntities(const std::string& html) { std::string result; for (char c : html) { switch (c) { case '<': result += \"&lt;\"; break; case '>': result += \"&gt;\"; break; case '&': result += \"&amp;\"; break; case '\"': result += \"&quot;\"; break; case '\'': result += \"&apos;\"; break; default: result += c; } } return result; }",
215
+ "std::string decodeHtmlEntities(const std::string& html) { std::string result = html; result = std::regex_replace(result, std::regex(\"&lt;\"), \"<\"); result = std::regex_replace(result, std::regex(\"&gt;\"), \">\"); result = std::regex_replace(result, std::regex(\"&amp;\"), \"&\"); result = std::regex_replace(result, std::regex(\"&quot;\"), \"\\\"\"); result = std::regex_replace(result, std::regex(\"&apos;\"), \"'\"); return result; }",
216
+ "void createSimpleGUI() { Gtk::Window window; window.set_title(\"Simple GUI\"); window.set_default_size(200, 200); Gtk::Button button(\"Click Me\"); button.signal_clicked().connect([]() { std::cout << \"Button clicked\" << std::endl; }); window.add(button); window.show_all(); Gtk::Main::run(window); }",
217
+ "void addButtonToWindow() { GtkWidget *button = gtk_button_new_with_label(\"Button\"); gtk_window_add(GTK_WINDOW(window), button); }",
218
+ "void handleButtonClick() { g_signal_connect(button, \"clicked\", G_CALLBACK([]() { std::cout << \"Button clicked!\" << std::endl; }), NULL); }",
219
+ "void showPopup() { GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, \"Popup Message\"); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); }",
220
+ "std::string getTextBoxInput() { const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); return std::string(text); }",
221
+ "void setWindowTitle(const std::string& title) { gtk_window_set_title(GTK_WINDOW(window), title.c_str()); }",
222
+ "void setWindowSize(int width, int height) { gtk_window_set_default_size(GTK_WINDOW(window), width, height); }",
223
+ "void centerWindow() { gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); }",
224
+ "void useMenuBar() { GtkWidget *menu_bar = gtk_menu_bar_new(); gtk_container_add(GTK_CONTAINER(window), menu_bar); }",
225
+ "void createDropdown() { GtkWidget *combo = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), \"Option 1\"); gtk_container_add(GTK_CONTAINER(window), combo); }",
226
+ "void useRadioButton() { GtkWidget *radio1 = gtk_radio_button_new_with_label(NULL, \"Option 1\"); gtk_container_add(GTK_CONTAINER(window), radio1); }",
227
+ "void useCheckbox() { GtkWidget *check = gtk_check_button_new_with_label(\"Checkbox\"); gtk_container_add(GTK_CONTAINER(window), check); }",
228
+ "void displayImage(const std::string& filePath) { GtkWidget *image = gtk_image_new_from_file(filePath.c_str()); gtk_container_add(GTK_CONTAINER(window), image); }",
229
+ "void playAudio(const std::string& filePath) { system((\"mpg123 \" + filePath).c_str()); }",
230
+ "void playVideo(const std::string& filePath) { system((\"vlc \" + filePath).c_str()); }",
231
+ "int getCurrentPlaybackTime() { return 0; }",
232
+ "void captureScreen() { system(\"import -window root screenshot.png\"); }",
233
+ "void recordScreen(int duration) { system((\"ffmpeg -f x11grab -video_size 1920x1080 -i :0.0 -t \" + std::to_string(duration) + \" output.mp4\").c_str()); }",
234
+ "std::pair<int, int> getMousePosition() { return {0, 0}; }",
235
+ "void simulateKeyboardInput(const std::string& input) { system((\"xdotool type \" + input).c_str()); }",
236
+ "void simulateMouseClick(int x, int y) { system((\"xdotool mousemove \" + std::to_string(x) + \" \" + std::to_string(y) + \" click 1\").c_str()); }",
237
+ "time_t getCurrentTimestamp() { return time(nullptr); }",
238
+ "std::string timestampToDate(time_t timestamp) { char buffer[80]; strftime(buffer, 80, \"%Y-%m-%d\", localtime(&timestamp)); return buffer; }",
239
+ "time_t dateToTimestamp(const std::string& date) { struct tm tm; strptime(date.c_str(), \"%Y-%m-%d\", &tm); return mktime(&tm); }",
240
+ "std::string getCurrentWeekday() { time_t now = time(nullptr); char buffer[80]; strftime(buffer, 80, \"%A\", localtime(&now)); return buffer; }",
241
+ "int getDaysInMonth(int year, int month) { if (month == 2) return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 29 : 28; else if (month == 4 || month == 6 || month == 9 || month == 11) return 30; else return 31; }",
242
+ "std::string getFirstDayOfYear(int year) { char buffer[80]; strftime(buffer, 80, \"%Y-01-01\", localtime(&(time_t){0})); return buffer; }",
243
+ "std::string getLastDayOfYear(int year) { char buffer[80]; strftime(buffer, 80, \"%Y-12-31\", localtime(&(time_t){0})); return buffer; }",
244
+ "std::string getFirstDayOfMonth(int year, int month) { char buffer[80]; strftime(buffer, 80, \"%Y-%m-01\", localtime(&(time_t){0})); return buffer; }",
245
+ "std::string getLastDayOfMonth(int year, int month) { int days = getDaysInMonth(year, month); char buffer[80]; snprintf(buffer, 80, \"%04d-%02d-%02d\", year, month, days); return buffer; }",
246
+ "bool isWeekday() { time_t now = time(nullptr); struct tm* tm = localtime(&now); return tm->tm_wday >= 1 && tm->tm_wday <= 5; }",
247
+ "bool isWeekend() { time_t now = time(nullptr); struct tm* tm = localtime(&now); return tm->tm_wday == 0 || tm->tm_wday == 6; }",
248
+ "int getCurrentHour() { time_t now = time(nullptr); return localtime(&now)->tm_hour; }",
249
+ "int getCurrentMinute() { time_t now = time(nullptr); return localtime(&now)->tm_min; }",
250
+ "int getCurrentSecond() { time_t now = time(nullptr); return localtime(&now)->tm_sec; }",
251
+ "void delay(int seconds) { sleep(seconds); }",
252
+ "long getMillisecondTimestamp() { auto now = std::chrono::system_clock::now(); return std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count(); }",
253
+ "std::string formatTime(const std::string& format) { time_t now = time(nullptr); char buffer[80]; strftime(buffer, 80, format.c_str(), localtime(&now)); return buffer; }",
254
+ "time_t parseTime(const std::string& timeStr, const std::string& format) { struct tm tm; strptime(timeStr.c_str(), format.c_str(), &tm); return mktime(&tm); }",
255
+ "void createThread(void (*func)()) { std::thread t(func); t.detach(); }",
256
+ "void pauseThread() { std::this_thread::sleep_for(std::chrono::seconds(1)); }",
257
+ "void runFunctionInThread(void (*func)()) { std::thread t(func); t.join(); }",
258
+ "std::string getCurrentThreadName() { return \"\"; }",
259
+ "void setThreadAsDaemon() { }",
260
+ "void synchronizeThreads() { std::mutex mtx; mtx.lock(); mtx.unlock(); }",
261
+ "void createProcess() { if (fork() == 0) { exit(0); } }",
262
+ "int getProcessPID() { return getpid(); }",
263
+ "bool isProcessAlive(int pid) { return kill(pid, 0) == 0; }",
264
+ "void runFunctionInProcess(void (*func)()) { if (fork() == 0) { func(); exit(0); } }",
265
+ "void useQueueForThreadCommunication() { std::queue<int> q; q.push(1); q.pop(); }",
266
+ "void usePipeForCommunication() { int fd[2]; pipe(fd); }",
267
+ "void limitCPUUsage() { }",
268
+ "void runShellCommand(const std::string& command) { system(command.c_str()); }",
269
+ "std::string getCommandOutput(const std::string& command) { std::string result; FILE* pipe = popen(command.c_str(), \"r\"); if (pipe) { char buffer[128]; while (fgets(buffer, sizeof(buffer), pipe) != nullptr) { result += buffer; } pclose(pipe); } return result; }",
270
+ "int getCommandStatusCode(const std::string& command) { return system(command.c_str()); }",
271
+ "bool isCommandSuccessful(const std::string& command) { return system(command.c_str()) == 0; }",
272
+ "std::string getCurrentScriptPath() { return \"\"; }",
273
+ "std::vector<std::string> getCommandLineArgs(int argc, char* argv[]) { return std::vector<std::string>(argv, argv + argc); }",
274
+ "void useArgparse(int argc, char* argv[]) { }",
275
+ "void generateCommandHelp() { }",
276
+ "void listPythonModules() { }",
277
+ "void installPythonPackage(const std::string& package) { system((\"pip install \" + package).c_str()); }",
278
+ "void uninstallPythonPackage(const std::string& package) { system((\"pip uninstall \" + package).c_str()); }",
279
+ "std::string getPackageVersion(const std::string& package) { return \"\"; }",
280
+ "void useVirtualEnvironment() { system(\"python3 -m venv venv\"); }",
281
+ "void listInstalledPackages() { system(\"pip list\"); }",
282
+ "void upgradePythonPackage(const std::string& package) { system((\"pip install --upgrade \" + package).c_str()); }",
283
+ "void connectToLocalDatabase() { sqlite3 *db; sqlite3_open(\":memory:\", &db); }",
284
+ "void executeSQLQuery(const std::string& query) { sqlite3 *db; sqlite3_exec(db, query.c_str(), 0, 0, 0); }",
285
+ "void insertRecord() { sqlite3 *db; sqlite3_exec(db, \"INSERT INTO table VALUES (1, 'value')\", 0, 0, 0); }",
286
+ "void deleteRecord() { sqlite3 *db; sqlite3_exec(db, \"DELETE FROM table WHERE id = 1\", 0, 0, 0); }",
287
+ "void updateRecord() { sqlite3 *db; sqlite3_exec(db, \"UPDATE table SET column = 'new_value' WHERE id = 1\", 0, 0, 0); }",
288
+ "void queryMultipleRecords() { sqlite3 *db; sqlite3_exec(db, \"SELECT * FROM table\", 0, 0, 0); }",
289
+ "void useParameterizedQuery() { sqlite3 *db; sqlite3_stmt *stmt; sqlite3_prepare_v2(db, \"SELECT * FROM table WHERE id = ?\", -1, &stmt, 0); }",
290
+ "void closeDatabaseConnection() { sqlite3 *db; sqlite3_close(db); }",
291
+ "void createTable() { sqlite3 *db; sqlite3_exec(db, \"CREATE TABLE table (id INT, column TEXT)\", 0, 0, 0); }",
292
+ "void deleteTable() { sqlite3 *db; sqlite3_exec(db, \"DROP TABLE table\", 0, 0, 0); }",
293
+ "bool tableExists() { return false; }",
294
+ "void getAllTables() { sqlite3 *db; sqlite3_exec(db, \"SELECT name FROM sqlite_master WHERE type = 'table'\", 0, 0, 0); }",
295
+ "void useORMInsert() { sqlite3 *db; sqlite3_exec(db, \"INSERT INTO table VALUES (1, 'value')\", 0, 0, 0); }",
296
+ "void useORMQuery() { sqlite3 *db; sqlite3_exec(db, \"SELECT * FROM table\", 0, 0, 0); }",
297
+ "void useORMDelete() { sqlite3 *db; sqlite3_exec(db, \"DELETE FROM table WHERE id = 1\", 0, 0, 0); }",
298
+ "void useORMUpdate() { sqlite3 *db; sqlite3_exec(db, \"UPDATE table SET column = 'new_value' WHERE id = 1\", 0, 0, 0); }",
299
+ "void defineModelClass() { struct Model { int id; std::string value; }; }",
300
+ "void implementModelInheritance() { struct Base { int id; }; struct Derived : Base { std::string value; }; }",
301
+ "void setPrimaryKeyField() { struct Model { int id; std::string value; }; }",
302
+ "void setUniqueConstraint() { struct Model { int id; std::string value; }; }",
303
+ "void setFieldDefaultValue() { struct Model { int id = 0; std::string value = \"default\"; }; }",
304
+ "void exportToCSV() { std::ofstream file(\"data.csv\"); file << \"id,value\\n1,example\"; file.close(); }",
305
+ "void exportToExcel() { std::ofstream file(\"data.xls\"); file << \"id\tvalue\n1\texample\"; file.close(); }",
306
+ "void exportToJSON() { std::ofstream file(\"data.json\"); file << \"{\\\"id\\\":1,\\\"value\\\":\\\"example\\\"}\"; file.close(); }",
307
+ "void readExcelData() { std::ifstream file(\"data.xls\"); std::string line; while (std::getline(file, line)) { std::cout << line << std::endl; } }",
308
+ "void mergeExcelFiles() { std::ofstream merged(\"merged.xls\"); std::ifstream file1(\"data1.xls\"); std::ifstream file2(\"data2.xls\"); merged << file1.rdbuf() << file2.rdbuf(); }",
309
+ "void addSheetToExcel() { std::ofstream file(\"data.xls\", std::ios::app); file << \"\\nNew Sheet\"; }",
310
+ "void copyExcelStyle() { std::ifstream src(\"source.xls\"); std::ofstream dst(\"destination.xls\"); dst << src.rdbuf(); }",
311
+ "void setExcelCellColor() { std::ofstream file(\"data.xls\", std::ios::app); file << \"\\nCell Color: Red\"; }",
312
+ "void setExcelFontStyle() { std::ofstream file(\"data.xls\", std::ios::app); file << \"\\nFont Style: Bold\"; }",
313
+ "void readExcelCellContent() { std::ifstream file(\"data.xls\"); std::string line; std::getline(file, line); std::cout << line << std::endl; }",
314
+ "void writeExcelCellContent() { std::ofstream file(\"data.xls\", std::ios::app); file << \"\\nNew Content\"; }",
315
+ "void getImageDimensions(const std::string& filePath) { std::ifstream file(filePath, std::ios::binary); file.seekg(16); int width, height; file.read((char*)&width, 4); file.read((char*)&height, 4); std::cout << \"Width: \" << width << \", Height: \" << height << std::endl; }",
316
+ "void resizeImage(const std::string& filePath, int width, int height) { std::string command = \"convert \" + filePath + \" -resize \" + std::to_string(width) + \"x\" + std::to_string(height) + \" \" + filePath; system(command.c_str()); }"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
 
318
 
319