我需要一个简单的php库,可以轻松地将规则和字段名称传递给,然后可以轻松执行验证.还应该有一种简单的方法来检索错误.
有什么建议?
有没有办法知道StreamReader使用了多少字节的流?
我有一个项目,我们需要读取一个文件,其中包含文本标题,后跟二进制数据的开头.我最初尝试阅读此文件是这样的:
private int _dataOffset;
void ReadHeader(string path)
{
using (FileStream stream = File.OpenRead(path))
{
StreamReader textReader = new StreamReader(stream);
do
{
string line = textReader.ReadLine();
handleHeaderLine(line);
} while(line != "DATA") // Yes, they used "DATA" to mark the end of the header
_dataOffset = stream.Position;
}
}
private byte[] ReadDataFrame(string path, int frameNum)
{
using (FileStream stream = File.OpenRead(path))
{
stream.Seek(_dataOffset + frameNum * cbFrame, SeekOrigin.Begin);
byte[] data = new byte[cbFrame];
stream.Read(data, 0, cbFrame);
return data;
}
return null; …Run Code Online (Sandbox Code Playgroud) 我原来是来自C#的世界,我正在学习C++.我一直想知道在C++中获取和设置函数.在C#中,这些使用非常流行,而像Visual Studio这样的工具通过使它们变得非常容易和快速实现来促进使用.但是,在C++世界中似乎并非如此.
这是C#2.0代码:
public class Foo
{
private string bar;
public string Bar
{
get { return bar; }
set { bar = value; }
}
}
Run Code Online (Sandbox Code Playgroud)
或者,在C#3.0中:
public class Foo { get; set; }
Run Code Online (Sandbox Code Playgroud)
可能人们会说,那是什么意思呢?为什么不创建一个公共字段,然后在需要时将其变为属性; 老实说,我其实不确定.我只是出于好的做法,因为我已经看过很多次了.
现在因为我已经习惯了这样做,我觉得我应该把习惯延续到我的C++代码中,但这真的有必要吗?我没有像C#那样频繁地完成它.
无论如何,这是我收集的C++:
class Foo
{
public:
std::string GetBar() const; // Thanks for the tip Earwicker.
void SetBar(std::string bar);
private:
std::string bar;
}
const std::string Foo::GetBar()
{
return bar;
}
void Foo::SetBar(std::string bar)
{
// Also, I always wonder if using 'this->' is good …Run Code Online (Sandbox Code Playgroud) 下面是我用来将地图数组"翻译"成SQL代码的一些代码,这样当我更新我的游戏地图时,我可以轻松更新我的数据库.正如您所看到的,它将SQL代码打印到屏幕上,以便我可以复制并粘贴它.
随着我的地图变得越来越大,这将变得效率低下,因为它会因为大量输出而导致浏览器崩溃,所以我想知道是否可以创建.txt文件并将所有数据写入其中而不是打印到屏幕?
<?php
if (isset($_POST['code'])){
$map = $_POST['code'];
$map = preg_replace("/,\\s*}/i", "}", $map);
$map = str_replace("{", "[", $map);
$map = str_replace("}", "]", $map);
$map = json_decode('[' . $map . ']');
$arrayCount1 = 0;
$arrayCount2 = -1;
$H = sprintf('%05d', 00000);
$V = sprintf('%05d', 00000);
$id = 1;
echo "INSERT INTO `map` (`id`, `horizontal`, `verticle`, `image`) VALUES" . "<br />";
for ($count1 = 0; $count1 < sizeof($map[0]); $count1++){
$arrayCount2++;
$arrayCount1 = 0;
$V = sprintf('%05d', $V + 1);
$H = sprintf('%05d', …Run Code Online (Sandbox Code Playgroud) 我更喜欢在纸上记下UML图,然后使用Java实现它们.如果有一个可以为我创建UML图表的实用程序,我可以在线共享并包含在数字文档中,这将是一件好事.换句话说:我想从Java源代码创建UML图.
该实用程序必须能够:
如果该实用程序能够:
是否可以在托管代码中启动另一个EXE?这时,我所能做的就是使用:
System.Diagnostics.Process.Start(exeName)
Run Code Online (Sandbox Code Playgroud)
还有另一种方法可以在同一个项目中调用另一个EXE吗?
谢谢!JFV
这里有点困惑,formatResult和formatItem在JQuery Autocomplete插件中做了什么?
我有一个函数返回逗号分隔的字符串(来自Django),但我的自动完成功能无法将字符串拆分为单独的条目/行,我如何使用自动完成功能实现此目的?
例如,返回的结果如下所示,这就是自动完成显示的内容: - ["one","oneTwo","Onethree","anotherOne"]
我希望在自动填充字段中显示时将其拆分为: -
one
oneTwo
Onethree
anotherOne
Run Code Online (Sandbox Code Playgroud)
我有一种感觉,我可以使用formatResult和formatItem,但我不知道怎么样,没有好的例子!
我的代码在html模板中:
function autoFill(){
$("#tags").autocomplete("/taglookup/", {
width: 320,
max: 4,
highlight: false,
multiple: true,
multipleSeparator: " ",
scroll: true,
scrollHeight: 300
});
}
Run Code Online (Sandbox Code Playgroud)
我使用Dajango来处理GET请求.
迦特
我有这个类,我使用jQuery和Prototype的组合:
var MyClass = Class.create({
initElements: function(sumEl) {
this.sumEl = sumEl;
sumEl.keyup(this.updateSumHandler);
},
updateSumHandler: function(event) {
// Throws error here: "this.updateSum is not a function"
this.updateSum();
},
updateSum: function() {
// does something here
}
});
Run Code Online (Sandbox Code Playgroud)
我怎么能打电话this.updateSum()呢?
任何人都可以给我发送一个示例nant.build文件,该文件从名为file.txt的文本文件中读取值.
谢谢Maddy
我正在练习Ruby和正则表达式删除某些不需要的字符.例如:
input = input.gsub(/<\/?[^>]*>/, '')
Run Code Online (Sandbox Code Playgroud)
对于特殊字符,例如☻或™:
input = input.gsub('&#', '')
Run Code Online (Sandbox Code Playgroud)
这只留下数字,好的.但这仅在用户输入特殊字符作为代码时才有效,如下所示:
™
Run Code Online (Sandbox Code Playgroud)
我的问题: 如果用户输入没有代码的特殊字符,我如何删除特殊字符,如下所示:
™ ?
Run Code Online (Sandbox Code Playgroud) .net ×2
c# ×2
javascript ×2
jquery ×2
php ×2
.net-3.5 ×1
c++ ×1
crud ×1
django ×1
file ×1
java ×1
oop ×1
properties ×1
prototypejs ×1
regex ×1
ruby ×1
uml ×1
utilities ×1
validation ×1
vb.net ×1