public static string CHeading(string path) { string text = Lib.File_ReadToEnd("C:\\home\\hidemaru\\template\\c_heading_001.txt"); if (File.Exists(path)) { try { string newValue = path.Replace("F:", "http://localhost").Replace("\\", "/"); text = text.Replace("%%FILEEXT%%", Path.GetExtension(path)).Replace(".", ""); text = text.Replace("%%FILENAME%%", Path.GetFileName(path)); text = text.Replace("%%FILEPATH%%", path); text = text.Replace("%%LOCALURL%%", newValue); text = text.Replace("%%TIMESTAMP%%", StringHandler.timestamp()); } catch (Exception ex) { string message = ex.Message.ToString(); MessageBox.Show(Lib.OutputError(message)); return(ex.Message.ToString()); } return(text); } return(text); }
public static void StackTrace(string text, int ptr) { MessageBox.Show(ptr.ToString()); MessageBox.Show(text[ptr].ToString()); Point point = StringHandler.Ptr2Pos(text, ptr); MessageBox.Show(string.Format("行:{0} 列:{1}", point.Y + 1, point.X + 1)); MessageBox.Show(StringHandler.GetLine(text, point.Y)); }
public static string File_ReadToEndDecode(string filepath) { if (!File.Exists(filepath)) { return(null); } FileStream fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read); byte[] array = new byte[fileStream.Length]; fileStream.Read(array, 0, array.Length); fileStream.Close(); Encoding code = StringHandler.GetCode(array); return(code.GetString(array)); }
public static List <string> ListIdentifiers(string text) { List <string> list = new List <string>(); string[] array = text.Split(new char[] { '\n' }); string arg_1F_0 = string.Empty; for (int i = 0; i < array.Length; i++) { if (StringHandler.GetDataType(array[i]) != string.Empty) { list.Add(StringHandler.GetPrototype(array[i])); } } return(list); }
public static string File_GetCode(string filepath) { if (!File.Exists(filepath)) { return(null); } FileStream fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read); byte[] array = new byte[fileStream.Length]; fileStream.Read(array, 0, array.Length); fileStream.Close(); Encoding code = StringHandler.GetCode(array); string result; try { result = code.WebName.ToUpper(); } catch { result = ""; } return(result); }
public static string GetToken(ref string text, ref int ptr) { string text2 = string.Empty; while (char.IsWhiteSpace(text[ptr]) && !string.IsNullOrEmpty(text[ptr].ToString())) { ptr++; } if (ptr == text.Length) { return(string.Empty); } if ("{}".IndexOf(text[ptr].ToString()) > -1) { ptr++; return(text[ptr - 1].ToString()); } while (text[ptr] == '/') { if (text[ptr + 1] != '*' && text[ptr + 1] != '/') { break; } if (text[ptr + 1] == '*') { ptr += 2; while (true) { if (text[ptr] == '*') { ptr++; if (text[ptr] == '/') { break; } } else { ptr++; } } ptr++; } else if (text[ptr + 1] == '/') { ptr += 2; while (text[ptr] != '\n') { ptr++; } } while (char.IsWhiteSpace(text[ptr]) && !string.IsNullOrEmpty(text[ptr].ToString())) { ptr++; } } while (char.IsWhiteSpace(text[ptr]) && !string.IsNullOrEmpty(text[ptr].ToString())) { ptr++; } if ("!<>=".IndexOf(text[ptr].ToString()) > -1) { char c = text[ptr]; if (c != '!') { switch (c) { case '<': if (text[ptr + 1] == '<' && text[ptr + 2] == '=') { ptr++; ptr++; ptr++; return("<<="); } if (text[ptr + 1] == '=') { ptr++; ptr++; return("<="); } if (text[ptr + 1] == '<') { ptr++; ptr++; return("<<"); } ptr++; return("<"); case '=': if (text[ptr + 1] == '=') { ptr++; ptr++; return("=="); } break; case '>': if (text[ptr + 1] == '>' && text[ptr + 2] == '=') { ptr++; ptr++; ptr++; return(">>="); } if (text[ptr + 1] == '=') { ptr++; ptr++; return(">="); } if (text[ptr + 1] == '>') { ptr++; ptr++; return(">>"); } ptr++; return(">"); } } else if (text[ptr + 1] == '=') { ptr++; ptr++; return("!="); } } if ("+-*/%^=;(),'?:~!&|".IndexOf(text[ptr].ToString()) > -1) { char c2 = text[ptr]; switch (c2) { case '%': if (text[ptr + 1] == '=') { ptr++; ptr++; return("%="); } ptr++; return("%"); case '&': if (text[ptr + 1] == '&') { ptr++; ptr++; return("&&"); } if (text[ptr + 1] == '=') { ptr++; ptr++; return("&="); } ptr++; return("&"); case '\'': case '(': case ')': case ',': case '.': break; case '*': if (text[ptr + 1] == '=') { ptr++; ptr++; return("*="); } ptr++; return("*"); case '+': if (text[ptr + 1] == '+') { ptr++; ptr++; return("++"); } if (text[ptr + 1] == '=') { ptr++; ptr++; return("+="); } ptr++; return("+"); case '-': if (text[ptr + 1] == '-') { ptr++; ptr++; return("--"); } if (text[ptr + 1] == '=') { ptr++; ptr++; return("-="); } if (text[ptr + 1] == '>') { ptr++; ptr++; return("->"); } ptr++; return("-"); case '/': if (text[ptr + 1] == '=') { ptr++; ptr++; return("/="); } ptr++; return("/"); default: if (c2 != '^') { if (c2 == '|') { if (text[ptr + 1] == '|') { ptr++; ptr++; return("||"); } if (text[ptr + 1] == '=') { ptr++; ptr++; return("|="); } ptr++; return("|"); } } else { if (text[ptr + 1] == '=') { ptr++; ptr++; return("^="); } ptr++; return("^"); } break; } ptr++; return(text[ptr - 1].ToString()); } if (text[ptr] == '"') { ptr++; while (text[ptr] != '"' && text[ptr] != '\n') { text2 += text[ptr++].ToString(); } if (text[ptr] == '\n') { MessageBox.Show("シンタックスエラー"); } ptr++; return("\"" + text2 + "\""); } if (char.IsDigit(text[ptr])) { text2 = string.Empty; while (!StringHandler.isdelim(text[ptr])) { text2 += text[ptr].ToString(); ptr++; } return(text2); } if (char.IsLetter(text[ptr])) { text2 = string.Empty; while (!StringHandler.isdelim(text[ptr])) { text2 += text[ptr].ToString(); ptr++; } return(text2); } return(text2); }
public static string GetLineFromPtr(string str, int ptr) { return(StringHandler.GetLine(str, StringHandler.Ptr2Pos(str, ptr).Y)); }